Skip to content

Commit cd88954

Browse files
authored
fix(chat): distinguish side questions in the composer (#479)
* fix(chat): distinguish side questions in the composer * fix(chat): keep /btw in streaming slash palette and allow immediate send/refusal * docs(chat): say why only /btw stays in the streaming slash palette * fix(chat): keep the Queue fallback for /btw when builtin commands are unavailable
1 parent 8bd0a3a commit cd88954

4 files changed

Lines changed: 66 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
108108
- **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.
109109
- **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.
110110
- **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.
111+
- **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.
111112
- **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.
112113
- **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.
113114
- **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.

‎components/ChatInput.btw.test.mjs‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,28 @@ for (const isStreaming of [false, true]) {
5050
});
5151
}
5252

53+
for (const behavior of ["queue", "steer"]) {
54+
test(`/btw offers Send during a run regardless of the ${behavior} preference`, async () => {
55+
localStorage.setItem("omp-web:submit-during-run", behavior);
56+
const user = userEvent.setup();
57+
const { calls } = renderComposer({ isStreaming: true });
58+
await user.type(screen.getByRole("textbox"), "/btw what is 2+2");
59+
await user.click(screen.getByRole("button", { name: "Send", exact: true }));
60+
await waitFor(() => assert.deepEqual(calls, [["onBuiltinCommand", "/btw what is 2+2"]]));
61+
await waitFor(() => assert.equal(screen.getByRole("textbox").value, ""));
62+
});
63+
}
64+
65+
test("without builtin dispatch, /btw during a run keeps the Queue button and queues as ordinary text", async () => {
66+
localStorage.setItem("omp-web:submit-during-run", "queue");
67+
const user = userEvent.setup();
68+
const { calls } = renderComposer({ isStreaming: true, onBuiltinCommand: undefined });
69+
await user.type(screen.getByRole("textbox"), "/btw what is 2+2");
70+
assert.equal(screen.queryByRole("button", { name: "Send", exact: true }), null);
71+
await user.keyboard("{Enter}");
72+
await waitFor(() => assert.deepEqual(calls, [["onFollowUp", "/btw what is 2+2"]]));
73+
});
74+
5375
test("/btw with an attachment is refused and keeps the draft and the attachment", async () => {
5476
const user = userEvent.setup();
5577
const { calls, ref } = renderComposer({ isStreaming: false });
@@ -64,3 +86,25 @@ test("/btw with an attachment is refused and keeps the draft and the attachment"
6486
assert.equal(screen.getByRole("textbox").value, "/btw what is this");
6587
assert.equal(getDraft("btw-draft")?.files.length, 1);
6688
});
89+
90+
test("slash palette keeps /btw available during a streaming run", async () => {
91+
const user = userEvent.setup();
92+
renderComposer({ isStreaming: true });
93+
await user.type(screen.getByRole("textbox"), "/bt");
94+
await waitFor(() => assert.ok(screen.getByText("/btw")));
95+
});
96+
97+
test("/btw Send button refuses pending uploads immediately with the attachment error", async () => {
98+
const user = userEvent.setup();
99+
const { calls, ref } = renderComposer({ isStreaming: true });
100+
// Attach an uploading file (20 MB exceeds inline text limit -> staged upload).
101+
await act(async () => {
102+
ref.current.addFiles([new File([new Uint8Array(6 * 1024 * 1024)], "big.bin", { type: "application/octet-stream" })]);
103+
});
104+
await user.type(screen.getByRole("textbox"), "/btw what is this");
105+
const sendBtn = screen.getByRole("button", { name: "Send", exact: true });
106+
assert.equal(sendBtn.disabled, false);
107+
await user.click(sendBtn);
108+
assert.deepEqual(calls, []);
109+
assert.equal(screen.getByRole("textbox").value, "/btw what is this");
110+
});

‎components/ChatInput.tsx‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ export const ChatInput = memo(forwardRef<ChatInputHandle, Props>(function ChatIn
479479
const bashExcluded = bashMode && trimmedValue.startsWith("!!");
480480
// "!" shares output with the model (riskier, root-style warning); "!!" stays local (plain terminal).
481481
const shellMode = bashMode ? (bashExcluded ? "local" : "model") : undefined;
482+
// Side questions stay separate from the main run's queue and Stop action. Without builtin dispatch `/btw` is
483+
// ordinary text, so the composer keeps its Queue fallback.
484+
const btwMode = Boolean(onBuiltinCommand) && /^\/btw(\s|$)/.test(trimmedValue);
482485
const [slashMenuOpen, setSlashMenuOpen] = useState(false);
483486
const [slashActiveIndex, setSlashActiveIndex] = useState(0);
484487
const [slashMatch, setSlashMatch] = useState<SlashQueryMatch | null>(null);
@@ -1283,9 +1286,10 @@ export const ChatInput = memo(forwardRef<ChatInputHandle, Props>(function ChatIn
12831286
if (!msg && !attachedImagesRef.current.length && !attachedTextFilesRef.current.length && !attachedUploadsRef.current.length) return;
12841287
// `!cmd` runs right away during a run too, as in omp's terminal; it is never queued as text.
12851288
const shellCommand = !promptOnlyRef.current && msg.startsWith("!") && !attachedImagesRef.current.length && !attachedTextFilesRef.current.length && !attachedUploadsRef.current.length;
1286-
if (submissionBlockedRef.current || holdingRef.current || (isStreaming && !shellCommand)) return;
1289+
if (submissionBlockedRef.current || holdingRef.current) return;
12871290
onAudioUnlock?.(