mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
037b85bd66
Replace immersive instant-switch with animated active chrome theme sync so top tabs match terminal sessions immediately on tab click, and clamp autocomplete popups to the active pane so they stay anchored to the cursor in split workspaces. Co-authored-by: Cursor <cursoragent@cursor.com>
105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import type { Workspace } from "../types";
|
|
import { getScopedTopTabsThemeId } from "./terminalTopTabsTheme.ts";
|
|
|
|
const workspace = (sessionIds: string[], viewMode?: Workspace["viewMode"]): Workspace => ({
|
|
id: "workspace-1",
|
|
title: "Workspace",
|
|
viewMode,
|
|
focusedSessionId: sessionIds[0],
|
|
root: {
|
|
id: "split-1",
|
|
type: "split",
|
|
direction: "vertical",
|
|
children: sessionIds.map((sessionId) => ({
|
|
id: `pane-${sessionId}`,
|
|
type: "pane",
|
|
sessionId,
|
|
})),
|
|
},
|
|
});
|
|
|
|
const resolveThemeFrom = (themes: Record<string, string>) => (sessionId: string) => themes[sessionId] ?? null;
|
|
|
|
test("top tabs use the focused session theme for solo work tabs", () => {
|
|
assert.equal(
|
|
getScopedTopTabsThemeId({
|
|
activeSidePanelTab: null,
|
|
activeThemePreviewId: null,
|
|
activeWorkspace: undefined,
|
|
followAppTerminalTheme: false,
|
|
isVisible: true,
|
|
previewTargetSessionId: "s1",
|
|
previewedOrVisibleThemeId: "tokyo-night",
|
|
resolveSessionThemeId: resolveThemeFrom({ s1: "tokyo-night" }),
|
|
}),
|
|
"tokyo-night",
|
|
);
|
|
});
|
|
|
|
test("top tabs are scoped while previewing a terminal theme", () => {
|
|
assert.equal(
|
|
getScopedTopTabsThemeId({
|
|
activeSidePanelTab: "theme",
|
|
activeThemePreviewId: "catppuccin",
|
|
activeWorkspace: undefined,
|
|
followAppTerminalTheme: false,
|
|
isVisible: true,
|
|
previewTargetSessionId: "s1",
|
|
previewedOrVisibleThemeId: "catppuccin",
|
|
resolveSessionThemeId: resolveThemeFrom({ s1: "tokyo-night" }),
|
|
}),
|
|
"catppuccin",
|
|
);
|
|
});
|
|
|
|
test("top tabs avoid scoped theme for same-theme workspace splits", () => {
|
|
assert.equal(
|
|
getScopedTopTabsThemeId({
|
|
activeSidePanelTab: null,
|
|
activeThemePreviewId: null,
|
|
activeWorkspace: workspace(["s1", "s2"]),
|
|
followAppTerminalTheme: false,
|
|
isVisible: true,
|
|
previewTargetSessionId: "s1",
|
|
previewedOrVisibleThemeId: "tokyo-night",
|
|
resolveSessionThemeId: resolveThemeFrom({ s1: "tokyo-night", s2: "tokyo-night" }),
|
|
}),
|
|
null,
|
|
);
|
|
});
|
|
|
|
test("top tabs are scoped for mixed-theme workspace splits", () => {
|
|
assert.equal(
|
|
getScopedTopTabsThemeId({
|
|
activeSidePanelTab: null,
|
|
activeThemePreviewId: null,
|
|
activeWorkspace: workspace(["s1", "s2"]),
|
|
followAppTerminalTheme: false,
|
|
isVisible: true,
|
|
previewTargetSessionId: "s1",
|
|
previewedOrVisibleThemeId: "tokyo-night",
|
|
resolveSessionThemeId: resolveThemeFrom({ s1: "tokyo-night", s2: "solarized-light" }),
|
|
}),
|
|
"tokyo-night",
|
|
);
|
|
});
|
|
|
|
test("top tabs avoid scoped theme when following the application theme", () => {
|
|
assert.equal(
|
|
getScopedTopTabsThemeId({
|
|
activeSidePanelTab: null,
|
|
activeThemePreviewId: null,
|
|
activeWorkspace: workspace(["s1", "s2"]),
|
|
followAppTerminalTheme: true,
|
|
isVisible: true,
|
|
previewTargetSessionId: "s1",
|
|
previewedOrVisibleThemeId: "app-theme",
|
|
resolveSessionThemeId: resolveThemeFrom({ s1: "tokyo-night", s2: "solarized-light" }),
|
|
}),
|
|
null,
|
|
);
|
|
});
|