mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
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>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { isActiveChromeThemeResolvable, resolveActiveChromeTheme } from '../app/activeChromeTheme';
|
|
import { clearTopTabsChromeThemeVars } from '../app/topTabsChromeTheme';
|
|
import type { Host, TerminalSession, TerminalTheme, Workspace } from '../../types';
|
|
import { activeTabStore } from './activeTabStore';
|
|
import type { EditorTab } from './editorTabStore';
|
|
import type { LogView } from './logViewState';
|
|
import { syncActiveChromeTheme } from './useActiveChromeTheme';
|
|
|
|
export type ActiveChromeThemeDeps = {
|
|
accentMode: 'theme' | 'custom';
|
|
applyAppTheme: () => void;
|
|
currentTerminalTheme: TerminalTheme;
|
|
customAccent: string;
|
|
editorTabs: readonly EditorTab[];
|
|
followAppTerminalTheme: boolean;
|
|
hostById: Map<string, Host>;
|
|
logViews: readonly LogView[];
|
|
sessionById: Map<string, TerminalSession>;
|
|
themeById: Map<string, TerminalTheme>;
|
|
workspaceById: Map<string, Workspace>;
|
|
};
|
|
|
|
let depsRef: ActiveChromeThemeDeps | null = null;
|
|
|
|
export function updateActiveChromeThemeDeps(deps: ActiveChromeThemeDeps): void {
|
|
depsRef = deps;
|
|
}
|
|
|
|
export function notifyActiveChromeThemeForTab(activeTabId: string): void {
|
|
if (!depsRef || typeof document === 'undefined') return;
|
|
if (activeTabId === 'vault' || activeTabId === 'sftp') {
|
|
clearTopTabsChromeThemeVars();
|
|
}
|
|
if (!isActiveChromeThemeResolvable({ ...depsRef, activeTabId })) return;
|
|
const activeTheme = resolveActiveChromeTheme({ ...depsRef, activeTabId });
|
|
syncActiveChromeTheme(activeTheme, depsRef.applyAppTheme);
|
|
}
|
|
|
|
activeTabStore.subscribeSync(notifyActiveChromeThemeForTab);
|