fix(web): make terminal context-menu actions reliable #8459
ClosedAdamulek123(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/8459/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -197,3 +197,11 @@197197 activeContextMenuDismiss = null;198198 }199199200+export function contextMenuAcceleratorAction<T extends string>(201+ items: readonly ContextMenuItem<T>[],202+ event: Pick<KeyboardEvent, "altKey" | "ctrlKey" | "isComposing" | "key" | "metaKey" | "shiftKey">,203+): T | null {204+ if (event.isComposing) return null;205+206+ for (const item of items) {207+ if (item.disabled) continue;
- @@ -316,5 +389,6 @@316389 button.type = "button";317390 const isDisabled = item.disabled === true;318391 button.disabled = isDisabled;319- const rowBase =320- "flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-left outline-none transition-colors sm:min-h-7 sm:text-sm min-h-8 text-base";392+ const rowBase = usesCompactLayout393+ ? "flex min-h-8 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-left text-sm outline-none transition-colors sm:min-h-7 sm:text-xs"394+ : "flex min-h-8 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-left text-base outline-none transition-colors sm:min-h-7 sm:text-sm";@@ -279,0 +275,21 @@275+ readonly focusTerminal: () => void;276+}): Promise<void> {277+ const isCurrent = () => options.isCurrentRequest() && !options.signal.aborted;278+ let action: TerminalContextMenuAction | null;279+ try {280+ action = await options.open();281+ } catch (error) {282+ if (isCurrent()) options.reportOpenError(error);283+ return;284+ }285+ if (action === null || !isCurrent()) return;286+ await options.perform(action, isCurrent);287+ if (shouldRestoreTerminalFocusAfterMenuAction(action) && isCurrent()) {288+ options.focusTerminal();289+ }290+}291+292+export function terminalContextMenuItems(293+ availability: { readonly canAddToChat: boolean; readonly canCopy: boolean },294+ platform = typeof navigator === "undefined" ? "" : navigator.platform,295+): ContextMenuItem<TerminalContextMenuAction>[] {
Adamulek123(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
db6111fc-ed9c-4f82-a6de-f4c42d1eaabeYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.