Skip to content
TypeScript

fix(web): show the configured stash shortcut (#8437)

Utkarsh Patilac3b2adf96e7
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index e27c265bef1..a3f30d5b681 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -90,7 +90,7 @@ import {
} from "../../lib/attachmentUploadState";
import { isCommandPaletteOpen } from "../../commandPaletteBus";
import { getTerminalFocusOwner } from "../../lib/terminalFocus";
-import { resolveShortcutCommand } from "../../keybindings";
+import { resolveShortcutCommand, shortcutLabelForCommand } from "../../keybindings";
import {
type TerminalContextDraft,
type TerminalContextSelection,
@@ -3201,6 +3201,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
<ComposerCommandMenuLayer anchor={composerMenuAnchor}>
<ComposerStashMenu
entries={stashQueue}
+ stashShortcutLabel={shortcutLabelForCommand(keybindings, "composer.stash", {
+ context: {
+ terminalFocus: false,
+ terminalOpen,
+ modelPickerOpen: false,
+ },
+ })}
onRestore={restoreStashEntry}
onDelete={deleteStashEntry}
onClose={() => setIsStashMenuOpen(false)}
diff --git a/apps/web/src/components/chat/ComposerStashMenu.test.tsx b/apps/web/src/components/chat/ComposerStashMenu.test.tsx
index 7ab8005af2b..fc32cc517cb 100644
--- a/apps/web/src/components/chat/ComposerStashMenu.test.tsx
+++ b/apps/web/src/components/chat/ComposerStashMenu.test.tsx
@@ -8,6 +8,7 @@ describe("ComposerStashMenu", () => {
const markup = renderToStaticMarkup(
<ComposerStashMenu
entries={[]}
+ stashShortcutLabel="Ctrl+S"
onRestore={() => {}}
onDelete={() => {}}
onClose={() => {}}
@@ -20,6 +21,22 @@ describe("ComposerStashMenu", () => {
expect(markup).toContain('aria-label="Close stash"');
expect(markup).not.toContain("dropdown-glass");
expect(markup).not.toContain("Stashed prompts");
+ expect(markup).toContain("Press Ctrl+S with a prompt in the composer to stash it.");
+ });
+
+ it("does not advertise a shortcut when stash is unbound", () => {
+ const markup = renderToStaticMarkup(
+ <ComposerStashMenu
+ entries={[]}
+ stashShortcutLabel={null}
+ onRestore={() => {}}
+ onDelete={() => {}}
+ onClose={() => {}}
+ />,
+ );
+
+ expect(markup).toContain("Nothing stashed yet.");
+ expect(markup).not.toContain("Press");
});
it("shows saved image thumbnails and incomplete image states", () => {
@@ -53,6 +70,7 @@ describe("ComposerStashMenu", () => {
pendingImageCount: 1,
},
]}
+ stashShortcutLabel="Ctrl+S"
onRestore={() => {}}
onDelete={() => {}}
onClose={() => {}}
diff --git a/apps/web/src/components/chat/ComposerStashMenu.tsx b/apps/web/src/components/chat/ComposerStashMenu.tsx
index fc12831025b..9bc29f47457 100644
--- a/apps/web/src/components/chat/ComposerStashMenu.tsx
+++ b/apps/web/src/components/chat/ComposerStashMenu.tsx
@@ -31,11 +31,12 @@ function stashEntrySnippet(entry: PromptStashEntry): string {
*/
export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
entries: ReadonlyArray<PromptStashEntry>;
+ stashShortcutLabel: string | null;
onRestore: (entry: PromptStashEntry) => void;
onDelete: (entry: PromptStashEntry) => void;
onClose: () => void;
}) {
- const { entries, onRestore, onDelete, onClose } = props;
+ const { entries, stashShortcutLabel, onRestore, onDelete, onClose } = props;
const drawerRef = useRef<HTMLDivElement>(null);
const [highlightedId, setHighlightedId] = useState<string | null>(entries[0]?.id ?? null);
@@ -128,7 +129,10 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
<CommandGroup>
{entries.length === 0 ? (
<p className="px-3 py-1.5 text-secondary-label text-xs">
- Nothing stashed yet. Press ⌘S with a prompt in the composer to stash it.
+ Nothing stashed yet.
+ {stashShortcutLabel
+ ? ` Press ${stashShortcutLabel} with a prompt in the composer to stash it.`
+ : null}
</p>
) : (
entries.map((entry) => (