diff --git a/CHANGELOG.md b/CHANGELOG.md index a046ad637..cca73e202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f - **Shell mode matches what Send will do.** Inline text attachments remain prompt attachments even when the draft begins with `!` or `!!`; their contents are never interpreted as shell commands. Rejected sends restore the original text and file attachments separately, so retrying does not turn the prompt into a shell command. During an active run, unattached shell commands say **Run shell command** rather than Queue or Steer. Shell-mode font changes also resize the composer when attachments are added or removed, and the exclusion label explicitly states that output remains saved in the transcript. - **Recovered prompts and attachment-backed drafts preserve their input mode.** Prompts remain model input even when their text starts with `!` or `!!`, including after navigation, session identity moves, rejection, and page reload. Drafts keep this provenance even when memory-only attachment payloads disappear on reload. Clearing the recovered content, including removing its final image from an otherwise empty composer, starts fresh input so a new shell command works normally. Empty recovery results never change newer input. - **History prefills and unfinished uploads keep prompt intent.** History Edit, edit-and-resend Fork, and refused interrupt/reply prefills remain model input when their omitted attachments once prevented shell execution. Existing user drafts keep their own intent. Draft snapshots capture every live attachment before filtering unfinished upload payloads, so uploading or failed file chips cannot turn a prompt into a shell command after navigation or reload. +- **Side questions look different before you send.** Typing `/btw` tints the composer and shows **Send**, even during a run and when the usual submit action is Queue or Steer. Side questions are sent immediately, never queued. - **Finished background tool calls no longer show up as running.** A `bash` or `task` call that omp moved to the background kept reporting progress after it returned, and ompweb counted each report as a running tool. Opening the chat mid-run then listed those long-finished calls as empty running rows below the transcript until the next event, and an open chat could briefly show a finished call as running again. Calls that returned before an ompweb server restart can still show this once. - **Background Sync retains permanent rejection states.** A rejected held message, including one from a changed installation scope, is saved as **Not sent** rather than left as **Sending**. It is not rebound to new credentials, and a late refusal cannot recreate an entry another sender already accepted. - **Pending messages protect newer drafts and delivery intent.** A delayed storage acknowledgement does not clear newer input, even if an edit restores identical text. Same-time submissions keep durable enqueue order; duplicate browser IDs and unrelated successful HTTP responses cannot overwrite or acknowledge a held message. Delete confirmations distinguish removing tracking from cancelling work omp may already have received. diff --git a/components/ChatInput.btw.test.mjs b/components/ChatInput.btw.test.mjs index 130776d1c..b4bf9612b 100644 --- a/components/ChatInput.btw.test.mjs +++ b/components/ChatInput.btw.test.mjs @@ -50,6 +50,28 @@ for (const isStreaming of [false, true]) { }); } +for (const behavior of ["queue", "steer"]) { + test(`/btw offers Send during a run regardless of the ${behavior} preference`, async () => { + localStorage.setItem("omp-web:submit-during-run", behavior); + const user = userEvent.setup(); + const { calls } = renderComposer({ isStreaming: true }); + await user.type(screen.getByRole("textbox"), "/btw what is 2+2"); + await user.click(screen.getByRole("button", { name: "Send", exact: true })); + await waitFor(() => assert.deepEqual(calls, [["onBuiltinCommand", "/btw what is 2+2"]])); + await waitFor(() => assert.equal(screen.getByRole("textbox").value, "")); + }); +} + +test("without builtin dispatch, /btw during a run keeps the Queue button and queues as ordinary text", async () => { + localStorage.setItem("omp-web:submit-during-run", "queue"); + const user = userEvent.setup(); + const { calls } = renderComposer({ isStreaming: true, onBuiltinCommand: undefined }); + await user.type(screen.getByRole("textbox"), "/btw what is 2+2"); + assert.equal(screen.queryByRole("button", { name: "Send", exact: true }), null); + await user.keyboard("{Enter}"); + await waitFor(() => assert.deepEqual(calls, [["onFollowUp", "/btw what is 2+2"]])); +}); + test("/btw with an attachment is refused and keeps the draft and the attachment", async () => { const user = userEvent.setup(); const { calls, ref } = renderComposer({ isStreaming: false }); @@ -64,3 +86,25 @@ test("/btw with an attachment is refused and keeps the draft and the attachment" assert.equal(screen.getByRole("textbox").value, "/btw what is this"); assert.equal(getDraft("btw-draft")?.files.length, 1); }); + +test("slash palette keeps /btw available during a streaming run", async () => { + const user = userEvent.setup(); + renderComposer({ isStreaming: true }); + await user.type(screen.getByRole("textbox"), "/bt"); + await waitFor(() => assert.ok(screen.getByText("/btw"))); +}); + +test("/btw Send button refuses pending uploads immediately with the attachment error", async () => { + const user = userEvent.setup(); + const { calls, ref } = renderComposer({ isStreaming: true }); + // Attach an uploading file (20 MB exceeds inline text limit -> staged upload). + await act(async () => { + ref.current.addFiles([new File([new Uint8Array(6 * 1024 * 1024)], "big.bin", { type: "application/octet-stream" })]); + }); + await user.type(screen.getByRole("textbox"), "/btw what is this"); + const sendBtn = screen.getByRole("button", { name: "Send", exact: true }); + assert.equal(sendBtn.disabled, false); + await user.click(sendBtn); + assert.deepEqual(calls, []); + assert.equal(screen.getByRole("textbox").value, "/btw what is this"); +}); diff --git a/components/ChatInput.tsx b/components/ChatInput.tsx index f35fc65e8..94bc66063 100644 --- a/components/ChatInput.tsx +++ b/components/ChatInput.tsx @@ -479,6 +479,9 @@ export const ChatInput = memo(forwardRef(function ChatIn const bashExcluded = bashMode && trimmedValue.startsWith("!!"); // "!" shares output with the model (riskier, root-style warning); "!!" stays local (plain terminal). const shellMode = bashMode ? (bashExcluded ? "local" : "model") : undefined; + // Side questions stay separate from the main run's queue and Stop action. Without builtin dispatch `/btw` is + // ordinary text, so the composer keeps its Queue fallback. + const btwMode = Boolean(onBuiltinCommand) && /^\/btw(\s|$)/.test(trimmedValue); const [slashMenuOpen, setSlashMenuOpen] = useState(false); const [slashActiveIndex, setSlashActiveIndex] = useState(0); const [slashMatch, setSlashMatch] = useState(null); @@ -1283,9 +1286,10 @@ export const ChatInput = memo(forwardRef(function ChatIn if (!msg && !attachedImagesRef.current.length && !attachedTextFilesRef.current.length && !attachedUploadsRef.current.length) return; // `!cmd` runs right away during a run too, as in omp's terminal; it is never queued as text. const shellCommand = !promptOnlyRef.current && msg.startsWith("!") && !attachedImagesRef.current.length && !attachedTextFilesRef.current.length && !attachedUploadsRef.current.length; - if (submissionBlockedRef.current || holdingRef.current || (isStreaming && !shellCommand)) return; + if (submissionBlockedRef.current || holdingRef.current) return; onAudioUnlock?.(); if (sendSideQuestion(msg, overrideText)) return; + if (isStreaming && !shellCommand) return; if (rejectsPendingUploads()) return; const files = attachedTextFilesRef.current; const composedMessage = composeMessageWithTextAttachments(msg, files); @@ -1370,7 +1374,9 @@ export const ChatInput = memo(forwardRef(function ChatIn toast.success(t("chatInput.dictationSuccess")); return; } - if (after && onFollowUp) { + if (after && sendSideQuestion(finalText.trim(), finalText)) { + return; + } else if (after && onFollowUp) { sendQueued(after === "send" ? "followup" : after, finalText); } else if (after && !isStreaming) { void handleSend(finalText); @@ -1502,7 +1508,8 @@ export const ChatInput = memo(forwardRef(function ChatIn return modelCollator.compare(a.name, b.name); }); } - const commands = [...(isStreaming ? [] : builtinSlashCommands), ...externalSlashCommands]; + // During a run the other builtins would only be queued as text; /btw runs beside the main run. + const commands = [...(isStreaming ? builtinSlashCommands.filter((command) => command.name === "btw") : builtinSlashCommands), ...externalSlashCommands]; return [...commands] .filter((command) => { const name = command.name.toLowerCase(); @@ -1859,7 +1866,7 @@ export const ChatInput = memo(forwardRef(function ChatIn const imageUploads = attachedUploads.filter((upload) => upload.previewUrl !== null); const fileUploads = attachedUploads.filter((upload) => upload.previewUrl === null); const primaryActionQueuesMessage = - isStreaming + isStreaming && !btwMode && (Boolean(value.trim()) || hasAttachments || dictationCapturing) && Boolean(onFollowUp); // The button follows the same Settings choice as Enter: soft keyboards have no @@ -3180,7 +3187,7 @@ export const ChatInput = memo(forwardRef(function ChatIn aria-live="polite" data-shell={shellMode} style={{ - border: "1px solid var(--shell-border, color-mix(in srgb, var(--border) 70%, transparent))", + border: btwMode ? "1px solid var(--accent)" : "1px solid var(--shell-border, color-mix(in srgb, var(--border) 70%, transparent))", borderBottom: "none", borderRadius: queuedCount > 0 ? 0 : "var(--radius-card) var(--radius-card) 0 0", background: "var(--bg-panel)", @@ -3205,8 +3212,8 @@ export const ChatInput = memo(forwardRef(function ChatIn style={{ display: "flex", flexDirection: "column", - background: "var(--shell-bg, var(--bg))", - border: "1px solid var(--shell-border, color-mix(in srgb, var(--border) 70%, transparent))", + background: btwMode ? "color-mix(in srgb, var(--accent) 8%, var(--bg))" : "var(--shell-bg, var(--bg))", + border: btwMode ? "1px solid var(--accent)" : "1px solid var(--shell-border, color-mix(in srgb, var(--border) 70%, transparent))", borderRadius: (queuedCount > 0 || Boolean(statusText)) ? "0 0 var(--radius-card) var(--radius-card)" : "var(--radius-card)", padding: "12px 12px 10px", boxShadow: "var(--shadow-card)", @@ -3960,7 +3967,7 @@ export const ChatInput = memo(forwardRef(function ChatIn :