Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(shortcuts): issue verbs S/A/P/L/⇧D/⇧P/Q/R on the issue in front of you (MUL-10203) (#11563)
Jiayuan Zhangf9b3b4b18e52
diff --git a/e2e/guest.spec.ts b/e2e/guest.spec.tsindex 036b89aff8..e72e701dea 100644--- a/e2e/guest.spec.ts+++ b/e2e/guest.spec.ts@@ -326,6 +326,23 @@ test.describe("as a guest", () => {await expectClean(seen);});+ test("an issue's field shortcuts do nothing for a guest, while R still focuses the composer", async ({ page }) => {+ const issue = fixture.issues.review;+ const seen = await openAsGuest(page, `/${slug}/issues/${issue.identifier}`);+ await expect(page.getByText(issue.title).first()).toBeVisible({ timeout: 30_000 });+ await expectClean(seen);++ for (const key of ["s", "a", "p", "l", "q", "Shift+D", "Shift+P"]) {+ await page.keyboard.press(key);+ await expect(page.getByRole("dialog")).toHaveCount(0);+ }+ await expectClean(seen);++ await page.keyboard.press("r");+ await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(1);+ await expectClean(seen);+ });+test("a project that is not shared is not found", async ({ page }) => {const { id } = fixture.projects.internal;const seen = await openAsGuest(page, `/${slug}/projects/${id}`, { notFound: [id] });diff --git a/packages/core/command-bar/search-store.ts b/packages/core/command-bar/search-store.tsindex 341fe01d7a..e55c21ec46 100644--- a/packages/core/command-bar/search-store.ts+++ b/packages/core/command-bar/search-store.ts@@ -4,12 +4,22 @@ import { create } from "zustand";interface SearchStore {open: boolean;+ /**+ * The page to open on, for a shortcut that goes straight to one of the+ * palette's pages. Opaque here: the palette owns its page types.+ */+ launchPage: unknown;setOpen: (open: boolean) => void;toggle: () => void;+ openOnPage: (page: unknown) => void;+ clearLaunchPage: () => void;}export const useSearchStore = create<SearchStore>((set) => ({open: false,+ launchPage: null,setOpen: (open) => set({ open }),toggle: () => set((s) => ({ open: !s.open })),+ openOnPage: (page) => set({ open: true, launchPage: page }),+ clearLaunchPage: () => set({ launchPage: null }),}));diff --git a/packages/core/shortcuts/definitions.ts b/packages/core/shortcuts/definitions.tsindex 4a4a6e6424..cf6f298fad 100644--- a/packages/core/shortcuts/definitions.ts+++ b/packages/core/shortcuts/definitions.ts@@ -20,6 +20,14 @@ export type ShortcutActionId =| "nextInboxItem"| "prevInboxItem"| "undoInboxAction"+ | "setIssueStatus"+ | "assignIssue"+ | "setIssuePriority"+ | "setIssueLabels"+ | "setIssueDueDate"+ | "moveIssueToProject"+ | "runIssueQuickAction"+ | "replyToIssue"| "send"| "voiceInput"| "goBack"@@ -37,7 +45,7 @@ export type ShortcutActionId =| "goSkills"| "goSettings";-export type ShortcutCategory = "general" | "navigation";+export type ShortcutCategory = "general" | "issue" | "navigation";export interface ShortcutModifiers {/** Command on macOS, Control on Windows/Linux. */@@ -153,6 +161,27 @@ export const SHORTCUT_ACTIONS: readonly ShortcutActionDefinition[] = [defaultShortcut: createShortcutChord("Z"),allowInEditable: false,},+ // Issue verbs act on the issue in front of the user: a peek, a list+ // selection, or the open issue (Inbox detail or issue page). The letters+ // follow Linear, including ⇧P for project (P is priority) and ⇧D for due date.+ { id: "setIssueStatus", category: "issue", defaultShortcut: createShortcutChord("S"), allowInEditable: false },+ { id: "assignIssue", category: "issue", defaultShortcut: createShortcutChord("A"), allowInEditable: false },+ { id: "setIssuePriority", category: "issue", defaultShortcut: createShortcutChord("P"), allowInEditable: false },+ { id: "setIssueLabels", category: "issue", defaultShortcut: createShortcutChord("L"), allowInEditable: false },+ {+ id: "setIssueDueDate",+ category: "issue",+ defaultShortcut: createShortcutChord("D", { shift: true }),+ allowInEditable: false,+ },+ {+ id: "moveIssueToProject",+ category: "issue",+ defaultShortcut: createShortcutChord("P", { shift: true }),+ allowInEditable: false,+ },+ { id: "runIssueQuickAction", category: "issue", defaultShortcut: createShortcutChord("Q"), allowInEditable: false },+ { id: "replyToIssue", category: "issue", defaultShortcut: createShortcutChord("R"), allowInEditable: false },{ id: "send", category: "general", defaultShortcut: primary("Enter"), allowInEditable: true },// Voice input works where the caret is, so it must fire inside editors. It// is matched on keydown AND keyup (holding it is push-to-talk), so the voicediff --git a/packages/views/common/page-shortcut.ts b/packages/views/common/page-shortcut.tsnew file mode 100644index 0000000000..441971db6d--- /dev/null+++ b/packages/views/common/page-shortcut.ts@@ -0,0 +1,15 @@+import { useModalStore } from "@multica/core/modals";+import { isEditableShortcutTarget, isPortalLayerShortcutTarget } from "@multica/core/shortcuts";+import { isImeComposing } from "@multica/core/utils";++/**+ * Whether a keydown is free for a single-key page shortcut: not handled+ * already, not a held key or an IME composition, not typed into a field, and+ * no menu, dialog or modal on top.+ */+export function isPageShortcutEvent(event: KeyboardEvent): boolean {+ if (event.defaultPrevented || event.repeat || isImeComposing(event)) return false;+ if (isEditableShortcutTarget(event.target)) return false;+ if (isPortalLayerShortcutTarget(event.target)) return false;+ return !useModalStore.getState().modal;+}diff --git a/packages/views/inbox/components/inbox-shortcut.ts b/packages/views/inbox/components/inbox-shortcut.tsindex 9ee0059e75..99f0ee767d 100644--- a/packages/views/inbox/components/inbox-shortcut.ts+++ b/packages/views/inbox/components/inbox-shortcut.ts@@ -1,23 +1,13 @@-import { useModalStore } from "@multica/core/modals";-import {- getShortcut,- isEditableShortcutTarget,- isPortalLayerShortcutTarget,- shortcutMatchesEvent,- type ShortcutActionId,-} from "@multica/core/shortcuts";-import { isImeComposing } from "@multica/core/utils";+import { getShortcut, shortcutMatchesEvent, type ShortcutActionId } from "@multica/core/shortcuts";+import { isPageShortcutEvent } from "../../common/page-shortcut";/*** Whether a keydown is `action`'s single-key Inbox shortcut and the Inbox's to- * take: not handled already, not a held key or an IME composition, not typed- * into a field, and no menu, dialog or modal on top.+ * take: free for a page shortcut (`isPageShortcutEvent`) and not under a+ * floating Issue Peek.*/export function isInboxShortcut(event: KeyboardEvent, action: ShortcutActionId): boolean {- if (event.defaultPrevented || event.repeat || isImeComposing(event)) return false;- if (isEditableShortcutTarget(event.target)) return false;- if (isPortalLayerShortcutTarget(event.target)) return false;- if (useModalStore.getState().modal) return false;+ if (!isPageShortcutEvent(event)) return false;// A floating Issue Peek owns J / K and hides the Inbox detail behind it.if (typeof document !== "undefined" && document.querySelector("[data-issue-peek]")) return false;return shortcutMatchesEvent(getShortcut(action), event);diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsxindex 7d9e8098d4..7660be5328 100644--- a/packages/views/issues/actions/issue-actions-menu-items.tsx+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx@@ -610,7 +610,7 @@ function QuickActionsSub({ issueId, primitives: P }: { issueId: string; primitiv</P.SubTrigger><P.SubContent className="max-w-80">{quickActions.map((action) => (- <P.Item key={action.id} onClick={() => run(action)}>+ <P.Item key={action.id} onClick={() => void run(action)}><Zap className="h-3.5 w-3.5" /><span className="min-w-0 flex-1 truncate">{action.name}</span>{action.target_name && (diff --git a/packages/views/issues/components/comment-input.tsx b/packages/views/issues/components/comment-input.tsxindex bb9623c651..4ac00b2f3a 100644--- a/packages/views/issues/components/comment-input.tsx+++ b/packages/views/issues/components/comment-input.tsx@@ -37,6 +37,7 @@ import { useStopRunsBeforeSend } from "./use-stop-runs-before-send";import { useCommentUploads } from "./use-comment-uploads";import { useQuickActionMenu } from "../hooks/use-quick-action-menu";import { useStickyComposer } from "../hooks/use-sticky-composer";+import { registerComposerFocus } from "./composer-focus";interface CommentInputProps {issueId: string;@@ -116,6 +117,9 @@ function CommentInput({ issueId, onSubmit, onAccepted, onEditAnnotation, annotatuseCommentDraftStore.getState().getUploads(draftKey).length > 0,editorRef,});+ const activateRef = useRef(lazy.activate);+ activateRef.current = lazy.activate;+ useEffect(() => registerComposerFocus(issueId, () => activateRef.current()), [issueId]);// Inactive shells must not mount query observers or duplicate cold reads.const quickActionMenu = useQuickActionMenu(issueId, { enabled: lazy.active, triggerPreview, previewContent });const { isDragOver, dropZoneProps } = useFileDropZone({diff --git a/packages/views/issues/components/composer-focus.ts b/packages/views/issues/components/composer-focus.tsnew file mode 100644index 0000000000..93c49f7591--- /dev/null+++ b/packages/views/issues/components/composer-focus.ts@@ -0,0 +1,21 @@+/**+ * The mounted comment composers, by issue, so a shortcut can reach the one+ * for the issue in front of the user. The newest mount answers: a peek's+ * composer over the page's, for the same issue.+ */+const composers = new Map<string, (() => void)[]>();++export function registerComposerFocus(issueId: string, focus: () => void): () => void {+ const list = composers.get(issueId) ?? [];+ composers.set(issueId, [...list, focus]);+ return () => {+ const remaining = (composers.get(issueId) ?? []).filter((entry) => entry !== focus);+ if (remaining.length > 0) composers.set(issueId, remaining);+ else composers.delete(issueId);+ };+}++/** Focuses `issueId`'s comment composer, or null when none is mounted. */+export function composerFocusFor(issueId: string): (() => void) | null {+ return composers.get(issueId)?.at(-1) ?? null;+}diff --git a/packages/views/issues/components/inbox-issue-actions.tsx b/packages/views/issues/components/inbox-issue-actions.tsxindex 402fde7c32..0358d19a92 100644--- a/packages/views/issues/components/inbox-issue-actions.tsx+++ b/packages/views/issues/components/inbox-issue-actions.tsx@@ -9,6 +9,7 @@ import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import { useActorName } from "@multica/core/workspace/hooks";import type { Issue, QuickAction, UpdateIssueRequest } from "@multica/core/types";import { ActorAvatar } from "../../common/actor-avatar";+import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";import { useT } from "../../i18n";import { useStatusLabel } from "../utils/status-label";import { AssigneePicker } from "./pickers/assignee-picker";@@ -64,7 +65,12 @@ export function IssueBarActions({isDuplicate={isDuplicate}align="start"side={side}- tooltip={t(($) => $.detail.prop_status)}+ tooltip={+ <>+ {t(($) => $.detail.prop_status)}+ <ActionShortcutKeycaps action="setIssueStatus" />+ </>+ }triggerRender={chip}trigger={<>@@ -85,7 +91,12 @@ export function IssueBarActions({onUpdate={onUpdate}align="start"side={side}- tooltip={t(($) => $.detail.prop_assignee)}+ tooltip={+ <>+ {t(($) => $.detail.prop_assignee)}+ <ActionShortcutKeycaps action="assignIssue" />+ </>+ }triggerRender={chip}trigger={assigned ? (diff --git a/packages/views/issues/components/quick-actions-section.tsx b/packages/views/issues/components/quick-actions-section.tsxindex e1ef4f8a1c..00a5b6bf1d 100644--- a/packages/views/issues/components/quick-actions-section.tsx+++ b/packages/views/issues/components/quick-actions-section.tsx@@ -29,6 +29,7 @@ import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { Tooltip, TooltipContent, TooltipTrigger } from "@multica/ui/components/ui/tooltip";import { cn } from "@multica/ui/lib/utils";import { ActorAvatar } from "../../common/actor-avatar";+import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";import { IssueSidebarCollapsible, IssueSidebarSectionHeader } from "./issue-sidebar-section";import { useT } from "../../i18n";@@ -291,7 +292,7 @@ export function QuickActionsMenu({return (<><DropdownMenu>- <TooltipHint label={label} side={side}>+ <TooltipHint label={label} shortcut={<ActionShortcutKeycaps action="runIssueQuickAction" />} side={side}><DropdownMenuTriggerrender={<Button variant="ghost" size="icon-sm" aria-label={label} className="shrink-0" disabled={running} />}>diff --git a/packages/views/issues/hooks/use-quick-action-runner.ts b/packages/views/issues/hooks/use-quick-action-runner.tsindex b1f4ed848e..9086605808 100644--- a/packages/views/issues/hooks/use-quick-action-runner.ts+++ b/packages/views/issues/hooks/use-quick-action-runner.ts@@ -22,21 +22,24 @@ export function useQuickActionRunner(issueId: string) {const { mutateAsync } = useRunQuickAction(issueId);return useCallback(- (action: QuickAction) => {+ /** Resolves whether the action's comment was posted. */+ (action: QuickAction): Promise<boolean> => {const targetName = action.target_name || t(($) => $.detail.quick_action_target_fallback);- mutateAsync({ quickActionId: action.id }).then(+ return mutateAsync({ quickActionId: action.id }).then((comment) => {const { message, kind } = outcomeMessage(comment.trigger_outcomes?.[0], targetName, t);if (kind === "success") toast.success(message);else if (kind === "error") toast.error(message);else toast.info(message);+ return true;},(error: unknown) => {if (dispatchReasonCode(error) === "invocation_not_allowed") {toast.error(t(($) => $.detail.quick_action_blocked_body, { name: action.name }));- return;+ return false;}toast.error(error instanceof Error ? error.message : String(error));+ return false;},);},diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex 24461011d5..51ca124658 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -396,8 +396,10 @@"send_enter_hint": "Shift+Enter inserts a paragraph, continues a list, or adds a code-block newline.","categories": {"general": "General",+ "issue": "Issue","navigation": "Navigation"},+ "issue_scope": "Act on the issue in front of you: the one in a peek, the issues selected in a list, or the open issue.","actions": {"openSearch": {"label": "Open search",@@ -455,6 +457,38 @@"label": "Undo inbox action","description": "Undo the last archive, snooze or unsubscribe while its toast shows; after that, put back the open notification once it is archived, or what Inbox cleared names."},+ "setIssueStatus": {+ "label": "Change status",+ "description": "Open the status picker."+ },+ "assignIssue": {+ "label": "Assign",+ "description": "Open the assignee picker."+ },+ "setIssuePriority": {+ "label": "Set priority",+ "description": "Open the priority picker."+ },+ "setIssueLabels": {+ "label": "Edit labels",+ "description": "Open the label picker."+ },+ "setIssueDueDate": {+ "label": "Set due date",+ "description": "Open the due date picker."+ },+ "moveIssueToProject": {+ "label": "Move to project",+ "description": "Open the project picker."+ },+ "runIssueQuickAction": {+ "label": "Run quick action",+ "description": "Available on a single issue when quick actions are active."+ },+ "replyToIssue": {+ "label": "Reply",+ "description": "Focus the open issue's comment box."+ },"send": {"label": "Send","description": "Also submits new issues."diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.jsonindex a643116d1c..67b5d1edd1 100644--- a/packages/views/locales/es/settings.json+++ b/packages/views/locales/es/settings.json@@ -396,8 +396,10 @@"send_enter_hint": "Shift+Enter inserta un párrafo, continúa una lista o añade un salto de línea en un bloque de código.","categories": {"general": "General",+ "issue": "Tarea","navigation": "Navegación"},+ "issue_scope": "Actúa sobre la tarea que tienes delante: la de la vista previa, las seleccionadas en una lista o la tarea abierta.","actions": {"openSearch": {"label": "Abrir búsqueda",@@ -455,6 +457,38 @@"label": "Deshacer acción de la bandeja","description": "Deshace el último archivado, posposición o baja mientras se ve su aviso; después, restaura la notificación abierta una vez archivada o lo que indica Bandeja de entrada vacía."},+ "setIssueStatus": {+ "label": "Cambiar estado",+ "description": "Abre el selector de estado."+ },+ "assignIssue": {+ "label": "Asignar",+ "description": "Abre el selector de responsable."+ },+ "setIssuePriority": {+ "label": "Establecer prioridad",+ "description": "Abre el selector de prioridad."+ },+ "setIssueLabels": {+ "label": "Editar etiquetas",+ "description": "Abre el selector de etiquetas."+ },+ "setIssueDueDate": {+ "label": "Establecer fecha de fin",+ "description": "Abre el selector de fecha de fin."+ },+ "moveIssueToProject": {+ "label": "Mover a proyecto",+ "description": "Abre el selector de proyecto."+ },+ "runIssueQuickAction": {+ "label": "Ejecutar acción rápida",+ "description": "Disponible en una sola tarea cuando hay acciones rápidas activas."+ },+ "replyToIssue": {+ "label": "Responder",+ "description": "Enfoca el cuadro de comentarios de la tarea abierta."+ },"send": {"label": "Enviar","description": "También envía nuevas tareas."diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.jsonindex 919d6de7b4..fbf8714b8d 100644--- a/packages/views/locales/fr/settings.json+++ b/packages/views/locales/fr/settings.json@@ -396,8 +396,10 @@"send_enter_hint": "Maj+Entrée insère un paragraphe, poursuit une liste, ou ajoute un saut de ligne dans un bloc de code.","categories": {"general": "Général",+ "issue": "Tâche","navigation": "Navigation"},+ "issue_scope": "Agit sur la tâche devant vous : celle de l'aperçu, les tâches sélectionnées dans une liste ou la tâche ouverte.","actions": {"openSearch": {"label": "Ouvrir la recherche",@@ -455,6 +457,38 @@"label": "Annuler l'action de la boîte de réception","description": "Annule le dernier archivage, report ou désabonnement tant que son message s'affiche ; ensuite, restaure la notification ouverte une fois archivée ou ce qu'indique Boîte de réception vide."},+ "setIssueStatus": {+ "label": "Changer le statut",+ "description": "Ouvre le sélecteur de statut."+ },+ "assignIssue": {+ "label": "Assigner",+ "description": "Ouvre le sélecteur de responsable."+ },+ "setIssuePriority": {+ "label": "Définir la priorité",+ "description": "Ouvre le sélecteur de priorité."+ },+ "setIssueLabels": {+ "label": "Modifier les libellés",+ "description": "Ouvre le sélecteur de libellés."+ },+ "setIssueDueDate": {+ "label": "Définir l'échéance",+ "description": "Ouvre le sélecteur d'échéance."+ },+ "moveIssueToProject": {+ "label": "Déplacer vers un projet",+ "description": "Ouvre le sélecteur de projet."+ },+ "runIssueQuickAction": {+ "label": "Lancer une action rapide",+ "description": "Disponible sur une seule tâche quand des actions rapides sont actives."+ },+ "replyToIssue": {+ "label": "Répondre",+ "description": "Place le curseur dans la zone de commentaire de la tâche ouverte."+ },"send": {"label": "Envoyer","description": "Permet aussi de créer des tâches."diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex 90c5244168..ca6d790b81 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -390,8 +390,10 @@"send_enter_hint": "Shift+Enterで段落の挿入、リストの継続、コードブロック内の改行ができます。","categories": {"general": "一般",+ "issue": "タスク","navigation": "ナビゲーション"},+ "issue_scope": "目の前のタスクに作用します:プレビュー中のタスク、リストで選択したタスク、または開いているタスク。","actions": {"openSearch": {"label": "検索を開く",@@ -449,6 +451,38 @@"label": "インボックスの操作を取り消す","description": "トーストが表示されている間は直前のアーカイブ・スヌーズ・購読解除を取り消します。トーストが消えた後は、開いている通知がアーカイブ済みならインボックスに戻し、「インボックスは空です」画面ではそこに表示された操作を取り消します。"},+ "setIssueStatus": {+ "label": "ステータスを変更",+ "description": "ステータスの選択を開きます。"+ },+ "assignIssue": {+ "label": "担当者を設定",+ "description": "担当者の選択を開きます。"+ },+ "setIssuePriority": {+ "label": "優先度を設定",+ "description": "優先度の選択を開きます。"+ },+ "setIssueLabels": {+ "label": "ラベルを編集",+ "description": "ラベルの選択を開きます。"+ },+ "setIssueDueDate": {+ "label": "期限を設定",+ "description": "期限の選択を開きます。"+ },+ "moveIssueToProject": {+ "label": "プロジェクトに移動",+ "description": "プロジェクトの選択を開きます。"+ },+ "runIssueQuickAction": {+ "label": "クイックアクションを実行",+ "description": "有効なクイックアクションがある単一のタスクで使えます。"+ },+ "replyToIssue": {+ "label": "返信",+ "description": "開いているタスクのコメント欄にフォーカスします。"+ },"send": {"label": "送信","description": "新しいタスクの作成にも使えます。"diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex 46c7db5bc5..151e0bc9e5 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -390,8 +390,10 @@"send_enter_hint": "Shift+Enter로 단락을 삽입하거나 목록을 이어가고 코드 블록에서 줄을 바꿀 수 있습니다.","categories": {"general": "일반",+ "issue": "태스크","navigation": "탐색"},+ "issue_scope": "눈앞의 태스크에 적용됩니다: 미리보기 중인 태스크, 목록에서 선택한 태스크, 또는 열려 있는 태스크.","actions": {"openSearch": {"label": "검색 열기",@@ -449,6 +451,38 @@"label": "인박스 작업 실행 취소","description": "토스트가 보이는 동안 마지막 보관, 미루기, 구독 해제를 취소합니다. 토스트가 사라진 뒤에는 열린 알림이 보관되었다면 인박스로 되돌리고, '인박스가 비었습니다' 화면에서는 그곳에 표시된 작업을 취소합니다."},+ "setIssueStatus": {+ "label": "상태 변경",+ "description": "상태 선택을 엽니다."+ },+ "assignIssue": {+ "label": "담당자 지정",+ "description": "담당자 선택을 엽니다."+ },+ "setIssuePriority": {+ "label": "우선순위 설정",+ "description": "우선순위 선택을 엽니다."+ },+ "setIssueLabels": {+ "label": "라벨 편집",+ "description": "라벨 선택을 엽니다."+ },+ "setIssueDueDate": {+ "label": "마감일 설정",+ "description": "마감일 선택을 엽니다."+ },+ "moveIssueToProject": {+ "label": "프로젝트로 이동",+ "description": "프로젝트 선택을 엽니다."+ },+ "runIssueQuickAction": {+ "label": "빠른 작업 실행",+ "description": "활성화된 빠른 작업이 있는 단일 태스크에서 사용할 수 있습니다."+ },+ "replyToIssue": {+ "label": "답글",+ "description": "열린 태스크의 댓글 입력란에 포커스합니다."+ },"send": {"label": "보내기","description": "새 태스크 생성에도 사용됩니다."diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.jsonindex d4d1ed1045..dcb8f47d8c 100644--- a/packages/views/locales/ru/settings.json+++ b/packages/views/locales/ru/settings.json@@ -408,8 +408,10 @@"send_enter_hint": "Shift+Enter вставляет абзац, продолжает список или добавляет перенос строки в блоке кода.","categories": {"general": "Общие",+ "issue": "Задача","navigation": "Навигация"},+ "issue_scope": "Действует на задачу перед вами: в предпросмотре, выбранные в списке или открытую задачу.","actions": {"openSearch": {"label": "Открыть поиск",@@ -467,6 +469,38 @@"label": "Отменить действие во входящих","description": "Отменяет последнее архивирование, откладывание или отписку, пока видно уведомление; после этого возвращает открытое уведомление во входящие после архивирования или отменяет действие, указанное на экране «Входящие разобраны»."},+ "setIssueStatus": {+ "label": "Изменить статус",+ "description": "Открыть выбор статуса."+ },+ "assignIssue": {+ "label": "Назначить исполнителя",+ "description": "Открыть выбор исполнителя."+ },+ "setIssuePriority": {+ "label": "Задать приоритет",+ "description": "Открыть выбор приоритета."+ },+ "setIssueLabels": {+ "label": "Изменить метки",+ "description": "Открыть выбор меток."+ },+ "setIssueDueDate": {+ "label": "Установить срок",+ "description": "Открыть выбор срока."+ },+ "moveIssueToProject": {+ "label": "Перенести в проект",+ "description": "Открыть выбор проекта."+ },+ "runIssueQuickAction": {+ "label": "Выполнить быстрое действие",+ "description": "Доступно для одной задачи, когда есть активные быстрые действия."+ },+ "replyToIssue": {+ "label": "Ответить",+ "description": "Перевести фокус в поле комментария открытой задачи."+ },"send": {"label": "Отправить","description": "Также отправляет новые задачи."diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex c24bdde916..f0ab1afc12 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -390,8 +390,10 @@"send_enter_hint": "Shift+Enter 可插入段落、继续列表,或在代码块中换行。","categories": {"general": "常规",+ "issue": "任务","navigation": "导航"},+ "issue_scope": "作用于眼前的任务:预览中的任务、列表中选中的任务,或当前打开的任务。","actions": {"openSearch": {"label": "打开搜索",@@ -449,6 +451,38 @@"label": "撤销收件箱操作","description": "提示还在时,撤销上一次归档、延后或取消订阅;提示消失后,打开的通知已归档时把它放回收件箱,在\"收件箱已清空\"页撤销页面上写明的操作。"},+ "setIssueStatus": {+ "label": "更改状态",+ "description": "打开状态选择。"+ },+ "assignIssue": {+ "label": "指派负责人",+ "description": "打开负责人选择。"+ },+ "setIssuePriority": {+ "label": "设置优先级",+ "description": "打开优先级选择。"+ },+ "setIssueLabels": {+ "label": "编辑标签",+ "description": "打开标签选择。"+ },+ "setIssueDueDate": {+ "label": "设置截止日期",+ "description": "打开截止日期选择。"+ },+ "moveIssueToProject": {+ "label": "移动到项目",+ "description": "打开项目选择。"+ },+ "runIssueQuickAction": {+ "label": "运行快捷操作",+ "description": "仅在单个任务且有可用的快捷操作时可用。"+ },+ "replyToIssue": {+ "label": "回复",+ "description": "聚焦当前任务的评论框。"+ },"send": {"label": "发送","description": "也用于提交新任务。"diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.jsonindex 0f77750496..e67e1ddd6a 100644--- a/packages/views/locales/zh-Hant/settings.json+++ b/packages/views/locales/zh-Hant/settings.json@@ -390,8 +390,10 @@"send_enter_hint": "Shift+Enter 可插入段落、繼續列表,或在程式碼塊中換行。","categories": {"general": "常規",+ "issue": "任務","navigation": "導航"},+ "issue_scope": "作用於眼前的任務:預覽中的任務、列表中選取的任務,或目前開啟的任務。","actions": {"openSearch": {"label": "開啟搜尋",@@ -449,6 +451,38 @@"label": "復原收件箱操作","description": "提示還在時,復原上一次歸檔、延後或取消訂閱;提示消失後,開啟的通知已歸檔時把它放回收件箱,在「收件箱已清空」頁復原頁面上寫明的操作。"},+ "setIssueStatus": {+ "label": "變更狀態",+ "description": "開啟狀態選擇。"+ },+ "assignIssue": {+ "label": "指派負責人",+ "description": "開啟負責人選擇。"+ },+ "setIssuePriority": {+ "label": "設定優先級",+ "description": "開啟優先級選擇。"+ },+ "setIssueLabels": {+ "label": "編輯標籤",+ "description": "開啟標籤選擇。"+ },+ "setIssueDueDate": {+ "label": "設定截止日期",+ "description": "開啟截止日期選擇。"+ },+ "moveIssueToProject": {+ "label": "移動到專案",+ "description": "開啟專案選擇。"+ },+ "runIssueQuickAction": {+ "label": "執行快捷操作",+ "description": "僅在單一任務且有可用的快捷操作時可用。"+ },+ "replyToIssue": {+ "label": "回覆",+ "description": "聚焦目前任務的留言框。"+ },"send": {"label": "傳送","description": "也用於提交新任務。"diff --git a/packages/views/search/commands/issue-commands.tsx b/packages/views/search/commands/issue-commands.tsxindex 5448f0b70b..493d926484 100644--- a/packages/views/search/commands/issue-commands.tsx+++ b/packages/views/search/commands/issue-commands.tsx@@ -38,6 +38,7 @@ import { useIssueDeletion } from "@multica/core/issues/use-issue-deletion";import { useCommentCollapseStore, useResolvedExpandStore } from "@multica/core/issues/stores";import { useIsGuest } from "@multica/core/permissions";import { quickActionListOptions } from "@multica/core/quick-actions";+import { useShortcut } from "@multica/core/shortcuts";import type { AgentTask, Issue } from "@multica/core/types";import { copyText } from "@multica/ui/lib/clipboard";import { useIssueActions } from "../../issues/actions/use-issue-actions";@@ -103,6 +104,13 @@ export function useIssueCommandGroup(const retryRun = useRetryIssueRun(singleId);const { canDelete } = useIssueDeletion(wsId);const deletable = !!target && (target.kind === "single" ? canDelete(target.issue) : target.issues.every(canDelete));+ const statusShortcut = useShortcut("setIssueStatus");+ const assigneeShortcut = useShortcut("assignIssue");+ const priorityShortcut = useShortcut("setIssuePriority");+ const labelsShortcut = useShortcut("setIssueLabels");+ const dueDateShortcut = useShortcut("setIssueDueDate");+ const projectShortcut = useShortcut("moveIssueToProject");+ const quickActionShortcut = useShortcut("runIssueQuickAction");return useMemo(() => {if (!target) return null;@@ -119,6 +127,7 @@ export function useIssueCommandGroup(keywords: ["status", "state", "状态"],page: { type: "issue-status", target },crumb,+ shortcut: statusShortcut,primary: true,},{@@ -128,6 +137,7 @@ export function useIssueCommandGroup(keywords: ["assign", "assignee", "owner", "agent", "指派", "负责人"],page: { type: "issue-assignee", target },crumb,+ shortcut: assigneeShortcut,primary: true,},{@@ -137,6 +147,7 @@ export function useIssueCommandGroup(keywords: ["priority", "urgent", "优先级"],page: { type: "issue-priority", target },crumb,+ shortcut: priorityShortcut,primary: true,},];@@ -151,6 +162,7 @@ export function useIssueCommandGroup(hint: t(($) => $.issue.quick_actions_available, { count: activeQuickActions.length }),page: { type: "issue-quick-action", issue: single },crumb,+ shortcut: quickActionShortcut,primary: true,});}@@ -172,6 +184,7 @@ export function useIssueCommandGroup(keywords: ["label", "tag", "标签"],page: { type: "issue-labels", target },crumb,+ shortcut: labelsShortcut,},{id: "issue-due-date",@@ -180,6 +193,7 @@ export function useIssueCommandGroup(keywords: ["due", "date", "deadline", "截止"],page: { type: "issue-due-date", target },crumb,+ shortcut: dueDateShortcut,},{id: "issue-project",@@ -188,6 +202,7 @@ export function useIssueCommandGroup(keywords: ["project", "move", "项目"],page: { type: "issue-project", target },crumb,+ shortcut: projectShortcut,},);@@ -384,7 +399,14 @@ export function useIssueCommandGroup(}, [actions,activeQuickActions.length,+ assigneeShortcut,deletable,+ dueDateShortcut,+ labelsShortcut,+ priorityShortcut,+ projectShortcut,+ quickActionShortcut,+ statusShortcut,guest,onDeletedFallbackPath,palette,diff --git a/packages/views/search/issue-shortcuts.tsx b/packages/views/search/issue-shortcuts.tsxnew file mode 100644index 0000000000..8356511b9b--- /dev/null+++ b/packages/views/search/issue-shortcuts.tsx@@ -0,0 +1,122 @@+"use client";++import { useEffect, useRef } from "react";+import { useQuery } from "@tanstack/react-query";+import { useCommandBarContextStore } from "@multica/core/command-bar";+import { useCurrentWorkspace } from "@multica/core/paths";+import { useAuthStore } from "@multica/core/auth";+import { quickActionListOptions } from "@multica/core/quick-actions";+import { memberListOptions } from "@multica/core/workspace/queries";+import { getShortcut, shortcutMatchesEvent, type ShortcutActionId } from "@multica/core/shortcuts";+import { isPageShortcutEvent } from "../common/page-shortcut";+import { composerFocusFor } from "../issues/components/composer-focus";+import { useT } from "../i18n";+import { issueTargetFromContexts } from "./issue-target";+import { stripEllipsis } from "./matching";+import { openPalettePage } from "./palette-launch";+import type { IssueTarget, PalettePage } from "./types";++type PickerPageType = Exclude<Extract<PalettePage, { target: IssueTarget }>["type"], "issue-parent">;++const PICKER_PAGES = {+ setIssueStatus: "issue-status",+ assignIssue: "issue-assignee",+ setIssuePriority: "issue-priority",+ setIssueLabels: "issue-labels",+ setIssueDueDate: "issue-due-date",+ moveIssueToProject: "issue-project",+} as const satisfies Partial<Record<ShortcutActionId, PickerPageType>>;++type PickerVerb = keyof typeof PICKER_PAGES;+type IssueVerb = PickerVerb | "runIssueQuickAction" | "replyToIssue";++const ISSUE_VERBS: readonly IssueVerb[] = [+ ...(Object.keys(PICKER_PAGES) as PickerVerb[]),+ "runIssueQuickAction",+ "replyToIssue",+];++/**+ * The issue verbs (S, A, P, ...) on the issue in front of the user: each opens+ * the ⌘K page its command opens, already on that issue or selection, and R+ * focuses the open issue's composer. A verb with nothing to act on leaves the+ * key alone.+ *+ * Listens on `window`, after every document-level handler, so a key that+ * means something more specific where it is pressed (a board peek's H / L)+ * keeps that meaning.+ */+export function IssueShortcuts() {+ const { t } = useT("search");+ // Mounted with the closed palette on every page, before the workspace may+ // have resolved.+ const wsId = useCurrentWorkspace()?.id ?? "";+ const userId = useAuthStore((s) => s.user?.id ?? null);+ const { data: members } = useQuery({+ ...memberListOptions(wsId),+ enabled: wsId !== "" && userId !== null,+ });+ const role = members?.find((member) => member.user_id === userId)?.role ?? null;+ // A guest (MUL-9420) only comments, and the server refuses its quick-action+ // reads, so field verbs wait until the role is known to be a member's.+ const canEdit = role !== null && role !== "guest";+ const onSingleIssue = useCommandBarContextStore(+ (s) => issueTargetFromContexts(s.entries.map((entry) => entry.context))?.kind === "single",+ );+ const { data: quickActions = [] } = useQuery({+ ...quickActionListOptions(wsId),+ enabled: canEdit && onSingleIssue,+ });+ const hasQuickActions = quickActions.some((action) => action.status === "active");++ const actionFor = (verb: IssueVerb, target: IssueTarget): (() => void) | null => {+ const single = target.kind === "single" ? target.issue : null;+ if (verb === "replyToIssue") return single ? composerFocusFor(single.id) : null;+ if (!canEdit) return null;+ const crumb =+ target.kind === "single"+ ? target.issue.identifier+ : t(($) => $.context.selected_issues, { count: target.issues.length });+ if (verb === "runIssueQuickAction") {+ if (!single || !hasQuickActions) return null;+ return () =>+ openPalettePage({+ page: { type: "issue-quick-action", issue: single },+ crumbs: [crumb, stripEllipsis(t(($) => $.issue.run_quick_action))],+ });+ }+ const labels: Record<PickerVerb, string> = {+ setIssueStatus: t(($) => $.issue.change_status),+ assignIssue: t(($) => $.issue.assign_to),+ setIssuePriority: t(($) => $.issue.set_priority),+ setIssueLabels: t(($) => $.issue.add_label),+ setIssueDueDate: t(($) => $.issue.set_due_date),+ moveIssueToProject: t(($) => $.issue.move_to_project),+ };+ return () =>+ openPalettePage({+ page: { type: PICKER_PAGES[verb], target },+ crumbs: [crumb, stripEllipsis(labels[verb])],+ });+ };+ const actionForRef = useRef(actionFor);+ actionForRef.current = actionFor;++ useEffect(() => {+ const onKeyDown = (event: KeyboardEvent) => {+ if (!isPageShortcutEvent(event)) return;+ const verb = ISSUE_VERBS.find((id) => shortcutMatchesEvent(getShortcut(id), event));+ if (!verb) return;+ const contexts = useCommandBarContextStore.getState().entries.map((entry) => entry.context);+ const target = issueTargetFromContexts(contexts);+ const run = target ? actionForRef.current(verb, target) : null;+ if (!run) return;+ event.preventDefault();+ run();+ };+ window.addEventListener("keydown", onKeyDown);+ return () => window.removeEventListener("keydown", onKeyDown);+ }, []);++ return null;+}diff --git a/packages/views/search/issue-target.ts b/packages/views/search/issue-target.tsindex 8e0655b350..2796f94852 100644--- a/packages/views/search/issue-target.ts+++ b/packages/views/search/issue-target.ts@@ -4,6 +4,8 @@ import { useCallback, useMemo } from "react";import { toast } from "sonner";import type { BatchIssueLabelOps, Issue, UpdateIssueRequest } from "@multica/core/types";import { errorCode } from "@multica/core/api";+import { useCommandBarContextStore, type CommandBarContext } from "@multica/core/command-bar";+import { noteInboxBarAction, type InboxBarAction } from "@multica/core/inbox/auto-archive";import { useWorkspaceId } from "@multica/core/hooks";import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";import { useBatchUpdateIssues, useUpdateIssue } from "@multica/core/issues/mutations";@@ -17,6 +19,28 @@ export function targetIssues(target: IssueTarget): Issue[] {return target.kind === "single" ? [target.issue] : target.issues;}+/** What issue commands act on: the newest issue or selection a page registered. */+export function issueTargetFromContexts(contexts: readonly CommandBarContext[]): IssueTarget | null {+ for (const context of contexts) {+ if (context.kind === "issue") return { kind: "single", issue: context.issue };+ if (context.kind === "issues") {+ return { kind: "batch", issues: context.issues, clearSelection: context.clearSelection };+ }+ }+ return null;+}++/**+ * Record a palette write to the Inbox's open issue as its bar records one, so+ * once the notification archives the bar names what the user did.+ */+export function noteInboxBarActionFromPalette(issueId: string, action: InboxBarAction) {+ const inbox = useCommandBarContextStore+ .getState()+ .entries.find((entry) => entry.context.kind === "inbox")?.context;+ if (inbox?.kind === "inbox" && inbox.item?.issue_id === issueId) noteInboxBarAction(issueId, action);+}+/*** Field writes for an issue command, routed the way the matching on-page* control routes them: a single issue passes the run-confirm gate that asksdiff --git a/packages/views/search/pages/issue-pages.tsx b/packages/views/search/pages/issue-pages.tsxindex 106a7f52c7..cc65821172 100644--- a/packages/views/search/pages/issue-pages.tsx+++ b/packages/views/search/pages/issue-pages.tsx@@ -16,6 +16,7 @@ import {} from "@multica/core/issue-workflows";import { issueLabelsOptions, labelListOptions } from "@multica/core/labels/queries";import { useAttachLabelToIssue, useDetachLabel } from "@multica/core/labels/mutations";+import { takeInboxBarAction } from "@multica/core/inbox/auto-archive";import { useModalStore } from "@multica/core/modals";import { projectListOptions } from "@multica/core/projects/queries";import { selectableProjects } from "@multica/core/projects";@@ -28,7 +29,7 @@ import { useIssueStatusOptions } from "../../issues/utils/status-options";import { ProjectIcon } from "../../projects/components/project-icon";import { useT } from "../../i18n";import { HighlightText } from "../highlight-text";-import { useIssueTargetWriter, targetIssues } from "../issue-target";+import { noteInboxBarActionFromPalette, useIssueTargetWriter, targetIssues } from "../issue-target";import { scoreRow, scoreText } from "../matching";import { usePalette } from "../palette-context";import { PaletteGroup, ROW_CLASS, ROW_ICON_CLASS, RowCheck, RowHint } from "../rows";@@ -110,6 +111,7 @@ export function IssueStatusPage({ target, query }: { target: IssueTarget; query:});return;}+ if (single) noteInboxBarActionFromPalette(single.id, { type: "status", status });writer.apply({ status });};@@ -209,6 +211,12 @@ export function IssueAssigneePage({ target, query }: { target: IssueTarget; querconst select = (type: "member" | "agent" | "squad" | null, id: string | null) => {palette.close();+ if (target.kind === "single") {+ noteInboxBarActionFromPalette(target.issue.id, {+ type: "assignee",+ assignee: type && id ? { type, id } : null,+ });+ }writer.assign(type, id);};@@ -556,7 +564,8 @@ export function IssueQuickActionPage({ issue, query }: { issue: Issue; query: stvalue={`quick-action:${action.id}`}onSelect={() => {palette.close();- run(action);+ noteInboxBarActionFromPalette(issue.id, { type: "quick_action", name: action.name });+ void run(action).then((posted) => posted || takeInboxBarAction(issue.id));}}className={ROW_CLASS}>diff --git a/packages/views/search/palette-launch.ts b/packages/views/search/palette-launch.tsnew file mode 100644index 0000000000..dfc2748c44--- /dev/null+++ b/packages/views/search/palette-launch.ts@@ -0,0 +1,17 @@+"use client";++import { useSearchStore } from "@multica/core/command-bar";+import type { PaletteStackEntry } from "./types";++/** Open ⌘K straight on `entry`'s page, as if its command had been chosen. ⌫ goes back to the root. */+export function openPalettePage(entry: PaletteStackEntry) {+ useSearchStore.getState().openOnPage(entry);+}++export function usePendingPalettePage(): PaletteStackEntry | null {+ return useSearchStore((s) => s.launchPage as PaletteStackEntry | null);+}++export function clearPendingPalettePage() {+ useSearchStore.getState().clearLaunchPage();+}diff --git a/packages/views/search/search-command.test.tsx b/packages/views/search/search-command.test.tsxindex 3202abaae1..2658c1f366 100644--- a/packages/views/search/search-command.test.tsx+++ b/packages/views/search/search-command.test.tsx@@ -9,6 +9,7 @@ import {useSearchStore,type CommandBarContext,} from "@multica/core/command-bar";+import { takeInboxBarAction } from "@multica/core/inbox/auto-archive";import { inboxUnreadSummaryOptions } from "@multica/core/inbox/queries";import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";import { issueViewEverywhereOptions } from "@multica/core/issue-views/queries";@@ -32,6 +33,7 @@ import {import { RESOURCES } from "../locales";import enLayout from "../locales/en/layout.json";import zhHansProjects from "../locales/zh-Hans/projects.json";+import { registerComposerFocus } from "../issues/components/composer-focus";import { SearchCommand } from "./search-command";import { DOC_SEARCH_DEBOUNCE_MS } from "./use-doc-search";@@ -1346,6 +1348,183 @@ describe("SearchCommand", () => {});});+ describe("issue shortcuts", () => {+ const issue = makeIssue({ id: "issue-1", identifier: "MUL-42", title: "Safari login loop", status: "todo" });+ const press = (key: string, init: KeyboardEventInit = {}, target: EventTarget = document.body) => {+ const event = new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true, ...init });+ act(() => void target.dispatchEvent(event));+ return event;+ };+ beforeEach(() => {+ act(() => useSearchStore.setState({ open: false }));+ seed(issueDetailOptions("ws-test", "issue-1"), issue);+ });++ it.each([+ ["s", false, "Change status"],+ ["a", false, "Assign to"],+ ["p", false, "Set priority"],+ ["l", false, "Add label"],+ ["D", true, "Set due date"],+ ["P", true, "Move to project"],+ ])("'%s' (shift: %s) opens %s on the open issue", async (key, shiftKey, page) => {+ registerContext({ kind: "issue", issue });+ renderSearch();++ expect(press(key, { shiftKey }).defaultPrevented).toBe(true);+ expect(useSearchStore.getState().open).toBe(true);+ expect(await screen.findByRole("navigation", { name: "Current menu" })).toHaveTextContent(`MUL-42${page}`);+ });++ it("goes back to the palette root on Backspace", async () => {+ const user = userEvent.setup();+ registerContext({ kind: "issue", issue });+ renderSearch();+ press("s");++ await screen.findByRole("navigation", { name: "Current menu" });+ await user.keyboard("{Backspace}");+ expect(await screen.findByPlaceholderText(PLACEHOLDER)).toBeInTheDocument();+ expect(renderedValues()).toContain("command:context-issue:issue-status");+ });++ it("acts on a list selection over the issue behind it", async () => {+ registerContext({ kind: "issue", issue });+ const selection = [makeIssue({ id: "issue-a", identifier: "MUL-1" }), makeIssue({ id: "issue-b", identifier: "MUL-2" })];+ registerContext({ kind: "issues", issues: selection, clearSelection: vi.fn() });+ renderSearch();+ press("p");++ expect(await screen.findByRole("navigation", { name: "Current menu" })).toHaveTextContent(+ "2 selected issuesSet priority",+ );+ });++ it("leaves the key alone with no issue in front of the user", () => {+ renderSearch();+ expect(press("s").defaultPrevented).toBe(false);+ expect(useSearchStore.getState().open).toBe(false);+ });++ it("leaves a key typed into a field, or one a page already handled", () => {+ registerContext({ kind: "issue", issue });+ renderSearch();+ const field = document.createElement("input");+ document.body.append(field);++ expect(press("s", {}, field).defaultPrevented).toBe(false);+ const handled = new KeyboardEvent("keydown", { key: "s", bubbles: true, cancelable: true });+ handled.preventDefault();+ act(() => void document.body.dispatchEvent(handled));+ expect(useSearchStore.getState().open).toBe(false);+ field.remove();+ });++ it("leaves every field verb to a guest", () => {+ seed(memberListOptions("ws-test"), [{ ...makeMember(ME, "Me Myself", "[email protected]"), role: "guest" }]);+ registerContext({ kind: "issue", issue });+ renderSearch();++ for (const key of ["s", "a", "p", "l", "q"]) expect(press(key).defaultPrevented).toBe(false);+ expect(useSearchStore.getState().open).toBe(false);+ });++ it("waits for the viewer's role before claiming a field verb or reading quick actions", () => {+ queryData.delete(JSON.stringify(memberListOptions("ws-test").queryKey));+ registerContext({ kind: "issue", issue });+ renderSearch();++ for (const key of ["s", "a", "q"]) expect(press(key).defaultPrevented).toBe(false);+ expect(useSearchStore.getState().open).toBe(false);+ expect(requestedKeys).not.toContain(JSON.stringify(quickActionListOptions("ws-test").queryKey));+ });++ it("reads quick actions only with a single issue in front of the user", () => {+ renderSearch();+ expect(requestedKeys).not.toContain(JSON.stringify(quickActionListOptions("ws-test").queryKey));+ });++ it("reads no quick actions for a guest", () => {+ seed(memberListOptions("ws-test"), [{ ...makeMember(ME, "Me Myself", "[email protected]"), role: "guest" }]);+ registerContext({ kind: "issue", issue });+ renderSearch();+ expect(requestedKeys).not.toContain(JSON.stringify(quickActionListOptions("ws-test").queryKey));+ });++ it("leaves 'q' alone when the workspace has no active quick action", () => {+ seed(quickActionListOptions("ws-test"), { quick_actions: [{ id: "qa-1", name: "Triage", status: "paused" }] });+ registerContext({ kind: "issue", issue });+ renderSearch();+ expect(press("q").defaultPrevented).toBe(false);+ });++ it("opens the quick actions on 'q'", async () => {+ seed(quickActionListOptions("ws-test"), {+ quick_actions: [{ id: "qa-1", name: "Triage", status: "active", target_name: "Lambda" }],+ });+ registerContext({ kind: "issue", issue });+ renderSearch();+ expect(press("q").defaultPrevented).toBe(true);+ expect(await screen.findByRole("navigation", { name: "Current menu" })).toHaveTextContent("MUL-42Run quick action");+ });++ it("focuses the open issue's composer on 'r', the newest one first", () => {+ registerContext({ kind: "issue", issue });+ renderSearch();+ expect(press("r").defaultPrevented).toBe(false);++ const page = vi.fn();+ const peek = vi.fn();+ const releasePage = registerComposerFocus("issue-1", page);+ const releasePeek = registerComposerFocus("issue-1", peek);+ expect(press("r").defaultPrevented).toBe(true);+ expect(peek).toHaveBeenCalledTimes(1);+ releasePeek();+ press("r");+ expect(page).toHaveBeenCalledTimes(1);+ releasePage();+ expect(useSearchStore.getState().open).toBe(false);+ });++ it("records a status picked for the Inbox's open issue as the bar does", async () => {+ const user = userEvent.setup();+ registerContext({ kind: "issue", issue });+ registerContext({+ kind: "inbox",+ item: { id: "inbox-1", issue_id: "issue-1" },+ archive: vi.fn(),+ markUnread: vi.fn(),+ markAllRead: vi.fn(),+ } as unknown as CommandBarContext);+ renderSearch();+ press("s");++ await user.click(await screen.findByText("In Progress"));+ await waitFor(() => expect(api("updateIssue")).toHaveBeenCalledWith("issue-1", { status: "in_progress" }));+ expect(takeInboxBarAction("issue-1")).toEqual({ type: "status", status: "in_progress" });+ });++ it("records nothing for an issue the Inbox is not showing", async () => {+ const user = userEvent.setup();+ registerContext({ kind: "issue", issue });+ renderSearch();+ press("s");++ await user.click(await screen.findByText("In Progress"));+ await waitFor(() => expect(api("updateIssue")).toHaveBeenCalled());+ expect(takeInboxBarAction("issue-1")).toBeNull();+ });++ it("shows each verb's keys on its command row", async () => {+ registerContext({ kind: "issue", issue });+ act(() => useSearchStore.setState({ open: true }));+ renderSearch();++ const row = (await rowText("Change status...")).closest('[cmdk-item=""]') as HTMLElement;+ expect(within(row).getByText("S")).toBeInTheDocument();+ });+ });+describe("previewed issue inside a selection", () => {const issues = [makeIssue({ id: "issue-a", identifier: "MUL-1" }),diff --git a/packages/views/search/search-command.tsx b/packages/views/search/search-command.tsxindex c30499e4c5..2698a71aa4 100644--- a/packages/views/search/search-command.tsx+++ b/packages/views/search/search-command.tsx@@ -27,6 +27,8 @@ import { useT } from "../i18n";import { PaletteContext, type PaletteApi } from "./palette-context";import { PaletteFooter } from "./footer";import { PaletteHostDialogs } from "./host-dialogs";+import { IssueShortcuts } from "./issue-shortcuts";+import { clearPendingPalettePage, usePendingPalettePage } from "./palette-launch";import { PageView } from "./pages/page-view";import { RootView } from "./root-view";import { useRootModel } from "./use-root-model";@@ -44,6 +46,7 @@ export function SearchCommand() {const workspaceSlug = useWorkspaceSlug();const open = useSearchStore((s) => s.open);const setOpen = useSearchStore((s) => s.setOpen);+ const launchPage = usePendingPalettePage();const [hostDialog, setHostDialog] = useState<PaletteHostDialog | null>(null);const close = useCallback(() => setOpen(false), [setOpen]);const openHostDialog = useCallback(@@ -70,26 +73,46 @@ export function SearchCommand() {selection and pending searches together with their workspace.Base UI's Portal keeps the body mounted through the exit animationand unmounts it once closed, so no `{open && ...}` gate is needed. */}- <PaletteBody key={workspaceSlug} active={open} close={close} openHostDialog={openHostDialog} />+ <PaletteBody+ key={workspaceSlug}+ active={open}+ launchPage={launchPage}+ close={close}+ openHostDialog={openHostDialog}+ /></DialogContent></Dialog><PaletteHostDialogs dialog={hostDialog} onClose={() => setHostDialog(null)} />+ <IssueShortcuts /></>);}function PaletteBody({active,+ launchPage,close,openHostDialog,}: {active: boolean;+ /** The page an issue shortcut opened the palette on (`openPalettePage`). */+ launchPage: PaletteStackEntry | null;close: () => void;openHostDialog: (dialog: PaletteHostDialog) => void;}) {const intentNavigate = useIntentNavigate();const [pageQuery, setPageQuery] = useState("");- const [stack, setStack] = useState<PaletteStackEntry[]>([]);+ const [stack, setStack] = useState<PaletteStackEntry[]>(() => (launchPage ? [launchPage] : []));++ // The body mounts as the palette opens, so the launch page is its first+ // page; one that arrives while it is still mounted (reopened mid-exit)+ // replaces the stack.+ useEffect(() => {+ if (!launchPage) return;+ clearPendingPalettePage();+ setStack((prev) => (prev.length === 1 && prev[0] === launchPage ? prev : [launchPage]));+ setPageQuery("");+ }, [launchPage]);// cmdk's onSelect carries no event, so the activating gesture's modifiers// are recorded on the capture phase (click on a result, Enter in the input)diff --git a/packages/views/search/search-command.visibility.test.tsx b/packages/views/search/search-command.visibility.test.tsxindex e1c123e502..3592a4b8e4 100644--- a/packages/views/search/search-command.visibility.test.tsx+++ b/packages/views/search/search-command.visibility.test.tsx@@ -44,6 +44,7 @@ vi.mock("../navigation/context", () => {vi.mock("@multica/ui/components/common/theme-provider", () => ({useTheme: () => ({ theme: "system", setTheme: vi.fn() }),}));+vi.mock("./issue-shortcuts", () => ({ IssueShortcuts: () => null }));function SidebarCount() {const count = useInboxUnreadCount("ws-1");diff --git a/packages/views/settings/components/keyboard-shortcuts-tab.tsx b/packages/views/settings/components/keyboard-shortcuts-tab.tsxindex f9a8b9adb5..46c277b76f 100644--- a/packages/views/settings/components/keyboard-shortcuts-tab.tsx+++ b/packages/views/settings/components/keyboard-shortcuts-tab.tsx@@ -75,7 +75,7 @@ export function KeyboardShortcutsTab() {});}, [query, t]);- const groups: readonly ShortcutCategory[] = ["general", "navigation"];+ const groups: readonly ShortcutCategory[] = ["general", "issue", "navigation"];const capture = (actionId: ShortcutActionId, event: React.KeyboardEvent) => {event.preventDefault();@@ -156,6 +156,7 @@ export function KeyboardShortcutsTab() {<SettingsSectionkey={category}title={t(($) => $.shortcuts.categories[category])}+ description={category === "issue" ? t(($) => $.shortcuts.issue_scope) : undefined}><SettingsCard>{actions.map((action) => (@@ -283,6 +284,8 @@ function ShortcutRow({"nextInboxItem","prevInboxItem","undoInboxAction",+ "runIssueQuickAction",+ "replyToIssue","send",].includes(action.id)? t(($) => $.shortcuts.actions[action.id].description)