feat(webui): complete bang commands and literal output (NAN-291) (#6173)

* feat(webui): complete direct bang shell commands

Reuse the gateway user-shell side channel, retain failed drafts without reconnect replay, and preserve literal output across live delivery and history. Highlight the bang prefix before and after sending.

NAN-291

* fix(clients): preserve literal shell output through display metadata
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-26 23:35:26 +08:00
1 parent f23a6d1485
commit 7e5dcb79e0
43 files changed
+805 -100

No files matched your search

@@ -1,5 +1,6 @@
import {
act,
createEvent,
fireEvent,
render,
screen,
@@ -443,6 +444,31 @@ describe("local attachment paths and video ingress", () => {
const local = { path: "C:\\project\\my clip.mp4", name: "my clip.mp4", size: 12,
mime: "video/mp4", kind: "video" as const, url: "/api/media/sig/local" };
it("leaves a path pasted into a bang command as Shell text", () => {
const inspect = vi.fn().mockResolvedValue(local);
render(<ThreadComposer onSend={vi.fn()} onInspectAttachment={inspect} />);
const input = screen.getByLabelText(/message input/i) as HTMLTextAreaElement;
fireEvent.change(input, { target: { value: "!cat " } });
input.setSelectionRange(5, 5);
const event = createEvent.paste(input, { clipboardData: { items: [], getData: () => local.path } });
fireEvent(input, event);
expect(event.defaultPrevented).toBe(false);
expect(inspect).not.toHaveBeenCalled();
});
it("keeps a pending path literal when its draft becomes a bang command", async () => {
let complete!: (attachment: typeof local) => void;
const onSend = vi.fn();
render(<ThreadComposer onSend={onSend} onInspectAttachment={() => new Promise((resolve) => { complete = resolve; })} />);
const input = screen.getByLabelText(/message input/i);
fireEvent.paste(input, { clipboardData: { items: [], getData: () => local.path } });
fireEvent.change(input, { target: { value: `!${local.path}` } });
await act(async () => complete(local));
expect(input).toHaveValue(`!${local.path}`);
fireEvent.keyDown(input, { key: "Enter" });
expect(onSend).toHaveBeenCalledWith(`!${local.path}`, undefined, { sideChannel: true, userShell: true });
});
it("confirms a large pasted video path and sends only the borrowed reference", async () => {
const inspect = vi.fn().mockResolvedValue({ ...local, size: 64 * 1024 * 1024 + 1 });
const onSend = vi.fn();