Add sub-question branching + document summary modals

- Source modal now shows LLM-generated document summary (lazy-gen + cached
  in documents.summary) instead of raw chunk text; toggle reveals matched
  chunk; "View all chunks" button fetches every chunk of the document via
  new api/document-chunks.php endpoint
- Each sub-question card gets a "Branch ↓" button that pre-fills the query
  with that sub-question and shows a context panel with the prior brief
  summary; prior_context + branch_notes are injected into interpretSeed()
  and synthesise() so the LLM knows where the research is coming from
- Upload document summaries generated at synthesis time and attached to
  upload sources alongside corpus summaries
- DB: documents.summary TEXT column added to bnl_corpus on chloe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 19:44:27 +02:00
parent 0ff4eb6d31
commit 343b19d0b4
8 changed files with 566 additions and 28 deletions
+14
View File
@@ -129,6 +129,20 @@ require_once __DIR__ . '/includes/layout.php';
</div>
</div>
<div id="drBranchPanel" class="branch-panel is-hidden" aria-label="Branch context">
<div class="branch-panel__head">
<span class="branch-panel__label">Branching from sub-question</span>
<button type="button" id="drBranchClear" class="upload-clear">&times; Clear branch</button>
</div>
<p id="drBranchOrigin" class="branch-panel__origin"></p>
<details class="branch-panel__prior">
<summary>Prior brief summary</summary>
<div id="drBranchSummary" class="branch-panel__brief"></div>
</details>
<label class="input-label" for="drBranchNotes">Add your notes / context</label>
<textarea id="drBranchNotes" rows="3" placeholder="Optional: add observations, corrections, or additional context for this branch…"></textarea>
</div>
<label class="input-label" for="drInput">Question or pasted text</label>
<textarea id="drInput" name="drInput" rows="8" placeholder="Describe the legal question, paste case notes, or both. The agent will research the corpus from 35 angles."></textarea>