fix: band-level windowed refine_layout + programmatic map_fields to prevent 91.5% content loss

Root cause: LLM receiving full 34k-char JRXML would regenerate from scratch
instead of modifying coordinates in-place, shrinking output to ~3k chars.

Solution (programmatic node control, not prompt engineering):

- New agent/jrxml_windower.py: decompose JRXML into header (never sent to
  LLM) + individual bands. Split bands >4000 chars at element boundaries.
  Reassemble with element count validation (>10% change = rollback).

- Rewrite refine_layout: per-band windowed LLM processing (~2-4k chars
  each). LLM cannot "reimagine" the entire report.

- Rewrite map_fields: 100% programmatic regex $F{field_N} -> real name
  replacement. Zero LLM calls, zero content loss.

- _sanitize_field_name: non-ASCII chars escaped to _uXXXX_ format for
  valid JRXML identifiers.

- Tests: 48 new unit tests (windower 28 + map_fields 20). All passing.
  Full suite 385 tests, zero regressions.
This commit is contained in:
2026-05-24 08:55:38 +08:00
parent bb6cc6e241
commit bd5bfbac2d
80 changed files with 39463 additions and 108 deletions
+13
View File
@@ -8,9 +8,19 @@ import ChatMessages from './components/ChatMessages.vue'
import ProcessSection from './components/ProcessSection.vue'
import SummaryCard from './components/SummaryCard.vue'
import UnifiedInput from './components/UnifiedInput.vue'
import KbSelector from './components/KbSelector.vue'
import KbManager from './components/KbManager.vue'
import { useKbStore } from './stores/kb'
const chat = useChatStore()
const session = useSessionStore()
const kb = useKbStore()
function handleKbChange(kbId: string) {
if (session.currentId) {
kb.bindKbToSession(session.currentId, kbId)
}
}
const chatContainer = ref<HTMLElement | null>(null)
@@ -128,6 +138,7 @@ async function handleSend(text: string, files: File[]) {
<Sidebar @quickAction="(text) => handleSend(text, [])" />
<main class="main-area">
<KbSelector @change="handleKbChange" />
<div class="chat-container" ref="chatContainer">
<ChatMessages />
<ProcessSection />
@@ -139,6 +150,8 @@ async function handleSend(text: string, files: File[]) {
@send="handleSend"
/>
</main>
<KbManager />
</div>
</template>