Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-9069 feat(chat): start a new Ask Multica chat with Shift+Cmd+J (#10390)
Jiayuan Zhang4486223fe9e2
diff --git a/apps/docs/content/docs/chat.fr.mdx b/apps/docs/content/docs/chat.fr.mdxindex a9c593b1d7..a21c093806 100644--- a/apps/docs/content/docs/chat.fr.mdx+++ b/apps/docs/content/docs/chat.fr.mdx@@ -54,8 +54,9 @@ Après la réponse de l'agent, des **Questions de suivi** s'affichent parfois enInutile de quitter la page en cours pour discuter. Les pages de l'espace de travail affichent un bouton de discussion rond en bas à droite (son info-bulle indique « Demander à Multica ») qui ouvre une fenêtre de discussion flottante. Cette fenêtre et la page **Discussion** partagent les mêmes conversations : une discussion commencée d'un côté se poursuit de l'autre.- Appuyez sur `⌘J` (`Ctrl+J` sous Windows et Linux) pour ouvrir ou fermer la fenêtre flottante ; à l'ouverture, le curseur se place dans la zone de saisie. La touche fonctionne aussi pendant que vous tapez dans cette zone. Vous pouvez la modifier dans **Paramètres → Raccourcis** ; voir [Recherche, raccourcis et préférences](/shortcuts).+- Appuyez sur `⇧⌘J` (`Ctrl+Maj+J` sous Windows et Linux) pour démarrer plutôt une nouvelle discussion, comme avec **Demander à Multica** ; `⌘J` rouvre la dernière discussion ouverte. Appuyez de nouveau sur la nouvelle discussion pour fermer la fenêtre.- Faites glisser les bords de la fenêtre pour la redimensionner, ou développez-la et réduisez-la. Pendant qu'un agent répond, le bouton de discussion fermé pulse légèrement.-- La page **Discussion** elle-même n'affiche pas ce bouton, et `⌘J` n'y fait rien : la page montre déjà la même conversation.+- La page **Discussion** elle-même n'affiche pas ce bouton, et ni `⌘J` ni `⇧⌘J` n'y font rien : la page montre déjà la même conversation.Si vous ne voulez pas de la fenêtre flottante, désactivez **Fenêtre de discussion flottante** dans **Paramètres → Préférences → Commentaires et discussion**. La discussion n'est alors accessible que depuis la barre latérale. Ce réglage ne s'applique qu'à l'appareil utilisé.diff --git a/apps/docs/content/docs/chat.ja.mdx b/apps/docs/content/docs/chat.ja.mdxindex 48b9764f8a..dc83b8c0c5 100644--- a/apps/docs/content/docs/chat.ja.mdx+++ b/apps/docs/content/docs/chat.ja.mdx@@ -54,8 +54,9 @@ import { ChatQueueDemo } from "@/components/demos/chat-queue-demo";いま開いているページを離れずにチャットできます。ワークスペースの各ページの右下には丸いチャットボタンがあり(ツールチップは「Multica に質問」)、クリックするとフローティングチャットが開きます。このウィンドウとサイドバーの**チャット**ページは同じ会話を共有しているので、どちらで始めた会話も、もう一方で続けられます。- `⌘J`(Windows と Linux では `Ctrl+J`)でフローティングチャットを開閉できます。開くとカーソルがメッセージ入力欄に入り、入力欄で文字を打っている最中でもこのキーで閉じられます。キーは**設定 → ショートカット**で変更できます。詳しくは[検索・ショートカット・環境設定](/shortcuts)を参照してください。+- `⇧⌘J`(Windows と Linux では `Ctrl+Shift+J`)を押すと、**Multica に質問**と同じく新しいチャットを始めます。`⌘J` は前回開いていたチャットを開きます。新しいチャットを表示中にもう一度押すとウィンドウを閉じます。- ウィンドウは端をドラッグしてサイズを変えられるほか、展開や最小化もできます。エージェントが返信している間は、閉じた状態のチャットボタンが小さく脈打ちます。-- **チャット**ページ自体にはこのボタンが表示されず、`⌘J` も効きません。ページ全体ですでに同じ会話を表示しているためです。+- **チャット**ページ自体にはこのボタンが表示されず、`⌘J` と `⇧⌘J` も効きません。ページ全体ですでに同じ会話を表示しているためです。フローティングチャットが不要なら、**設定 → 環境設定 → コメントとチャット**で**フローティングチャット**をオフにします。以後チャットはサイドバーからだけ開けます。この設定は今使っているデバイスにだけ適用されます。diff --git a/apps/docs/content/docs/chat.ko.mdx b/apps/docs/content/docs/chat.ko.mdxindex 607e0c7198..1b108e2af9 100644--- a/apps/docs/content/docs/chat.ko.mdx+++ b/apps/docs/content/docs/chat.ko.mdx@@ -54,8 +54,9 @@ import { ChatQueueDemo } from "@/components/demos/chat-queue-demo";지금 보고 있는 페이지를 떠나지 않고도 채팅할 수 있습니다. 워크스페이스 페이지 오른쪽 아래에 둥근 채팅 버튼이 있고(툴팁은 'Multica에 묻기'), 클릭하면 플로팅 채팅 창이 열립니다. 이 창과 사이드바의 **채팅** 페이지는 같은 대화를 공유하므로, 어느 쪽에서 시작한 대화든 다른 쪽에서 이어서 할 수 있습니다.- `⌘J`(Windows와 Linux에서는 `Ctrl+J`)로 플로팅 채팅 창을 열고 닫습니다. 창을 열면 커서가 메시지 입력란에 놓이고, 입력란에서 글을 쓰는 중에도 이 키로 닫을 수 있습니다. 키는 **설정 → 단축키**에서 바꿀 수 있습니다. [검색, 단축키, 환경설정](/shortcuts)을 참고하세요.+- `⇧⌘J`(Windows와 Linux에서는 `Ctrl+Shift+J`)를 누르면 **Multica에 묻기**처럼 새 채팅을 시작합니다. `⌘J`는 마지막으로 열었던 채팅을 엽니다. 새 채팅이 열린 상태에서 다시 누르면 창이 닫힙니다.- 창 가장자리를 끌어 크기를 조절하거나, 창을 펼치거나 최소화할 수 있습니다. 에이전트가 답변하는 동안에는 닫힌 채팅 버튼이 살짝 맥박치듯 움직입니다.-- **채팅** 페이지에는 이 버튼이 표시되지 않고 `⌘J`도 동작하지 않습니다. 페이지 전체가 이미 같은 대화를 보여 주기 때문입니다.+- **채팅** 페이지에는 이 버튼이 표시되지 않고 `⌘J`와 `⇧⌘J`도 동작하지 않습니다. 페이지 전체가 이미 같은 대화를 보여 주기 때문입니다.플로팅 창이 필요 없다면 **설정 → 환경설정 → 댓글 및 채팅**에서 **플로팅 채팅 창**을 끄세요. 그 뒤에는 사이드바에서만 채팅에 들어갈 수 있습니다. 이 설정은 지금 쓰는 기기에만 적용됩니다.diff --git a/apps/docs/content/docs/chat.mdx b/apps/docs/content/docs/chat.mdxindex 4cb8f11f8e..83dfc630a1 100644--- a/apps/docs/content/docs/chat.mdx+++ b/apps/docs/content/docs/chat.mdx@@ -54,8 +54,9 @@ After the agent replies, it sometimes offers **Follow-up questions** below the rYou don't have to leave the page you're on to chat. Workspace pages have a round chat button in the bottom-right corner (its tooltip reads "Ask Multica"), which opens a floating chat window. The window and the **Chat** page share the same conversations, so you can pick up a chat from either one.- Press `⌘J` (`Ctrl+J` on Windows and Linux) to open or close the floating window; opening it puts the cursor in the message input. The key works while you're typing in that input, too. You can rebind it under **Settings → Shortcuts**; see [Search, shortcuts, and preferences](/shortcuts).+- Press `⇧⌘J` (`Ctrl+Shift+J` on Windows and Linux) to start a new chat instead, the same as **Ask Multica**; `⌘J` reopens the chat you had open last. Press it again on the new chat to close the window.- Drag the window's edges to resize it, or expand or minimize it. While an agent is replying, the closed chat button pulses gently.-- The **Chat** page itself doesn't show the button, and `⌘J` does nothing there: the page already shows the same conversation.+- The **Chat** page itself doesn't show the button, and neither `⌘J` nor `⇧⌘J` does anything there: the page already shows the same conversation.If you don't want the floating window, turn off **Floating chat window** under **Settings → Preferences → Comments & chat**. Chat is then reachable only from the sidebar. The switch applies to the current device only.diff --git a/apps/docs/content/docs/chat.zh-Hant.mdx b/apps/docs/content/docs/chat.zh-Hant.mdxindex d094962285..54f1159137 100644--- a/apps/docs/content/docs/chat.zh-Hant.mdx+++ b/apps/docs/content/docs/chat.zh-Hant.mdx@@ -54,8 +54,9 @@ AI 代理回覆後,下方有時會給出**後續提問**。後續提問點選不用離開當前頁面也能聊天。工作區頁面的右下角有一個圓形聊天按鈕,懸停時提示"問 Multica",點開是一個懸浮聊天窗。窗裡的對話和**聊天**頁是同一份,在哪邊開始的對話,另一邊都能接著聊。- 按 `⌘J`(Windows / Linux 上是 `Ctrl+J`)開啟或收起懸浮窗,開啟後游標直接落在輸入框裡。游標在輸入框裡時也能用這個鍵收起。按鍵可以在**設定 → 快捷鍵**裡改,見[搜尋、快捷鍵與偏好設定](/shortcuts)。+- 按 `⇧⌘J`(Windows / Linux 上是 `Ctrl+Shift+J`)則直接開始新對話,和點**問 Multica**一樣;`⌘J` 開啟的是上次那段對話。停在新對話上再按一次會收起懸浮窗。- 懸浮窗可以拖動邊緣調整大小,也可以展開或最小化。AI 代理正在回覆時,收起後的按鈕會輕輕跳動。-- **聊天**頁本身不顯示這個按鈕,`⌘J` 在這裡也不起作用:整頁顯示的已經是同一段對話。+- **聊天**頁本身不顯示這個按鈕,`⌘J` 和 `⇧⌘J` 在這裡也不起作用:整頁顯示的已經是同一段對話。不需要懸浮窗時,在**設定 → 偏好設定 → 評論與聊天**裡關閉**懸浮聊天窗**,之後只能從側邊欄進入聊天。這個開關只對當前裝置生效。diff --git a/apps/docs/content/docs/chat.zh.mdx b/apps/docs/content/docs/chat.zh.mdxindex c5d1247c0d..46d9528c94 100644--- a/apps/docs/content/docs/chat.zh.mdx+++ b/apps/docs/content/docs/chat.zh.mdx@@ -54,8 +54,9 @@ import { ChatQueueDemo } from "@/components/demos/chat-queue-demo";不用离开当前页面也能聊天。工作区页面的右下角有一个圆形聊天按钮,悬停时提示"问 Multica",点开是一个悬浮聊天窗。窗里的对话和**聊天**页是同一份,在哪边开始的对话,另一边都能接着聊。- 按 `⌘J`(Windows / Linux 上是 `Ctrl+J`)打开或收起悬浮窗,打开后光标直接落在输入框里。光标在输入框里时也能用这个键收起。按键可以在**设置 → 快捷键**里改,见[搜索、快捷键与偏好设置](/shortcuts)。+- 按 `⇧⌘J`(Windows / Linux 上是 `Ctrl+Shift+J`)则直接开始新对话,和点**问 Multica**一样;`⌘J` 打开的是上次那段对话。停在新对话上再按一次会收起悬浮窗。- 悬浮窗可以拖动边缘调整大小,也可以展开或最小化。智能体正在回复时,收起后的按钮会轻轻跳动。-- **聊天**页本身不显示这个按钮,`⌘J` 在这里也不起作用:整页显示的已经是同一段对话。+- **聊天**页本身不显示这个按钮,`⌘J` 和 `⇧⌘J` 在这里也不起作用:整页显示的已经是同一段对话。不需要悬浮窗时,在**设置 → 偏好设置 → 评论与聊天**里关闭**悬浮聊天窗**,之后只能从侧边栏进入聊天。这个开关只对当前设备生效。diff --git a/apps/docs/content/docs/shortcuts.fr.mdx b/apps/docs/content/docs/shortcuts.fr.mdxindex dbe07aa6db..ba27c89d8c 100644--- a/apps/docs/content/docs/shortcuts.fr.mdx+++ b/apps/docs/content/docs/shortcuts.fr.mdx@@ -33,6 +33,7 @@ Choisir un résultat l'ouvre. Maintenez `⌘` (`Ctrl` sous Windows et Linux) en| Afficher ou masquer la barre latérale gauche | `⌘B` | `Ctrl+B` | || Afficher ou masquer la barre latérale droite | `⌘/` | `Ctrl+/` | Uniquement sur les pages qui en ont une, comme une tâche. || Afficher ou masquer la fenêtre de discussion | `⌘J` | `Ctrl+J` | À l'ouverture, le curseur se place dans la zone de saisie. Voir [Discuter depuis n'importe quelle page](/chat#discuter-depuis-nimporte-quelle-page). |+| Demander à Multica | `⇧⌘J` | `Ctrl+Maj+J` | Démarre une nouvelle discussion dans la fenêtre flottante. || Rechercher dans la tâche | `⌘F` | `Ctrl+F` | Voir plus bas. || Archiver la notification | `E` | `E` | Archive la notification ouverte dans la boîte de réception, ou la restaure quand vous consultez les archives. || Envoyer | `⌘↵` | `Ctrl+Enter` | Envoie commentaires et messages de discussion, et sert aussi à créer des tâches. |diff --git a/apps/docs/content/docs/shortcuts.ja.mdx b/apps/docs/content/docs/shortcuts.ja.mdxindex a4fa7bb631..30bb495ebd 100644--- a/apps/docs/content/docs/shortcuts.ja.mdx+++ b/apps/docs/content/docs/shortcuts.ja.mdx@@ -33,6 +33,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";| 左サイドバーを切り替え | `⌘B` | `Ctrl+B` | || 右サイドバーを切り替え | `⌘/` | `Ctrl+/` | タスクの詳細など、右サイドバーのあるページでのみ使えます。 || チャットウィンドウを切り替え | `⌘J` | `Ctrl+J` | 開くとカーソルが入力欄に入ります。[どのページからでもチャットする](/chat#どのページからでもチャットする)を参照。 |+| Multica に質問 | `⇧⌘J` | `Ctrl+Shift+J` | フローティングチャットで新しいチャットを始めます。 || タスク内を検索 | `⌘F` | `Ctrl+F` | 後述。 || 通知をアーカイブ | `E` | `E` | インボックスで開いている通知をアーカイブします。アーカイブ表示中はアーカイブを解除します。 || 送信 | `⌘↵` | `Ctrl+Enter` | コメントやチャットのメッセージを送信します。新しいタスクの作成にも使います。 |diff --git a/apps/docs/content/docs/shortcuts.ko.mdx b/apps/docs/content/docs/shortcuts.ko.mdxindex ec771e871b..c0db7fd111 100644--- a/apps/docs/content/docs/shortcuts.ko.mdx+++ b/apps/docs/content/docs/shortcuts.ko.mdx@@ -33,6 +33,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";| 왼쪽 사이드바 전환 | `⌘B` | `Ctrl+B` | || 오른쪽 사이드바 전환 | `⌘/` | `Ctrl+/` | 태스크 상세처럼 오른쪽 사이드바가 있는 페이지에서만 쓸 수 있습니다. || 채팅 창 전환 | `⌘J` | `Ctrl+J` | 열면 커서가 메시지 입력란에 놓입니다. [어느 페이지에서나 채팅하기](/chat#어느-페이지에서나-채팅하기)를 참고하세요. |+| Multica에 묻기 | `⇧⌘J` | `Ctrl+Shift+J` | 플로팅 채팅 창에서 새 채팅을 시작합니다. || 태스크에서 찾기 | `⌘F` | `Ctrl+F` | 아래 설명 참고. || 알림 보관 | `E` | `E` | 인박스에서 열어 둔 알림을 보관합니다. 보관함을 보는 중에는 보관을 해제합니다. || 보내기 | `⌘↵` | `Ctrl+Enter` | 댓글과 채팅 메시지를 보내고, 새 태스크를 만들 때도 씁니다. |diff --git a/apps/docs/content/docs/shortcuts.mdx b/apps/docs/content/docs/shortcuts.mdxindex 3c1476c95d..d396146ff8 100644--- a/apps/docs/content/docs/shortcuts.mdx+++ b/apps/docs/content/docs/shortcuts.mdx@@ -33,6 +33,7 @@ Selecting a result opens it. Hold `⌘` (`Ctrl` on Windows and Linux) while clic| Toggle left sidebar | `⌘B` | `Ctrl+B` | || Toggle right sidebar | `⌘/` | `Ctrl+/` | Only on pages with a right sidebar, such as an issue. || Toggle chat window | `⌘J` | `Ctrl+J` | Opening it puts the cursor in the message input. See [Chat from any page](/chat#chat-from-any-page). |+| Ask Multica | `⇧⌘J` | `Ctrl+Shift+J` | Starts a new chat in the floating window. || Find in issue | `⌘F` | `Ctrl+F` | See below. || Archive notification | `E` | `E` | Archives the open inbox notification, or restores it while you're reading the archive. || Send | `⌘↵` | `Ctrl+Enter` | Sends comments and chat messages, and also submits new issues. |diff --git a/apps/docs/content/docs/shortcuts.zh-Hant.mdx b/apps/docs/content/docs/shortcuts.zh-Hant.mdxindex 109485812d..879cc6a886 100644--- a/apps/docs/content/docs/shortcuts.zh-Hant.mdx+++ b/apps/docs/content/docs/shortcuts.zh-Hant.mdx@@ -33,6 +33,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";| 顯示或隱藏左側邊欄 | `⌘B` | `Ctrl+B` | || 顯示或隱藏右側邊欄 | `⌘/` | `Ctrl+/` | 只在有右側欄的頁面可用,例如任務詳情。 || 顯示或隱藏聊天窗 | `⌘J` | `Ctrl+J` | 開啟時游標落在輸入框裡。見[懸浮聊天窗](/chat#在任意頁面開啟懸浮聊天窗)。 |+| 問 Multica | `⇧⌘J` | `Ctrl+Shift+J` | 在懸浮聊天窗裡開始新對話。 || 在任務中查詢 | `⌘F` | `Ctrl+F` | 見下文。 || 歸檔通知 | `E` | `E` | 歸檔收件箱裡當前開啟的通知;檢視已歸檔時則取消歸檔。 || 傳送 | `⌘↵` | `Ctrl+Enter` | 傳送評論和聊天訊息,也用於提交新任務。 |diff --git a/apps/docs/content/docs/shortcuts.zh.mdx b/apps/docs/content/docs/shortcuts.zh.mdxindex 188ed585d2..20d3a24bac 100644--- a/apps/docs/content/docs/shortcuts.zh.mdx+++ b/apps/docs/content/docs/shortcuts.zh.mdx@@ -33,6 +33,7 @@ import { Step, Steps } from "fumadocs-ui/components/steps";| 显示或隐藏左侧边栏 | `⌘B` | `Ctrl+B` | || 显示或隐藏右侧边栏 | `⌘/` | `Ctrl+/` | 只在有右侧栏的页面可用,例如任务详情。 || 显示或隐藏聊天窗 | `⌘J` | `Ctrl+J` | 打开时光标落在输入框里。见[悬浮聊天窗](/chat#在任意页面打开悬浮聊天窗)。 |+| 问 Multica | `⇧⌘J` | `Ctrl+Shift+J` | 在悬浮聊天窗里开始新对话。 || 在任务中查找 | `⌘F` | `Ctrl+F` | 见下文。 || 归档通知 | `E` | `E` | 归档收件箱里当前打开的通知;查看已归档时则取消归档。 || 发送 | `⌘↵` | `Ctrl+Enter` | 发送评论和聊天消息,也用于提交新任务。 |diff --git a/packages/core/chat/store.test.ts b/packages/core/chat/store.test.tsindex 3a169b0e25..8b6f55ad51 100644--- a/packages/core/chat/store.test.ts+++ b/packages/core/chat/store.test.ts@@ -324,6 +324,35 @@ describe("chat store — Ask Multica agent", () => {store.getState().setQuickChatAgentId(null);expect(createChatStore({ storage }).getState().quickChatAgentId).toBeNull();});++ it("starts a new chat with that agent and no project, and asks for composer focus", () => {+ const store = createChatStore({ storage: memStorage() });+ const s = () => store.getState();+ s().setSelectedAgentId("agent-1");+ s().setSelectedProjectId("project-1");+ s().setActiveSession("session-1");+ s().setQuickChatAgentId("agent-9");++ s().startNewChat();++ expect(s().isOpen).toBe(true);+ expect(s().activeSessionId).toBeNull();+ expect(s().selectedProjectId).toBeNull();+ expect(s().selectedAgentId).toBe("agent-9");+ expect(s().newChatRequest).toBe(1);++ s().startNewChat();+ expect(s().newChatRequest).toBe(2);+ });++ it("starts the new chat with the current agent when none is set", () => {+ const store = createChatStore({ storage: memStorage() });+ store.getState().setSelectedAgentId("agent-1");++ store.getState().startNewChat();++ expect(store.getState().selectedAgentId).toBe("agent-1");+ });});// The ledger is what makes a durable draft restore (#5219) apply at most once.diff --git a/packages/core/chat/store.ts b/packages/core/chat/store.tsindex 350ffdf03b..0fb4ce83c4 100644--- a/packages/core/chat/store.ts+++ b/packages/core/chat/store.ts@@ -361,6 +361,8 @@ export interface ChatState {selectedProjectId: string | null;/** Settings preference: the agent Ask Multica starts a new chat with. */quickChatAgentId: string | null;+ /** Bumped by `startNewChat`; the window focuses its composer on each bump. */+ newChatRequest: number;/** Chats kept as chips in the bottom bar, newest first. */chatBarKept: string[];/** Chips closed from the bar: sessionId → the chat's activity at that moment. */@@ -385,6 +387,8 @@ export interface ChatState {setSelectedAgentId: (id: string) => void;setSelectedProjectId: (id: string | null) => void;setQuickChatAgentId: (id: string | null) => void;+ /** Ask Multica: open the window on a new chat with the quick-chat agent and no project. */+ startNewChat: () => void;/** Give a chat a chip in the bottom bar. No-op when it already has one. */keepChatInBar: (sessionId: string) => void;/** Close a chat's chip until the chat moves past `activity`. */@@ -458,6 +462,7 @@ export function createChatStore(options: ChatStoreOptions) {selectedAgentId: initialAgentId,selectedProjectId: storage.getItem(wsKey(PROJECT_STORAGE_KEY)),quickChatAgentId: storage.getItem(wsKey(QUICK_CHAT_AGENT_KEY)),+ newChatRequest: 0,chatBarKept: initialChatBar.kept,chatBarDismissed: initialChatBar.dismissed,inputDrafts: initialDraftSlots.inputDrafts,@@ -512,6 +517,15 @@ export function createChatStore(options: ChatStoreOptions) {else storage.removeItem(wsKey(QUICK_CHAT_AGENT_KEY));set({ quickChatAgentId: id });},+ startNewChat: () => {+ const { quickChatAgentId, setSelectedAgentId, setSelectedProjectId, setActiveSession, setOpen } =+ get();+ if (quickChatAgentId) setSelectedAgentId(quickChatAgentId);+ setSelectedProjectId(null);+ setActiveSession(null);+ setOpen(true);+ set((state) => ({ newChatRequest: state.newChatRequest + 1 }));+ },keepChatInBar: (sessionId) => {const { chatBarKept, chatBarDismissed } = get();const wasDismissed = sessionId in chatBarDismissed;diff --git a/packages/core/shortcuts/definitions.test.ts b/packages/core/shortcuts/definitions.test.tsindex 3147381308..d5ec51a20a 100644--- a/packages/core/shortcuts/definitions.test.ts+++ b/packages/core/shortcuts/definitions.test.ts@@ -98,6 +98,23 @@ describe("keyboard shortcut definitions", () => {expect(action.allowInEditable).toBe(true);});+ it("keeps the new-chat shortcut usable on every platform and runtime", () => {+ const action = SHORTCUT_ACTION_BY_ID.newChat;+ const chord = createShortcutChord("J", { primary: true, shift: true });+ expect(action.defaultShortcut).toEqual(chord);+ for (const platform of ["macos", "windows", "linux"] as const) {+ for (const runtime of ["web", "desktop"] as const) {+ expect(+ isShortcutAllowedForAction("newChat", chord, platform, runtime),+ `Mod+Shift+J must stay assignable on ${platform}/${runtime}`,+ ).toBe(true);+ }+ }+ expect(action.allowInEditable).toBe(true);+ expect(shortcutMatchesEvent(chord, keyEvent("J", { metaKey: true, shiftKey: true }), "macos")).toBe(true);+ expect(shortcutMatchesEvent(chord, keyEvent("j", { metaKey: true }), "macos")).toBe(false);+ });+it("keeps the plain inbox archive key out of editable controls", () => {expect(SHORTCUT_ACTION_BY_ID.archiveInboxItem.allowInEditable).toBe(false);});diff --git a/packages/core/shortcuts/definitions.ts b/packages/core/shortcuts/definitions.tsindex b599719c06..49111949a6 100644--- a/packages/core/shortcuts/definitions.ts+++ b/packages/core/shortcuts/definitions.ts@@ -11,6 +11,7 @@ export type ShortcutActionId =| "toggleSidebar"| "toggleRightSidebar"| "toggleChat"+ | "newChat"| "findInIssue"| "archiveInboxItem"| "send"@@ -93,6 +94,14 @@ export const SHORTCUT_ACTIONS: readonly ShortcutActionDefinition[] = [// the binding is reaching — and dismissing — chat without a mouse, which has// to keep working while the caret sits in the chat composer itself.{ id: "toggleChat", category: "general", defaultShortcut: primary("J"), allowInEditable: true },+ // Ask Multica from the keyboard: Shift on the chat toggle, so the two chat+ // chords sit together. Shift+J is outside every reserved set, as is Mod+J.+ {+ id: "newChat",+ category: "general",+ defaultShortcut: createShortcutChord("J", { primary: true, shift: true }),+ allowInEditable: true,+ },{ id: "findInIssue", category: "general", defaultShortcut: primary("F"), allowInEditable: true },{id: "archiveInboxItem",diff --git a/packages/views/chat/components/chat-bar.test.tsx b/packages/views/chat/components/chat-bar.test.tsxindex c537675ffe..3f42134682 100644--- a/packages/views/chat/components/chat-bar.test.tsx+++ b/packages/views/chat/components/chat-bar.test.tsx@@ -14,13 +14,12 @@ const h = vi.hoisted(() => ({isOpen: false,activeSessionId: null as string | null,selectedAgentId: "agent-1" as string | null,- quickChatAgentId: null as string | null,chatBarKept: [] as string[],chatBarDismissed: {} as Record<string, string>,setOpen: vi.fn(),setActiveSession: vi.fn(),setSelectedAgentId: vi.fn(),- setSelectedProjectId: vi.fn(),+ startNewChat: vi.fn(),keepChatInBar: vi.fn(),dismissChatFromBar: vi.fn(),},@@ -95,7 +94,6 @@ beforeEach(() => {h.chat.isOpen = false;h.chat.activeSessionId = null;h.chat.selectedAgentId = "agent-1";- h.chat.quickChatAgentId = null;h.chat.chatBarKept = [];h.chat.chatBarDismissed = {};});@@ -195,20 +193,8 @@ describe("ChatBar", () => {expect(ask).toHaveAttribute("aria-pressed", "false");fireEvent.click(ask);- expect(h.chat.setActiveSession).toHaveBeenCalledWith(null);- expect(h.chat.setSelectedProjectId).toHaveBeenCalledWith(null);- expect(h.chat.setOpen).toHaveBeenCalledWith(true);- expect(h.chat.setSelectedAgentId).not.toHaveBeenCalled();- });-- it("starts the new chat with the agent set in Settings", () => {- h.chat.quickChatAgentId = "agent-9";- renderBar(SESSIONS);-- fireEvent.click(screen.getByRole("button", { name: "Ask Multica" }));-- expect(h.chat.setSelectedAgentId).toHaveBeenCalledWith("agent-9");- expect(h.chat.setActiveSession).toHaveBeenCalledWith(null);+ expect(h.chat.startNewChat).toHaveBeenCalledTimes(1);+ expect(h.chat.setOpen).not.toHaveBeenCalled();});it("closes the window from Ask Multica while it shows the new chat", () => {@@ -221,7 +207,7 @@ describe("ChatBar", () => {fireEvent.click(ask);expect(h.chat.setOpen).toHaveBeenCalledWith(false);- expect(h.chat.setActiveSession).not.toHaveBeenCalled();+ expect(h.chat.startNewChat).not.toHaveBeenCalled();});it("opens a chat from the history, grouped by when it last moved", async () => {diff --git a/packages/views/chat/components/chat-bar.tsx b/packages/views/chat/components/chat-bar.tsxindex b1b616a495..b7874af817 100644--- a/packages/views/chat/components/chat-bar.tsx+++ b/packages/views/chat/components/chat-bar.tsx@@ -16,6 +16,7 @@ import {} from "@multica/ui/components/ui/dropdown-menu";import { STAR_STROKE, starPath } from "@multica/ui/lib/multica-brand";import { cn } from "@multica/ui/lib/utils";+import { ActionShortcutKeycaps } from "../../common/shortcut-keycaps";import { useT } from "../../i18n";import { BOTTOM_BAR_ITEM_CLASS } from "../../layout/bottom-bar-styles";import { ChatBarHistory } from "./chat-bar-history";@@ -92,13 +93,12 @@ export function ChatBar() {const isOpen = useChatStore((s) => s.isOpen);const activeSessionId = useChatStore((s) => s.activeSessionId);const selectedAgentId = useChatStore((s) => s.selectedAgentId);- const quickChatAgentId = useChatStore((s) => s.quickChatAgentId);const kept = useChatStore((s) => s.chatBarKept);const dismissed = useChatStore((s) => s.chatBarDismissed);const setOpen = useChatStore((s) => s.setOpen);const setActiveSession = useChatStore((s) => s.setActiveSession);const setSelectedAgentId = useChatStore((s) => s.setSelectedAgentId);- const setSelectedProjectId = useChatStore((s) => s.setSelectedProjectId);+ const startNewChat = useChatStore((s) => s.startNewChat);const keepChatInBar = useChatStore((s) => s.keepChatInBar);const dismissChatFromBar = useChatStore((s) => s.dismissChatFromBar);const rootRef = useRef<HTMLDivElement>(null);@@ -149,14 +149,8 @@ export function ChatBar() {};const askMultica = () => {- if (askPressed) {- setOpen(false);- return;- }- if (quickChatAgentId) setSelectedAgentId(quickChatAgentId);- setSelectedProjectId(null);- setActiveSession(null);- setOpen(true);+ if (askPressed) setOpen(false);+ else startNewChat();};const titleOf = (session: ChatSession) => session.title || t(($) => $.window.untitled);@@ -227,7 +221,10 @@ export function ChatBar() {{(visible.length > 0 || overflow.length > 0) && (<span aria-hidden className="mx-1.5 h-3.5 w-px shrink-0 bg-surface-border" />)}- <TooltipHint label={t(($) => $.window.new_chat_tooltip)}>+ <TooltipHint+ label={t(($) => $.window.new_chat_tooltip)}+ shortcut={<ActionShortcutKeycaps action="newChat" />}+ ><buttontype="button"data-chat-anchor="new"diff --git a/packages/views/chat/components/chat-window.tsx b/packages/views/chat/components/chat-window.tsxindex 6aeaf1220a..70771628ed 100644--- a/packages/views/chat/components/chat-window.tsx+++ b/packages/views/chat/components/chat-window.tsx@@ -93,11 +93,12 @@ export function ChatWindow() {// Toast when an accepted refresh later fails in the daemon (async half).useQuickActionsFailureToast(activeSessionId ?? null);- // The window adds its own focus moment — opening it — on top of the- // controller's new-chat nonce. Both counters only grow, so their sum changes- // whenever either one does.+ // The window adds its own focus moments — opening it, and Ask Multica starting+ // a new chat — on top of the controller's new-chat nonce. Both counters only+ // grow, so their sum changes whenever either one does.const windowRef = useRef<HTMLDivElement>(null);- const { focusRequest: openFocusRequest } = useChatInputFocus(isOpen, windowRef);+ const newChatRequest = useChatStore((s) => s.newChatRequest);+ const { focusRequest: openFocusRequest } = useChatInputFocus(isOpen, windowRef, newChatRequest);const focusRequest = c.focusInputRequest + openFocusRequest;const annotations = useChatAnnotations({diff --git a/packages/views/chat/components/use-chat-input-focus.test.ts b/packages/views/chat/components/use-chat-input-focus.test.tsindex 370a1b33ba..0d407341c8 100644--- a/packages/views/chat/components/use-chat-input-focus.test.ts+++ b/packages/views/chat/components/use-chat-input-focus.test.ts@@ -56,6 +56,21 @@ describe("useChatInputFocus", () => {expect(result.current.focusRequest).toBe(2);});+ it("requests focus for each new Ask Multica chat, even in a window already open", () => {+ // Mounting with an earlier bump must not count as a new one.+ const { result, rerender } = renderHook(+ ({ request }: { request: number }) => useChatInputFocus(true, undefined, request),+ { initialProps: { request: 3 } },+ );+ expect(result.current.focusRequest).toBe(0);++ rerender({ request: 4 });+ expect(result.current.focusRequest).toBe(1);++ rerender({ request: 4 });+ expect(result.current.focusRequest).toBe(1);+ });+it("releases the hidden composer's focus when the window closes", () => {const { root, editor } = makeWindow();const windowRef = { current: root };diff --git a/packages/views/chat/components/use-chat-input-focus.ts b/packages/views/chat/components/use-chat-input-focus.tsindex fe11c7e7e5..ea5eec06c1 100644--- a/packages/views/chat/components/use-chat-input-focus.ts+++ b/packages/views/chat/components/use-chat-input-focus.ts@@ -13,14 +13,19 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState, type RefObje* Opening the window is one of those moments (MUL-5522): the whole point of the* toggle shortcut is reaching chat without a mouse, so landing in a window you* still have to click into would defeat it — and the same courtesy applies to- * opening it from the FAB.+ * opening it from the FAB. So is Ask Multica (`newChatRequest`, bumped by the+ * store's `startNewChat`), which can start a new chat in a window already open.*- * The ref is seeded with the mount-time value so only a real closed → open- * transition focuses. ChatWindow stays mounted while closed and `isOpen` is- * restored from storage, so treating mount as an open event would let a- * persisted "open" preference steal focus from whatever page the user loaded.+ * The refs are seeded with mount-time values so only a real closed → open+ * transition or a new bump focuses. ChatWindow stays mounted while closed and+ * `isOpen` is restored from storage, so treating mount as an open event would+ * let a persisted "open" preference steal focus from whatever page the user loaded.*/-export function useChatInputFocus(isOpen: boolean, windowRef?: RefObject<HTMLElement | null>): {+export function useChatInputFocus(+ isOpen: boolean,+ windowRef?: RefObject<HTMLElement | null>,+ newChatRequest = 0,+): {focusRequest: number;requestInputFocus: () => void;} {@@ -44,5 +49,12 @@ export function useChatInputFocus(isOpen: boolean, windowRef?: RefObject<HTMLEleif (isOpen && !wasOpen) requestInputFocus();}, [isOpen, requestInputFocus]);+ const seenNewChatRequestRef = useRef(newChatRequest);+ useEffect(() => {+ if (newChatRequest === seenNewChatRequestRef.current) return;+ seenNewChatRequestRef.current = newChatRequest;+ requestInputFocus();+ }, [newChatRequest, requestInputFocus]);+return { focusRequest, requestInputFocus };}diff --git a/packages/views/layout/global-shortcuts.chat.test.tsx b/packages/views/layout/global-shortcuts.chat.test.tsxindex 5d4216caf1..c7530224e1 100644--- a/packages/views/layout/global-shortcuts.chat.test.tsx+++ b/packages/views/layout/global-shortcuts.chat.test.tsx@@ -10,7 +10,14 @@ import { GlobalShortcuts } from "./global-shortcuts";// matters is not just "the chord calls toggle", but that it stays a no-op —// without swallowing the keypress — everywhere the overlay cannot exist.const h = vi.hoisted(() => ({- chat: { floatingChatEnabled: true, toggle: vi.fn() },+ chat: {+ floatingChatEnabled: true,+ isOpen: false,+ activeSessionId: null as string | null,+ toggle: vi.fn(),+ setOpen: vi.fn(),+ startNewChat: vi.fn(),+ },navigation: { pathname: "/acme/issues", push: vi.fn() },toggleSidebar: vi.fn(),searchToggle: vi.fn(),@@ -64,11 +71,26 @@ function pressToggleChat(target: EventTarget = document): boolean {return event.defaultPrevented;}+/** Shift+Mod+J on macOS: Shift turns the logical key into "J". */+function pressNewChat(target: EventTarget = document): boolean {+ const event = new KeyboardEvent("keydown", {+ key: "J",+ metaKey: true,+ shiftKey: true,+ bubbles: true,+ cancelable: true,+ });+ target.dispatchEvent(event);+ return event.defaultPrevented;+}+beforeEach(() => {// Pin the platform: jsdom's user agent reports the host OS, so Command vs// Control would otherwise depend on where the suite runs.configureShortcutPlatform("macos");h.chat.floatingChatEnabled = true;+ h.chat.isOpen = false;+ h.chat.activeSessionId = null;h.navigation.pathname = "/acme/issues";});@@ -164,3 +186,59 @@ describe("chat toggle shortcut", () => {expect(h.chat.toggle).not.toHaveBeenCalled();});});++describe("new chat shortcut", () => {+ it("starts a new chat instead of reopening the last one", () => {+ h.chat.activeSessionId = "session-1";+ render(<GlobalShortcuts />);++ expect(pressNewChat()).toBe(true);+ expect(h.chat.startNewChat).toHaveBeenCalledTimes(1);+ expect(h.chat.toggle).not.toHaveBeenCalled();+ });++ it("switches an open window from another chat to a new one", () => {+ h.chat.isOpen = true;+ h.chat.activeSessionId = "session-1";+ render(<GlobalShortcuts />);++ expect(pressNewChat()).toBe(true);+ expect(h.chat.startNewChat).toHaveBeenCalledTimes(1);+ expect(h.chat.setOpen).not.toHaveBeenCalled();+ });++ it("closes the window while it shows the new chat, like Ask Multica", () => {+ h.chat.isOpen = true;+ h.chat.activeSessionId = null;+ render(<GlobalShortcuts />);++ expect(pressNewChat()).toBe(true);+ expect(h.chat.setOpen).toHaveBeenCalledWith(false);+ expect(h.chat.startNewChat).not.toHaveBeenCalled();+ });++ it("still fires while the caret is inside a text input", () => {+ render(<GlobalShortcuts />);+ const input = document.createElement("input");+ document.body.appendChild(input);+ input.focus();++ expect(pressNewChat(input)).toBe(true);+ expect(h.chat.startNewChat).toHaveBeenCalledTimes(1);++ input.remove();+ });++ it("leaves the chord alone where the floating window is unavailable", () => {+ h.navigation.pathname = "/acme/chat";+ const { unmount } = render(<GlobalShortcuts />);+ expect(pressNewChat()).toBe(false);+ unmount();++ h.navigation.pathname = "/acme/issues";+ h.chat.floatingChatEnabled = false;+ render(<GlobalShortcuts />);+ expect(pressNewChat()).toBe(false);+ expect(h.chat.startNewChat).not.toHaveBeenCalled();+ });+});diff --git a/packages/views/layout/global-shortcuts.tsx b/packages/views/layout/global-shortcuts.tsxindex a57d15c9ad..804b291c1c 100644--- a/packages/views/layout/global-shortcuts.tsx+++ b/packages/views/layout/global-shortcuts.tsx@@ -25,6 +25,7 @@ const GLOBAL_ACTIONS: readonly ShortcutActionId[] = ["createIssue","toggleSidebar","toggleChat",+ "newChat","goBack","goForward","goInbox",@@ -78,7 +79,7 @@ export function GlobalShortcuts() {// An unavailable overlay must not claim the chord either — returning false// from the finder leaves the keypress its outside-the-app meaning instead of// swallowing it for an action that would visibly do nothing.- const canToggleFloatingChat = () =>+ const canUseFloatingChat = () =>useChatStore.getState().floatingChatEnabled &&!isFloatingChatRouteSuppressed(navigation.pathname, chatPath);@@ -93,7 +94,9 @@ export function GlobalShortcuts() {if (!action.allowInEditable && isEditableShortcutTarget(event.target)) {return false;}- if (candidate === "toggleChat" && !canToggleFloatingChat()) return false;+ if ((candidate === "toggleChat" || candidate === "newChat") && !canUseFloatingChat()) {+ return false;+ }return shortcutMatchesEvent(getShortcut(candidate), event);});if (!actionId) return;@@ -107,6 +110,13 @@ export function GlobalShortcuts() {useChatStore.getState().toggle();return;}+ if (actionId === "newChat") {+ // Like pressing Ask Multica: a second press closes the new chat it opened.+ const chat = useChatStore.getState();+ if (chat.isOpen && chat.activeSessionId === null) chat.setOpen(false);+ else chat.startNewChat();+ return;+ }if (actionId === "toggleSidebar") {toggleNav();return;diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex 979b478a18..1ed63bb5c3 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -419,6 +419,10 @@"label": "Toggle chat window","description": "Open or close the floating chat window. Opening it focuses the message input."},+ "newChat": {+ "label": "Ask Multica",+ "description": "Start a new chat in the floating chat window."+ },"findInIssue": {"label": "Find in issue","description": "Search within the open issue detail."diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.jsonindex d1a91765b0..b3794cfb7b 100644--- a/packages/views/locales/es/settings.json+++ b/packages/views/locales/es/settings.json@@ -419,6 +419,10 @@"label": "Mostrar u ocultar la ventana de chat","description": "Abre o cierra la ventana de chat flotante. Al abrirla, el foco va al campo de mensaje."},+ "newChat": {+ "label": "Pregunta a Multica",+ "description": "Inicia un chat nuevo en la ventana de chat flotante."+ },"findInIssue": {"label": "Buscar en la tarea","description": "Busca dentro del detalle de la tarea abierta."diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.jsonindex 2c3880113f..a9d6409930 100644--- a/packages/views/locales/fr/settings.json+++ b/packages/views/locales/fr/settings.json@@ -419,6 +419,10 @@"label": "Afficher ou masquer la fenêtre de discussion","description": "Ouvrir ou fermer la fenêtre de discussion flottante. À l'ouverture, le champ de message reçoit le focus."},+ "newChat": {+ "label": "Demander à Multica",+ "description": "Démarrer une nouvelle discussion dans la fenêtre de discussion flottante."+ },"findInIssue": {"label": "Rechercher dans la tâche","description": "Rechercher dans la tâche ouverte."diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex 50228e1967..4d1ea5b72d 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -413,6 +413,10 @@"label": "チャットウィンドウを切り替え","description": "フローティングチャットを開閉します。開いたときは入力欄にフォーカスします。"},+ "newChat": {+ "label": "Multica に質問",+ "description": "フローティングチャットで新しいチャットを始めます。"+ },"findInIssue": {"label": "タスク内を検索","description": "開いているタスクの詳細を検索します。"diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex f8a5d5d89d..cbac30aafe 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -413,6 +413,10 @@"label": "채팅 창 전환","description": "플로팅 채팅 창을 열거나 닫습니다. 열면 메시지 입력란에 포커스합니다."},+ "newChat": {+ "label": "Multica에 묻기",+ "description": "플로팅 채팅 창에서 새 채팅을 시작합니다."+ },"findInIssue": {"label": "태스크에서 찾기","description": "열린 태스크 상세 내용에서 검색합니다."diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.jsonindex dc2289a86e..566116e8d0 100644--- a/packages/views/locales/ru/settings.json+++ b/packages/views/locales/ru/settings.json@@ -430,6 +430,10 @@"label": "Переключить окно чата","description": "Открыть или закрыть плавающее окно чата. При открытии фокус переходит в поле ввода сообщения."},+ "newChat": {+ "label": "Спросить Multica",+ "description": "Начать новый чат в плавающем окне чата."+ },"findInIssue": {"label": "Найти в задаче","description": "Поиск внутри открытой карточки задачи."diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex aab5b34131..f02a6e155e 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -413,6 +413,10 @@"label": "显示或隐藏聊天窗","description": "打开或关闭悬浮聊天窗,打开时自动聚焦输入框。"},+ "newChat": {+ "label": "问 Multica",+ "description": "在悬浮聊天窗里开始新对话。"+ },"findInIssue": {"label": "在任务中查找","description": "搜索当前打开的任务详情。"diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.jsonindex c07a5c9166..340b07647a 100644--- a/packages/views/locales/zh-Hant/settings.json+++ b/packages/views/locales/zh-Hant/settings.json@@ -413,6 +413,10 @@"label": "顯示或隱藏聊天窗","description": "開啟或關閉懸浮聊天窗,開啟時自動聚焦輸入框。"},+ "newChat": {+ "label": "問 Multica",+ "description": "在懸浮聊天窗裡開始新對話。"+ },"findInIssue": {"label": "在任務中查詢","description": "搜尋當前開啟的任務詳情。"