@devries-cameron20 / t3code-1 / commits / 2b07556d71
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): a stashed prompt ending in a skill or file chip restores as a chip (#28352)

Julius Marminge committed Nov 12, 2026 at 00:02 UTC 2b07556d719a071390984eeb19347af72f71a565
2 files changed +42 -2
apps/web/src/components/ChatView.browser.test.tsx
+35 -1
@@ -4,7 +4,7 @@ import { ThreadId } from "@t3tools/contracts";
4 import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
5 import type * as Context from "effect/Context";
6 import { expect, it, vi } from "vite-plus/test";
7 -import { page } from "vite-plus/test/browser";
7 +import { page, userEvent } from "vite-plus/test/browser";
8
9 import { AppRoot } from "~/AppRoot";
10 // The route loads ChatView lazily, and its first transform (React Compiler over ~4k lines)
@@ -157,3 +157,37 @@ it("retains each thread's diff selection when returning from another thread or S
157 turnId: a.runs[0]!.id,
158 });
159 });
160 +
161 +it("a stashed prompt ending in a file chip restores with the chip", async () => {
162 + using _environment = installFakeEnvironment([]);
163 + __setClientSettingsForTests({
164 + ...DEFAULT_CLIENT_SETTINGS,
165 + onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
166 + });
167 + const draftId = DraftId.make("draft-28338");
168 + const drafts = useComposerDraftStore.getState();
169 + drafts.setProjectDraftThreadId(scopeProjectRef(ENVIRONMENT_ID, PROJECT_ID), draftId, {
170 + threadId: ThreadId.make("thread-28338"),
171 + });
172 + drafts.setPrompt(draftId, "Check [package.json](package.json) ");
173 + const router = getRouter(createMemoryHistory({ initialEntries: [`/draft/${draftId}`] }));
174 + await router.load();
175 + await using _app = await render(<AppRoot router={router} />, {
176 + // AppRoot brings its own router.
177 + router: false,
178 + });
179 + const chip = page.getByRole("button", { name: "Preview package.json" });
180 + await expect.element(chip).toBeVisible();
181 + // The stash shortcut is a no-op until the shell snapshot lists the project.
182 + await expect.element(page.getByText("render", { exact: true }).first()).toBeVisible();
183 +
184 + const editor = page.getByTestId("composer-editor");
185 + await userEvent.click(editor);
186 + await userEvent.keyboard("{ControlOrMeta>}s{/ControlOrMeta}");
187 + await expect.element(chip).not.toBeInTheDocument();
188 + await userEvent.keyboard("{ControlOrMeta>}s{/ControlOrMeta}");
189 +
190 + await vi.waitFor(() => expect(editor.element().textContent).toContain("Check"));
191 + expect(editor.element().textContent).not.toContain("[package.json](package.json)");
192 + await expect.element(chip).toBeVisible();
193 +});
apps/web/src/components/chat/useComposerStash.ts
+7 -1
@@ -28,6 +28,7 @@ import {
28 import { type PendingUserInput } from "../../session-logic";
29 import { type ReviewCommentContext } from "../../reviewCommentContext";
30 import { collapseExpandedComposerCursor } from "../../composer-logic";
31 +import { collectComposerPromptInlineTokens } from "../../composer-editor-mentions";
32 import { compressImageForStash } from "../../lib/imageCompression";
33 import { formatInlineContextReference } from "~/lib/composerContextReferences";
34 import { isCommandPaletteOpen } from "../../commandPaletteBus";
@@ -469,7 +470,12 @@ export function useComposerStash(input: {
470 return;
471 }
472 const replyTo = getComposerDraft(composerDraftTarget)?.replyTo;
472 - const prompt = promptRef.current.trim();
473 + const trimmedPrompt = promptRef.current.trim();
474 + // A trailing chip only parses with whitespace after it, so keep one space to restore it.
475 + const endsWithChip =
476 + collectComposerPromptInlineTokens(promptRef.current).at(-1)?.end ===
477 + promptRef.current.trimEnd().length;
478 + const prompt = endsWithChip ? `${trimmedPrompt} ` : trimmedPrompt;
479 const attachmentDraft = readAttachmentDraft();
480 const images = [...attachmentDraft.images];
481 const files = [...attachmentDraft.files];