@@ -57,10 +57,8 @@ import {
5757 useEffectiveComposerModelState ,
5858} from "../../composerDraftStore" ;
5959import {
60- EMPTY_PROMPT_STASH_QUEUE ,
61- MAX_STASH_ENTRIES_PER_QUEUE ,
60+ MAX_STASH_ENTRIES ,
6261 partitionStashAttachments ,
63- promptStashScopeKey ,
6462 usePromptStashStore ,
6563 type PromptStashEntry ,
6664} from "../../promptStashStore" ;
@@ -733,7 +731,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
733731 const clearComposerDraftPromptAndImages = useComposerDraftStore (
734732 ( store ) => store . clearComposerPromptAndImages ,
735733 ) ;
736- const setComposerDraftModelSelection = useComposerDraftStore ( ( store ) => store . setModelSelection ) ;
737734 const syncComposerDraftPersistedAttachments = useComposerDraftStore (
738735 ( store ) => store . syncPersistedAttachments ,
739736 ) ;
@@ -1888,23 +1885,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
18881885 // ------------------------------------------------------------------
18891886 // Prompt stash (⌘S)
18901887 // ------------------------------------------------------------------
1891- const stashScopeInstanceId = noProviderAvailable ? null : selectedInstanceId ;
1892- const stashScope = promptStashScopeKey ( stashScopeInstanceId ) ;
1893- const stashQueue = usePromptStashStore (
1894- ( state ) => state . queuesByScopeKey [ stashScope ] ?? EMPTY_PROMPT_STASH_QUEUE ,
1895- ) ;
1896- const stashOtherScopesCount = usePromptStashStore ( ( state ) =>
1897- Object . entries ( state . queuesByScopeKey ) . reduce (
1898- ( total , [ key , queue ] ) => ( key === stashScope ? total : total + queue . length ) ,
1899- 0 ,
1900- ) ,
1901- ) ;
1888+ // One global queue. Stashed prompts carry only text + images so they can be
1889+ // restored into any thread or provider — stash, switch, restore is the
1890+ // whole point.
1891+ const stashQueue = usePromptStashStore ( ( state ) => state . entries ) ;
19021892 const stashEntryToQueue = usePromptStashStore ( ( state ) => state . stashEntry ) ;
19031893 const takeStashEntry = usePromptStashStore ( ( state ) => state . takeEntry ) ;
19041894 const finalizeStashEntryImages = usePromptStashStore ( ( state ) => state . finalizeEntryImages ) ;
1905- const stashProviderLabel = noProviderAvailable
1906- ? "No provider"
1907- : getProviderDisplayName ( providerStatuses , selectedProvider ) ;
19081895
19091896 useEffect ( ( ) => {
19101897 return ( ) => {
@@ -1930,10 +1917,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
19301917 const restoreStashEntry = useCallback (
19311918 ( entry : PromptStashEntry ) => {
19321919 // Remove first so a double activation (click + Enter) can't restore twice.
1933- const { entry : taken , durable } = takeStashEntry (
1934- promptStashScopeKey ( entry . providerInstanceId ) ,
1935- entry . id ,
1936- ) ;
1920+ const { entry : taken , durable } = takeStashEntry ( entry . id ) ;
19371921 if ( ! taken ) return ;
19381922 if ( ! durable ) {
19391923 toastManager . add ( {
@@ -1996,21 +1980,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
19961980 }
19971981 }
19981982
1999- const restorableSelection =
2000- entry . modelSelection &&
2001- providerInstanceEntries . some (
2002- ( candidate ) =>
2003- candidate . instanceId === entry . modelSelection ?. instanceId &&
2004- candidate . enabled &&
2005- candidate . isAvailable ,
2006- )
2007- ? entry . modelSelection
2008- : null ;
2009- if ( restorableSelection ) {
2010- setComposerDraftModelSelection ( composerDraftTarget , restorableSelection , {
2011- replaceOptions : true ,
2012- } ) ;
2013- }
1983+ // Deliberately no model/provider restore: the stash exists to carry a
1984+ // prompt across threads and providers, so whatever the composer has
1985+ // selected right now stays selected.
20141986
20151987 // Each cause gets its own sentence so "too large" is never blamed for a
20161988 // file that actually failed to decode, or for one the composer simply
@@ -2052,16 +2024,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
20522024 composerDraftTarget ,
20532025 composerImagesRef ,
20542026 promptRef ,
2055- providerInstanceEntries ,
2056- setComposerDraftModelSelection ,
20572027 setComposerDraftPrompt ,
20582028 takeStashEntry ,
20592029 ] ,
20602030 ) ;
20612031
20622032 const deleteStashEntry = useCallback (
20632033 ( entry : PromptStashEntry ) => {
2064- const { durable } = takeStashEntry ( promptStashScopeKey ( entry . providerInstanceId ) , entry . id ) ;
2034+ const { durable } = takeStashEntry ( entry . id ) ;
20652035 if ( ! durable ) {
20662036 toastManager . add ( {
20672037 type : "warning" ,
@@ -2097,7 +2067,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
20972067
20982068 const stashTarget = composerDraftTarget ;
20992069 const entryId = randomUUID ( ) ;
2100- const scopeKey = promptStashScopeKey ( stashScopeInstanceId ) ;
21012070 try {
21022071 // Persist the text-only entry *first*, then clear. Ordering matters in
21032072 // both directions: writing before clearing means a crash or closed tab
@@ -2109,8 +2078,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
21092078 createdAt : new Date ( ) . toISOString ( ) ,
21102079 prompt,
21112080 attachments : [ ] ,
2112- providerInstanceId : stashScopeInstanceId ,
2113- modelSelection : noProviderAvailable ? null : selectedModelSelection ,
21142081 droppedImageNames : [ ] ,
21152082 unreadableImageNames : [ ] ,
21162083 pendingImageCount : images . length ,
@@ -2144,7 +2111,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
21442111 toastManager . add ( {
21452112 type : "warning" ,
21462113 title : "Oldest stashed prompt discarded" ,
2147- description : `The ${ stashProviderLabel } stash holds ${ MAX_STASH_ENTRIES_PER_QUEUE } prompts; the oldest was removed to make room.` ,
2114+ description : `The stash holds ${ MAX_STASH_ENTRIES } prompts; the oldest was removed to make room.` ,
21482115 data : { hideCopyButton : true } ,
21492116 } ) ;
21502117 }
@@ -2176,7 +2143,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
21762143 }
21772144 const { kept, droppedNames } = partitionStashAttachments ( candidateAttachments ) ;
21782145
2179- const { attached, durable : imagesDurable } = finalizeStashEntryImages ( scopeKey , entryId , {
2146+ const { attached, durable : imagesDurable } = finalizeStashEntryImages ( entryId , {
21802147 attachments : kept ,
21812148 droppedImageNames : [ ...oversizedImageNames , ...droppedNames ] ,
21822149 unreadableImageNames,
@@ -2216,13 +2183,9 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
22162183 composerDraftTarget ,
22172184 composerImagesRef ,
22182185 finalizeStashEntryImages ,
2219- noProviderAvailable ,
22202186 promptRef ,
22212187 pulseStashBadge ,
2222- selectedModelSelection ,
22232188 stashEntryToQueue ,
2224- stashProviderLabel ,
2225- stashScopeInstanceId ,
22262189 ] ) ;
22272190
22282191 const toggleStashMenu = useCallback ( ( ) => {
@@ -2832,8 +2795,6 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
28322795 < ComposerCommandMenuLayer anchor = { composerMenuAnchor } >
28332796 < ComposerStashMenu
28342797 entries = { stashQueue }
2835- providerLabel = { stashProviderLabel }
2836- otherScopesCount = { stashOtherScopesCount }
28372798 onRestore = { restoreStashEntry }
28382799 onDelete = { deleteStashEntry }
28392800 onClose = { ( ) => setIsStashMenuOpen ( false ) }
0 commit comments