Skip to content
TypeScript

fix(web): toggle a single stashed prompt with Cmd+S (#9644)

Theo Browne14bf3f6d1644
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index 0b034d44338..946d150bb0a 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -3336,7 +3336,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
const images = [...composerImagesRef.current];
const files = [...composerFilesRef.current];
if (prompt.length === 0 && images.length === 0 && files.length === 0) {
- setIsStashMenuOpen((open) => !open);
+ const entries = usePromptStashStore.getState().entries;
+ const entry = entries.length === 1 ? entries[0] : undefined;
+ if (entry && !entry.pendingImageCount) {
+ await restoreStashEntry(entry);
+ } else {
+ setIsStashMenuOpen((open) => !open);
+ }
return;
}
const stashedFiles: PersistedComposerFileAttachment[] = [];
@@ -3523,6 +3529,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
finalizeStashEntryImages,
promptRef,
pulseStashBadge,
+ restoreStashEntry,
stashEntryToQueue,
]);
diff --git a/apps/web/src/components/chat/ComposerStashMenu.tsx b/apps/web/src/components/chat/ComposerStashMenu.tsx
index 69032764c1f..4942b21dd60 100644
--- a/apps/web/src/components/chat/ComposerStashMenu.tsx
+++ b/apps/web/src/components/chat/ComposerStashMenu.tsx
@@ -30,10 +30,10 @@ function stashEntrySnippet(entry: PromptStashEntry): string {
}
/**
- * Attached banner listing the stashed prompts. Keyboard-first: opened by ⌘S on an
- * empty composer, navigated with arrows, restored with Enter, dismissed
- * with Escape. The listener runs capture-phase on window so it wins over
- * the Lexical editor's handlers while the menu is open.
+ * Attached banner listing the stashed prompts. Opened by the stash badge or ⌘S
+ * when the empty composer cannot restore a single entry. Navigated with arrows,
+ * restored with Enter, dismissed with Escape. The listener runs capture-phase
+ * on window so it wins over the Lexical editor's handlers while the menu is open.
*/
export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
entries: ReadonlyArray<PromptStashEntry>;
diff --git a/docs/user/composer.md b/docs/user/composer.md
index fce133cd27d..2e98a21f719 100644
--- a/docs/user/composer.md
+++ b/docs/user/composer.md
@@ -182,8 +182,10 @@ open the stack. Interacting with the attached banner or composer does not open t
## Prompt stash
Use the default shortcut, `Cmd+S` on macOS or `Ctrl+S` on Windows and Linux, to stash the current
-prompt and its attachments after all file uploads finish. Restore the entry later from the stash
-menu. Stashes that contain files must be restored in the environment where those files were
+prompt and its attachments after all file uploads finish. When the composer is empty and the stash
+has one entry, press the shortcut again to restore it. The shortcut opens the stash menu if there
+are multiple entries or the entry's images are still saving. You can also open the menu from the
+stash badge. Stashes that contain files must be restored in the environment where those files were
uploaded. Stashed files stay uploaded on the server for 24 hours. If you restore an entry after
that, the file comes back with **Attach again** next to it. Attach the file again or remove it, then
send.