From 5f13f7b3c9b666e8bbcd7272c02fe9aea981276c Mon Sep 17 00:00:00 2001 From: Lukas Parsons Date: Tue, 7 Jul 2026 11:49:24 -0400 Subject: [PATCH] feat: 'Send to Chat' button in document editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a 'Chat' button to the left of the Save button in the document editor footer. Clicking it injects a reference into the chat textarea: [Title](#document-) — <120-char snippet>... The reference is not the full document content — just a title link with opening snippet. The user can then send it or edit the message before sending. This is the first step toward making documents feel like first-class citizens in agent chat. --- static/js/document.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/static/js/document.js b/static/js/document.js index b245ec85..f9ebee9e 100644 --- a/static/js/document.js +++ b/static/js/document.js @@ -667,6 +667,22 @@ import { bindMenuDismiss, dismissOrRemove } from './escMenuStack.js'; } } + function _sendToChat() { + if (!activeDocId) return; + const doc = docs.get(activeDocId); + if (!doc) return; + const content = typeof doc.content === 'string' ? doc.content : ''; + const snippet = content.substring(0, 120).replace(/\n/g, ' '); + const ref = `[${doc.title || 'Untitled'}](#document-${activeDocId})${snippet ? ' — ' + snippet + (content.length > 120 ? '...' : '') : ''}`; + const msgEl = document.getElementById('message'); + if (!msgEl) return; + const current = msgEl.value.trim(); + msgEl.value = current ? `${current}\n\n${ref}` : ref; + msgEl.focus(); + // Trigger input event so the textarea auto-resizes and any listeners fire + msgEl.dispatchEvent(new Event('input', { bubbles: true })); + } + async function _openExportPdfModal() { if (!activeDocId) return; await _saveActiveDocBeforeExport(); @@ -4596,6 +4612,7 @@ import { bindMenuDismiss, dismissOrRemove } from './escMenuStack.js'; pinned to the bottom no matter which pane (editor / md-preview / csv / html / pdf) is the one growing to fill. -->