Skip to content

Commit 1354217

Browse files
whatasodaclaude
andauthored
feat: improve command display in options page (#35)
## Summary - Fix command display order: `_execute_action` → `open-popup` → `move-tab-left` → `move-tab-right` - Use i18n (`t()`) for command descriptions instead of Chrome API values - Reorganize layout: Mode selection now appears to the right of command name ## Test plan - [ ] Open options page and verify command order is correct - [ ] Verify `_execute_action` description displays properly - [ ] Verify Mode selection appears to the right of command name for popup commands - [ ] Verify "Select on re-press" appears below the key settings 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 561402d commit 1354217

1 file changed

Lines changed: 54 additions & 35 deletions

File tree

src/options/components/ShortcutsSection.tsx

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@ import { css } from "../../../styled-system/css";
33
import type { CommandName, Settings } from "../../core/settings/settings-types";
44
import { getCommands, openShortcutsPage } from "../../infrastructure/chrome/messaging";
55
import { t } from "../../shared/i18n/index.ts";
6-
import { MSG } from "../../shared/i18n/message-keys.ts";
6+
import { type MessageKey, MSG } from "../../shared/i18n/message-keys.ts";
77
import { Button, Checkbox, RadioGroup, Section } from "../../shared/ui";
88

9+
/**
10+
* Fixed display order for commands in the options page.
11+
*/
12+
const COMMAND_ORDER = ["_execute_action", "open-popup", "move-tab-left", "move-tab-right"];
13+
14+
/**
15+
* Mapping from command names to i18n message keys for descriptions.
16+
*/
17+
const COMMAND_DESCRIPTION_KEYS: Record<string, MessageKey> = {
18+
_execute_action: MSG.MANIFEST_COMMAND_EXECUTE_ACTION,
19+
"open-popup": MSG.MANIFEST_COMMAND_OPEN_POPUP,
20+
"move-tab-left": MSG.MANIFEST_COMMAND_MOVE_TAB_LEFT,
21+
"move-tab-right": MSG.MANIFEST_COMMAND_MOVE_TAB_RIGHT,
22+
};
23+
924
const styles = {
1025
shortcutList: css({
1126
display: "flex",
@@ -26,6 +41,12 @@ const styles = {
2641
display: "flex",
2742
justifyContent: "space-between",
2843
alignItems: "center",
44+
gap: "md",
45+
}),
46+
shortcutHeaderLeft: css({
47+
display: "flex",
48+
alignItems: "center",
49+
gap: "md",
2950
}),
3051
shortcutName: css({
3152
fontSize: "lg",
@@ -40,16 +61,8 @@ const styles = {
4061
textAlign: "center",
4162
}),
4263
shortcutSettings: css({
43-
display: "flex",
44-
flexDirection: "column",
45-
gap: "sm",
4664
paddingLeft: "sm",
4765
}),
48-
settingRow: css({
49-
display: "flex",
50-
alignItems: "center",
51-
gap: "md",
52-
}),
5366
note: css({
5467
fontSize: "12px",
5568
color: "text.secondary",
@@ -73,6 +86,11 @@ interface ShortcutsSectionProps {
7386
export function ShortcutsSection(props: ShortcutsSectionProps) {
7487
const [shortcuts] = createResource(getCommands);
7588

89+
const sortedShortcuts = () => {
90+
const list = shortcuts() ?? [];
91+
return [...list].sort((a, b) => COMMAND_ORDER.indexOf(a.name) - COMMAND_ORDER.indexOf(b.name));
92+
};
93+
7694
const modeOptions = [
7795
{ value: "all", label: t(MSG.OPTIONS_MODE_ALL) },
7896
{ value: "currentWindow", label: t(MSG.OPTIONS_MODE_CURRENT) },
@@ -81,34 +99,15 @@ export function ShortcutsSection(props: ShortcutsSectionProps) {
8199
return (
82100
<Section title={t(MSG.OPTIONS_GLOBAL_SHORTCUTS)}>
83101
<div class={styles.shortcutList}>
84-
<For each={shortcuts()}>
102+
<For each={sortedShortcuts()}>
85103
{(shortcut) => (
86104
<div class={styles.shortcutItem}>
87105
<div class={styles.shortcutHeader}>
88-
<span class={styles.shortcutName}>{shortcut.description}</span>
89-
<span class={styles.shortcutKey}>{shortcut.shortcut}</span>
90-
</div>
91-
<Show when={isPopupCommand(shortcut.name ?? "")}>
92-
<div class={styles.shortcutSettings}>
93-
<div class={styles.settingRow}>
94-
<Checkbox
95-
checked={
96-
props.settings.commandSettings[shortcut.name as CommandName]
97-
?.selectOnClose ?? true
98-
}
99-
onChange={(checked) =>
100-
props.onUpdateCommandSetting(
101-
shortcut.name as CommandName,
102-
"selectOnClose",
103-
checked,
104-
)
105-
}
106-
>
107-
{t(MSG.OPTIONS_SELECT_ON_REPRESS)}
108-
</Checkbox>
109-
</div>
110-
<div class={styles.settingRow}>
111-
<span>{t(MSG.OPTIONS_POPUP_MODE)}:</span>
106+
<div class={styles.shortcutHeaderLeft}>
107+
<span class={styles.shortcutName}>
108+
{t(COMMAND_DESCRIPTION_KEYS[shortcut.name] ?? shortcut.name)}
109+
</span>
110+
<Show when={isPopupCommand(shortcut.name ?? "")}>
112111
<RadioGroup
113112
name={`mode-${shortcut.name}`}
114113
options={modeOptions}
@@ -123,7 +122,27 @@ export function ShortcutsSection(props: ShortcutsSectionProps) {
123122
)
124123
}
125124
/>
126-
</div>
125+
</Show>
126+
</div>
127+
<span class={styles.shortcutKey}>{shortcut.shortcut}</span>
128+
</div>
129+
<Show when={isPopupCommand(shortcut.name ?? "")}>
130+
<div class={styles.shortcutSettings}>
131+
<Checkbox
132+
checked={
133+
props.settings.commandSettings[shortcut.name as CommandName]?.selectOnClose ??
134+
true
135+
}
136+
onChange={(checked) =>
137+
props.onUpdateCommandSetting(
138+
shortcut.name as CommandName,
139+
"selectOnClose",
140+
checked,
141+
)
142+
}
143+
>
144+
{t(MSG.OPTIONS_SELECT_ON_REPRESS)}
145+
</Checkbox>
127146
</div>
128147
</Show>
129148
</div>

0 commit comments

Comments
 (0)