Skip to content

Commit c3ca81c

Browse files
refactor(ui): inline forwarding scroll wrappers in composer menus
scrollActiveSkillMenuOptionIntoView and scrollActiveSlashMenuOptionIntoView only forwarded their state/paneId args to getActive*MenuOptionId and the shared scrollActiveMenuOptionIntoView helper. Delete both wrappers and have the chat-composer.ts keydown call sites resolve the active option id and call the shared geometry helper directly, since both id resolvers were already exported and consumed elsewhere.
1 parent 0e46e27 commit c3ca81c

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

‎ui/src/pages/chat/components/chat-composer-skill-menu.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getSlashCommandDescription,
88
type SlashCommandDef,
99
} from "../../../lib/chat/commands.ts";
10-
import { scrollActiveMenuOptionIntoView } from "./chat-composer-dom.ts";
1110
import { paneDomId } from "./chat-composer-slash-menu.ts";
1211
import { commitComposerDraft, getChatComposerState } from "./chat-composer-state.ts";
1312
import type { ChatComposerProps, ChatComposerState } from "./chat-composer-types.ts";
@@ -180,13 +179,6 @@ export function getActiveSkillMenuOptionLabel(state: ChatComposerState): string
180179
return command ? `${getSkillDisplayName(command)} ${getSlashCommandDescription(command)}` : "";
181180
}
182181

183-
export function scrollActiveSkillMenuOptionIntoView(
184-
state: ChatComposerState,
185-
paneId: string,
186-
): void {
187-
scrollActiveMenuOptionIntoView(getActiveSkillMenuOptionId(state, paneId));
188-
}
189-
190182
export function selectSkillMention(
191183
command: SlashCommandDef,
192184
props: ChatComposerProps,

‎ui/src/pages/chat/components/chat-composer-slash-menu.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
type SlashCommandDef,
1111
} from "../../../lib/chat/commands.ts";
1212
import { exportChatMarkdown } from "../export.ts";
13-
import { scrollActiveMenuOptionIntoView } from "./chat-composer-dom.ts";
1413
import { commitComposerDraft, getChatComposerState } from "./chat-composer-state.ts";
1514
import type { ChatComposerProps, ChatComposerState } from "./chat-composer-types.ts";
1615

@@ -260,13 +259,6 @@ export function getActiveSlashMenuOptionLabel(state: ChatComposerState): string
260259
return `${command} ${getSlashCommandDescription(cmd)}`;
261260
}
262261

263-
export function scrollActiveSlashMenuOptionIntoView(
264-
state: ChatComposerState,
265-
paneId: string,
266-
): void {
267-
scrollActiveMenuOptionIntoView(getActiveSlashMenuOptionId(state, paneId));
268-
}
269-
270262
function renderSlashIcon(name: string) {
271263
return icons[name as IconName] ?? icons.terminal;
272264
}

‎ui/src/pages/chat/components/chat-composer.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import {
1717
replaceComposerPopoverAnchor,
1818
restoreHistoryCaret,
1919
scheduleTextareaHeightAdjustment,
20+
scrollActiveMenuOptionIntoView,
2021
} from "./chat-composer-dom.ts";
2122
import {
2223
getActiveSkillMenuOptionId,
2324
getActiveSkillMenuOptionLabel,
2425
isSkillMenuVisible,
2526
resetSkillMenuState,
26-
scrollActiveSkillMenuOptionIntoView,
2727
selectSkillMention,
2828
updateSkillMenu,
2929
} from "./chat-composer-skill-menu.ts";
@@ -34,7 +34,6 @@ import {
3434
isSlashMenuVisible,
3535
paneDomId,
3636
resetSlashMenuState,
37-
scrollActiveSlashMenuOptionIntoView,
3837
selectSlashArg,
3938
selectSlashCommand,
4039
tabCompleteSlashCommand,
@@ -322,7 +321,8 @@ export function renderChatComposer(props: ChatComposerProps) {
322321
props.paneId,
323322
requestUpdate,
324323
(command) => selectSkillMention(command, props, requestUpdate),
325-
scrollActiveSkillMenuOptionIntoView,
324+
(menuState, paneId) =>
325+
scrollActiveMenuOptionIntoView(getActiveSkillMenuOptionId(menuState, paneId)),
326326
"skill",
327327
)
328328
) {
@@ -344,7 +344,8 @@ export function renderChatComposer(props: ChatComposerProps) {
344344
props.paneId,
345345
requestUpdate,
346346
(arg, submit) => selectSlashArg(arg, props, requestUpdate, submit),
347-
scrollActiveSlashMenuOptionIntoView,
347+
(menuState, paneId) =>
348+
scrollActiveMenuOptionIntoView(getActiveSlashMenuOptionId(menuState, paneId)),
348349
)
349350
) {
350351
return;
@@ -363,7 +364,8 @@ export function renderChatComposer(props: ChatComposerProps) {
363364
submit
364365
? selectSlashCommand(command, props, requestUpdate)
365366
: tabCompleteSlashCommand(command, props, requestUpdate),
366-
scrollActiveSlashMenuOptionIntoView,
367+
(menuState, paneId) =>
368+
scrollActiveMenuOptionIntoView(getActiveSlashMenuOptionId(menuState, paneId)),
367369
)
368370
) {
369371
return;

0 commit comments

Comments
 (0)