feat(corpus): add save-to-corpus + private corpus search scope

- POST /api/save-to-corpus.php — saves tool output text to user's default CaveauAI corpus via ClientRagPipeline
- api/case/upload.php — dual-writes uploaded PDFs to CaveauAI client_documents (best-effort)
- assets/js/corpus-save.js — shared <dialog> handler for .js-save-corpus buttons on all tool pages
- includes/layout_footer.php — injects corpus-save.js + shared save dialog markup
- korrespond/deep-research/barnevernet/discrepancy JS — save-to-corpus buttons on output sections
- api/search.php + LegalTools::search() — corpus_scope param ('shared'|'private'|'both'), merges personal CaveauAI corpus with shared legal library when 'both'
- includes/tool_form.php + assets/js/tools.js — corpus scope radio toggle shown on search tab
- api/user-docs.php — add POST upload method for non-SSO authenticated users

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 17:50:32 +02:00
parent ed329f9d05
commit b014638f39
13 changed files with 465 additions and 33 deletions
+15
View File
@@ -563,6 +563,21 @@
${nextHtml}
`;
// Save-to-corpus button (inject after brief block)
const briefEl = els.results.querySelector('.dr-brief');
if (briefEl) {
briefEl.id = 'drBriefText';
const saveBtn = document.createElement('button');
saveBtn.type = 'button';
saveBtn.className = 'js-save-corpus secondary-button';
saveBtn.dataset.tool = 'deep-research';
saveBtn.dataset.contentId = 'drBriefText';
saveBtn.dataset.suggestedTitle = 'Research: ' + (document.getElementById('drQuery')?.value?.slice(0, 80) ?? 'Report');
saveBtn.textContent = 'Save to corpus';
saveBtn.style.marginTop = '12px';
briefEl.insertAdjacentElement('afterend', saveBtn);
}
// Bind source-card click handlers (open modal) — but ignore clicks on inner <a>
els.results.querySelectorAll('.dr-source-card[data-source-n]').forEach((node) => {
node.addEventListener('click', (e) => {