Skip to content

Commit ac3b2ad

Browse files
fix(web): show the configured stash shortcut (pingdotgg#8437)
Co-authored-by: Shivam Sharma <[email protected]>
1 parent e898008 commit ac3b2ad

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import {
9090
} from "../../lib/attachmentUploadState";
9191
import { isCommandPaletteOpen } from "../../commandPaletteBus";
9292
import { getTerminalFocusOwner } from "../../lib/terminalFocus";
93-
import { resolveShortcutCommand } from "../../keybindings";
93+
import { resolveShortcutCommand, shortcutLabelForCommand } from "../../keybindings";
9494
import {
9595
type TerminalContextDraft,
9696
type TerminalContextSelection,
@@ -3201,6 +3201,13 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
32013201
<ComposerCommandMenuLayer anchor={composerMenuAnchor}>
32023202
<ComposerStashMenu
32033203
entries={stashQueue}
3204+
stashShortcutLabel={shortcutLabelForCommand(keybindings, "composer.stash", {
3205+
context: {
3206+
terminalFocus: false,
3207+
terminalOpen,
3208+
modelPickerOpen: false,
3209+
},
3210+
})}
32043211
onRestore={restoreStashEntry}
32053212
onDelete={deleteStashEntry}
32063213
onClose={() => setIsStashMenuOpen(false)}

‎apps/web/src/components/chat/ComposerStashMenu.test.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe("ComposerStashMenu", () => {
88
const markup = renderToStaticMarkup(
99
<ComposerStashMenu
1010
entries={[]}
11+
stashShortcutLabel="Ctrl+S"
1112
onRestore={() => {}}
1213
onDelete={() => {}}
1314
onClose={() => {}}
@@ -20,6 +21,22 @@ describe("ComposerStashMenu", () => {
2021
expect(markup).toContain('aria-label="Close stash"');
2122
expect(markup).not.toContain("dropdown-glass");
2223
expect(markup).not.toContain("Stashed prompts");
24+
expect(markup).toContain("Press Ctrl+S with a prompt in the composer to stash it.");
25+
});
26+
27+
it("does not advertise a shortcut when stash is unbound", () => {
28+
const markup = renderToStaticMarkup(
29+
<ComposerStashMenu
30+
entries={[]}
31+
stashShortcutLabel={null}
32+
onRestore={() => {}}
33+
onDelete={() => {}}
34+
onClose={() => {}}
35+
/>,
36+
);
37+
38+
expect(markup).toContain("Nothing stashed yet.");
39+
expect(markup).not.toContain("Press");
2340
});
2441

2542
it("shows saved image thumbnails and incomplete image states", () => {
@@ -53,6 +70,7 @@ describe("ComposerStashMenu", () => {
5370
pendingImageCount: 1,
5471
},
5572
]}
73+
stashShortcutLabel="Ctrl+S"
5674
onRestore={() => {}}
5775
onDelete={() => {}}
5876
onClose={() => {}}

‎apps/web/src/components/chat/ComposerStashMenu.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ function stashEntrySnippet(entry: PromptStashEntry): string {
3131
*/
3232
export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
3333
entries: ReadonlyArray<PromptStashEntry>;
34+
stashShortcutLabel: string | null;
3435
onRestore: (entry: PromptStashEntry) => void;
3536
onDelete: (entry: PromptStashEntry) => void;
3637
onClose: () => void;
3738
}) {
38-
const { entries, onRestore, onDelete, onClose } = props;
39+
const { entries, stashShortcutLabel, onRestore, onDelete, onClose } = props;
3940
const drawerRef = useRef<HTMLDivElement>(null);
4041
const [highlightedId, setHighlightedId] = useState<string | null>(entries[0]?.id ?? null);
4142

@@ -128,7 +129,10 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
128129
<CommandGroup>
129130
{entries.length === 0 ? (
130131
<p className="px-3 py-1.5 text-secondary-label text-xs">
131-
Nothing stashed yet. Press ⌘S with a prompt in the composer to stash it.
132+
Nothing stashed yet.
133+
{stashShortcutLabel
134+
? ` Press ${stashShortcutLabel} with a prompt in the composer to stash it.`
135+
: null}
132136
</p>
133137
) : (
134138
entries.map((entry) => (

0 commit comments

Comments
 (0)