Files
multica/packages/views/chat/floating-chat-visibility.test.ts
Bohan Jiang 6be7adcb6b feat(chat): toggle the floating chat window from the keyboard (MUL-5522) (#6162)
Adds a `toggleChat` shortcut action (default Mod+J, rebindable in
Settings -> Shortcuts) so the pop-up chat window can be opened and
dismissed without a mouse, and focuses the composer whenever the window
opens so you can start typing immediately.

The shortcut deliberately does not claim the chord where the overlay
cannot exist -- on the Chat tab, or when the Settings -> Chat preference
is off -- since flipping a hidden `isOpen` would read as a dead keypress
and then surprise the user on the next navigation. That route rule now
lives in one predicate shared with the overlay itself.

Focus is requested only on a real closed -> open transition: ChatWindow
stays mounted while closed and `isOpen` is restored from storage, so
treating mount as an open event would steal focus on page load.

Co-authored-by: Bohan-J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-07-30 14:22:47 +08:00

19 lines
994 B
TypeScript

import { describe, expect, it } from "vitest";
import { isFloatingChatRouteSuppressed } from "./floating-chat-visibility";
describe("floating chat route suppression", () => {
it("suppresses the overlay on the Chat tab and its sub-routes", () => {
expect(isFloatingChatRouteSuppressed("/acme/chat", "/acme/chat")).toBe(true);
expect(isFloatingChatRouteSuppressed("/acme/chat/session-1", "/acme/chat")).toBe(true);
});
it("keeps the overlay on every other route, including prefix look-alikes", () => {
expect(isFloatingChatRouteSuppressed("/acme/issues", "/acme/chat")).toBe(false);
// A sibling route that merely starts with the same characters is not the
// Chat tab — matching on the bare prefix would hide chat from it.
expect(isFloatingChatRouteSuppressed("/acme/chatter", "/acme/chat")).toBe(false);
// Another workspace's chat tab is a different route too.
expect(isFloatingChatRouteSuppressed("/other/chat", "/acme/chat")).toBe(false);
});
});