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
+165 -2
View File
@@ -2573,7 +2573,7 @@ p {
.dr-source-modal__meta dt:first-of-type { margin-top: 0; }
.dr-source-modal__text {
white-space: pre-wrap;
white-space: normal;
line-height: 1.7;
color: var(--ink);
}
@@ -2600,7 +2600,7 @@ p {
.dr-subq-report__head {
display: grid;
grid-template-columns: auto 1fr;
grid-template-columns: auto 1fr auto;
gap: 10px;
align-items: start;
margin-bottom: 10px;
@@ -3213,3 +3213,166 @@ a.dr-source-title-link:hover {
.adv-role-select, .adv-role-custom { max-width: 100%; }
.adv-banner { flex-direction: column; align-items: flex-start; }
}
/* ── Branch-from-sub-question panel ──────────────────────────────────────── */
.branch-panel {
background: #f0faf8;
border: 1px solid var(--teal);
border-left: 4px solid var(--teal);
border-radius: 8px;
padding: 14px 16px;
margin-bottom: 16px;
}
.branch-panel__head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 6px;
}
.branch-panel__label {
font-weight: 700;
font-size: 0.82rem;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--teal-dark);
}
.branch-panel__origin {
margin: 0 0 8px;
font-size: 0.88rem;
color: var(--ink);
line-height: 1.45;
}
.branch-panel__prior {
margin-bottom: 10px;
font-size: 0.87rem;
}
.branch-panel__prior summary {
cursor: pointer;
color: var(--teal-dark);
font-weight: 600;
user-select: none;
}
.branch-panel__brief {
margin-top: 6px;
padding: 8px 10px;
background: rgba(255,255,255,0.7);
border-radius: 5px;
font-size: 0.86rem;
color: var(--muted);
line-height: 1.5;
white-space: pre-wrap;
}
/* "Branch ↓" button on sub-Q cards */
.dr-branch-btn {
align-self: start;
padding: 4px 10px;
font-size: 0.78rem;
font-weight: 700;
background: transparent;
border: 1px solid var(--teal);
border-radius: 5px;
color: var(--teal-dark);
white-space: nowrap;
transition: background 0.12s, color 0.12s;
}
.dr-branch-btn:hover {
background: var(--teal);
color: #fff;
}
/* ── Source modal: summary + chunk toggle + all-chunks ───────────────────── */
.dr-modal-summary {
font-size: 0.93rem;
line-height: 1.65;
color: var(--ink);
margin-bottom: 14px;
}
.dr-modal-summary--empty em {
color: var(--muted);
font-size: 0.87rem;
}
.dr-modal-chunk-toggle,
.dr-modal-all-chunks {
display: inline-block;
margin-bottom: 8px;
padding: 4px 10px;
font-size: 0.8rem;
font-weight: 600;
background: transparent;
border: 1px solid var(--line);
border-radius: 5px;
color: var(--teal-dark);
cursor: pointer;
transition: background 0.12s, border-color 0.12s;
}
.dr-modal-chunk-toggle:hover,
.dr-modal-all-chunks:hover {
background: var(--soft-teal);
border-color: var(--teal);
}
.dr-modal-chunk-text {
white-space: pre-wrap;
font-size: 0.87rem;
line-height: 1.65;
color: var(--muted);
background: #f8f9fb;
border: 1px solid var(--line);
border-radius: 6px;
padding: 10px 12px;
margin-bottom: 12px;
}
.dr-modal-all-chunks {
display: block;
width: 100%;
text-align: left;
margin-top: 4px;
}
.dr-modal-chunks-list {
margin-top: 4px;
}
.dr-modal-chunks-head {
font-weight: 700;
font-size: 0.82rem;
color: var(--teal-dark);
padding: 6px 0 8px;
border-bottom: 1px solid var(--line);
margin-bottom: 8px;
}
.dr-modal-chunk-item {
padding: 8px 0;
border-bottom: 1px solid var(--line);
}
.dr-modal-chunk-item:last-child { border-bottom: 0; }
.dr-modal-chunk-idx {
display: block;
font-size: 0.78rem;
font-weight: 700;
color: var(--coral);
margin-bottom: 4px;
}
.dr-modal-chunk-preview {
margin: 0;
font-size: 0.86rem;
line-height: 1.5;
color: var(--muted);
white-space: pre-wrap;
}