@@ -4,7 +4,7 @@ import { ThreadId } from "@t3tools/contracts";
44import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings" ;
55import type * as Context from "effect/Context" ;
66import { expect , it , vi } from "vite-plus/test" ;
7- import { page } from "vite-plus/test/browser" ;
7+ import { page , userEvent } from "vite-plus/test/browser" ;
88
99import { AppRoot } from "~/AppRoot" ;
1010// 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
157157 turnId : a . runs [ 0 ] ! . id ,
158158 } ) ;
159159} ) ;
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+ } ) ;
0 commit comments