fix: Project action terminal lifecycle (#3287)
* fix(terminal): make command sessions own action lifecycle * fix(ui): reconcile project action terminal state * feat(ui): show running project actions in terminal tabs * feat(ui): run project actions from linked worktrees * fix(ui): guard project action reconciliation * fix(ui): scope project action preview fallback * fix(ui): default project actions to worktrees * fix(ui): reveal project action terminals * fix(ui): retain terminal output after snapshot replay * fix(ui): restore running action terminals on revisit
This commit is contained in:
@@ -0,0 +1,405 @@
|
||||
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test';
|
||||
import React, { act } from 'react';
|
||||
import { createRoot, type Root } from 'react-dom/client';
|
||||
import { Window } from 'happy-dom';
|
||||
|
||||
import type { TerminalHandlers } from '@/lib/api/types';
|
||||
import { useTerminalStore } from '@/stores/useTerminalStore';
|
||||
|
||||
let effectiveDirectory = '/repo';
|
||||
const openContextPreviewCalls: Array<[string, string]> = [];
|
||||
const createSessionCalls: Array<{ cwd: string }> = [];
|
||||
const connectCalls: string[] = [];
|
||||
const ensureDirectoryCalls: string[] = [];
|
||||
const openContextPreview = (directory: string, url: string) => {
|
||||
openContextPreviewCalls.push([directory, url]);
|
||||
};
|
||||
const createSession = async ({ cwd }: { cwd: string }) => {
|
||||
createSessionCalls.push({ cwd });
|
||||
return { sessionId: 'unused', cols: 80, rows: 24, status: 'running' as const };
|
||||
};
|
||||
let connectBehavior: (sessionId: string, handlers: TerminalHandlers) => { close: () => void } = () => ({ close: () => undefined });
|
||||
const terminalRuntime = {
|
||||
createSession,
|
||||
sendInput: async () => undefined,
|
||||
resize: async () => undefined,
|
||||
close: async () => undefined,
|
||||
updateAppearance: async () => undefined,
|
||||
connect: (sessionId: string, handlers: TerminalHandlers) => {
|
||||
connectCalls.push(sessionId);
|
||||
return connectBehavior(sessionId, handlers);
|
||||
},
|
||||
};
|
||||
const runtimeApis = {
|
||||
runtime: { platform: 'web' as const },
|
||||
terminal: terminalRuntime,
|
||||
};
|
||||
const i18n = { t: (key: string) => key };
|
||||
|
||||
const sessionUiState = {
|
||||
currentSessionId: 'session-1',
|
||||
newSessionDraft: null,
|
||||
};
|
||||
|
||||
const useSessionUIStoreMock = <T,>(selector: (state: typeof sessionUiState) => T): T => selector(sessionUiState);
|
||||
|
||||
const uiState = {
|
||||
terminalFontSize: 14,
|
||||
terminalShell: 'zsh',
|
||||
terminalLoginShells: ['zsh'],
|
||||
showTerminalQuickKeysOnDesktop: false,
|
||||
openContextPreview,
|
||||
};
|
||||
|
||||
const useUiStoreMock = Object.assign(
|
||||
<T,>(selector: (state: typeof uiState) => T): T => selector(uiState),
|
||||
{ getState: () => uiState },
|
||||
);
|
||||
|
||||
mock.module('@/sync/session-ui-store', () => ({ useSessionUIStore: useSessionUIStoreMock }));
|
||||
mock.module('@/hooks/useEffectiveDirectory', () => ({ useEffectiveDirectory: () => effectiveDirectory }));
|
||||
mock.module('@/hooks/useRuntimeAPIs', () => ({
|
||||
useRuntimeAPIs: () => runtimeApis,
|
||||
}));
|
||||
mock.module('@/contexts/useThemeSystem', () => ({
|
||||
useThemeSystem: () => ({
|
||||
currentTheme: {
|
||||
metadata: { variant: 'dark' },
|
||||
colors: {
|
||||
surface: {
|
||||
background: '#000',
|
||||
muted: '#111',
|
||||
elevatedForeground: '#fff',
|
||||
},
|
||||
syntax: {
|
||||
base: { foreground: '#fff' },
|
||||
function: '#7dd3fc',
|
||||
keyword: '#c084fc',
|
||||
type: '#67e8f9',
|
||||
comment: '#6b7280',
|
||||
},
|
||||
interactive: {
|
||||
cursor: '#fff',
|
||||
selection: '#334155',
|
||||
selectionForeground: '#fff',
|
||||
},
|
||||
status: {
|
||||
error: '#f87171',
|
||||
success: '#4ade80',
|
||||
warning: '#fbbf24',
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
mock.module('@/hooks/useFontPreferences', () => ({ useFontPreferences: () => ({ monoFont: 'geist-mono' }) }));
|
||||
mock.module('@/lib/device', () => ({ useDeviceInfo: () => ({ isMobile: false, isTablet: false, hasTouchOnlyPointer: false }) }));
|
||||
mock.module('@/stores/useUIStore', () => ({ useUIStore: useUiStoreMock }));
|
||||
mock.module('@/stores/useInlineCommentDraftStore', () => ({ useInlineCommentDraftStore: () => ({ addDraft: () => undefined }) }));
|
||||
mock.module('@/components/terminal/TerminalViewport', () => ({
|
||||
TerminalViewport: React.forwardRef(function TerminalViewportMock(
|
||||
{ sessionKey, chunks, isVisible }: { sessionKey: string; chunks: unknown[]; isVisible: boolean },
|
||||
ref: React.ForwardedRef<{ focus: () => void; fit: () => void; getSelection: () => null }>,
|
||||
) {
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
focus: () => undefined,
|
||||
fit: () => undefined,
|
||||
getSelection: () => null,
|
||||
}), []);
|
||||
|
||||
return React.createElement('div', {
|
||||
'data-terminal-viewport': 'true',
|
||||
'data-session-key': sessionKey,
|
||||
'data-visible': String(isVisible),
|
||||
'data-chunk-count': String(chunks.length),
|
||||
});
|
||||
}),
|
||||
}));
|
||||
mock.module('@/components/icon/Icon', () => ({
|
||||
Icon: ({ name, className }: { name: string; className?: string }) => React.createElement('span', { 'data-icon': name, className }),
|
||||
}));
|
||||
mock.module('@/components/ui/sortable-tabs-strip', () => ({
|
||||
SortableTabsStrip: ({ items }: { items: Array<{ id: string; label: string; icon?: React.ReactNode }> }) => React.createElement(
|
||||
'div',
|
||||
{ 'data-tabs-strip': 'terminal' },
|
||||
items.map((item) => React.createElement(
|
||||
'div',
|
||||
{ key: item.id, 'data-tab-id': item.id },
|
||||
item.icon,
|
||||
React.createElement('span', { 'data-tab-label': item.id }, item.label),
|
||||
)),
|
||||
),
|
||||
}));
|
||||
mock.module('@/lib/i18n', () => ({ useI18n: () => i18n }));
|
||||
|
||||
const { TerminalView } = await import('./TerminalView');
|
||||
|
||||
const ensureDirectorySpy = (directory: string) => {
|
||||
ensureDirectoryCalls.push(directory);
|
||||
useTerminalStore.setState((state) => {
|
||||
if (state.sessions.get(directory)) return state;
|
||||
|
||||
const tab = {
|
||||
id: `spy-tab-${directory}`,
|
||||
terminalSessionId: null,
|
||||
lifecycle: 'idle' as const,
|
||||
purpose: { type: 'terminal' as const },
|
||||
label: 'Terminal',
|
||||
iconKey: null,
|
||||
isConnecting: false,
|
||||
createdAt: Date.now(),
|
||||
previewUrl: null,
|
||||
previewAutoOpened: false,
|
||||
previewUrlLocked: false,
|
||||
};
|
||||
|
||||
const sessions = new Map(state.sessions);
|
||||
sessions.set(directory, { tabs: [tab], activeTabId: tab.id });
|
||||
return { sessions };
|
||||
});
|
||||
};
|
||||
|
||||
const flushEffects = async () => {
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
const bufferEntryKey = (directory: string, tabId: string) => `${directory}\u0000${tabId}`;
|
||||
const readBufferContent = (directory: string, tabId: string) => useTerminalStore.getState().getBuffer(directory, tabId).chunks.map((chunk) => chunk.data).join('');
|
||||
|
||||
describe('TerminalView project action tab indicator', () => {
|
||||
let windowInstance: Window;
|
||||
let host: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
beforeEach(() => {
|
||||
effectiveDirectory = '/repo';
|
||||
openContextPreviewCalls.length = 0;
|
||||
createSessionCalls.length = 0;
|
||||
connectCalls.length = 0;
|
||||
ensureDirectoryCalls.length = 0;
|
||||
connectBehavior = () => ({ close: () => undefined });
|
||||
windowInstance = new Window({ url: 'http://localhost/' });
|
||||
Object.assign(globalThis, {
|
||||
window: windowInstance,
|
||||
document: windowInstance.document,
|
||||
navigator: windowInstance.navigator,
|
||||
HTMLElement: windowInstance.HTMLElement,
|
||||
Element: windowInstance.Element,
|
||||
Node: windowInstance.Node,
|
||||
Event: windowInstance.Event,
|
||||
KeyboardEvent: windowInstance.KeyboardEvent,
|
||||
MouseEvent: windowInstance.MouseEvent,
|
||||
ResizeObserver: class {
|
||||
observe() {}
|
||||
disconnect() {}
|
||||
},
|
||||
IS_REACT_ACT_ENVIRONMENT: true,
|
||||
});
|
||||
|
||||
host = document.createElement('div');
|
||||
document.body.appendChild(host);
|
||||
root = createRoot(host);
|
||||
|
||||
useTerminalStore.getState().clearAll();
|
||||
useTerminalStore.setState({ ensureDirectory: ensureDirectorySpy });
|
||||
useTerminalStore.getState().ensureDirectory('/repo');
|
||||
|
||||
const interactiveTabId = useTerminalStore.getState().getDirectoryState('/repo')!.tabs[0]!.id;
|
||||
useTerminalStore.getState().setTabLabel('/repo', interactiveTabId, 'Interactive');
|
||||
|
||||
const runningActionTabId = useTerminalStore.getState().createTab('/repo');
|
||||
useTerminalStore.getState().setTabLabel('/repo', runningActionTabId, 'Build');
|
||||
useTerminalStore.getState().setTabIconKey('/repo', runningActionTabId, 'build');
|
||||
useTerminalStore.getState().setTabPurpose('/repo', runningActionTabId, { type: 'project-action', actionId: 'build', executionId: 'exec-running' });
|
||||
useTerminalStore.getState().setTabLifecycle('/repo', runningActionTabId, 'running');
|
||||
|
||||
const exitedActionTabId = useTerminalStore.getState().createTab('/repo');
|
||||
useTerminalStore.getState().setTabLabel('/repo', exitedActionTabId, 'Deploy');
|
||||
useTerminalStore.getState().setTabIconKey('/repo', exitedActionTabId, 'play');
|
||||
useTerminalStore.getState().setTabPurpose('/repo', exitedActionTabId, { type: 'project-action', actionId: 'deploy', executionId: 'exec-exited' });
|
||||
useTerminalStore.getState().setTabLifecycle('/repo', exitedActionTabId, 'exited');
|
||||
ensureDirectoryCalls.length = 0;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await act(async () => root.unmount());
|
||||
useTerminalStore.getState().clearAll();
|
||||
});
|
||||
|
||||
test('shows a spinner only for active project-action tabs and keeps terminal or action icons elsewhere', async () => {
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: false }));
|
||||
});
|
||||
|
||||
const tabs = Array.from(host.querySelectorAll('[data-tab-id]'));
|
||||
expect(tabs).toHaveLength(3);
|
||||
|
||||
const interactiveTab = tabs.find((tab) => tab.querySelector('[data-tab-label]')?.textContent === 'Interactive');
|
||||
const runningActionTab = tabs.find((tab) => tab.querySelector('[data-tab-label]')?.textContent === 'Build');
|
||||
const exitedActionTab = tabs.find((tab) => tab.querySelector('[data-tab-label]')?.textContent === 'Deploy');
|
||||
|
||||
expect(interactiveTab?.querySelector('[data-icon]')?.getAttribute('data-icon')).toBe('terminal');
|
||||
expect(runningActionTab?.querySelector('[data-icon]')?.getAttribute('data-icon')).toBe('loader-4');
|
||||
expect(runningActionTab?.querySelector('[data-icon]')?.className).toContain('animate-spin');
|
||||
expect(runningActionTab?.querySelector('[data-icon]')?.className).toContain('motion-reduce:animate-none');
|
||||
expect(runningActionTab?.querySelector('[data-icon]')?.className).toContain('text-muted-foreground');
|
||||
expect(exitedActionTab?.querySelector('[data-icon]')?.getAttribute('data-icon')).toBe('play');
|
||||
expect(host.querySelectorAll('[data-icon="loader-4"]').length).toBe(1);
|
||||
});
|
||||
|
||||
test('uses the explicit terminal directory for terminal tabs and session creation while preview ownership stays on the host directory', async () => {
|
||||
effectiveDirectory = '/repo-worktree';
|
||||
useTerminalStore.getState().ensureDirectory('/repo-worktree');
|
||||
const worktreeTabId = useTerminalStore.getState().getDirectoryState('/repo-worktree')!.tabs[0]!.id;
|
||||
useTerminalStore.getState().setTabLabel('/repo-worktree', worktreeTabId, 'Worktree Terminal');
|
||||
|
||||
const repoTabId = useTerminalStore.getState().getDirectoryState('/repo')!.tabs[0]!.id;
|
||||
useTerminalStore.getState().setTabLabel('/repo', repoTabId, 'Repo Terminal');
|
||||
useTerminalStore.getState().setTabPreviewUrl('/repo', repoTabId, 'https://preview.example.test');
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true, directory: '/repo' }));
|
||||
});
|
||||
|
||||
const tabLabels = Array.from(host.querySelectorAll('[data-tab-label]')).map((node) => node.textContent);
|
||||
expect(tabLabels).toContain('Repo Terminal');
|
||||
expect(tabLabels).not.toContain('Worktree Terminal');
|
||||
expect(createSessionCalls.length).toBe(1);
|
||||
expect(createSessionCalls[0]?.cwd).toBe('/repo');
|
||||
|
||||
const previewButton = host.querySelector<HTMLElement>('[title="terminalView.preview.openTitle"]');
|
||||
expect(previewButton).not.toBeNull();
|
||||
previewButton?.click();
|
||||
expect(openContextPreviewCalls).toEqual([['/repo-worktree', 'https://preview.example.test']]);
|
||||
});
|
||||
|
||||
test('keeps the existing context-directory behavior when no explicit terminal directory is provided', async () => {
|
||||
effectiveDirectory = '/repo-worktree';
|
||||
useTerminalStore.getState().ensureDirectory('/repo-worktree');
|
||||
const worktreeTabId = useTerminalStore.getState().getDirectoryState('/repo-worktree')!.tabs[0]!.id;
|
||||
useTerminalStore.getState().setTabLabel('/repo-worktree', worktreeTabId, 'Worktree Terminal');
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true }));
|
||||
});
|
||||
|
||||
const tabLabels = Array.from(host.querySelectorAll('[data-tab-label]')).map((node) => node.textContent);
|
||||
expect(tabLabels).toContain('Worktree Terminal');
|
||||
expect(createSessionCalls.length).toBe(1);
|
||||
expect(createSessionCalls[0]?.cwd).toBe('/repo-worktree');
|
||||
});
|
||||
|
||||
test('treats an explicit terminal target with no terminal state as an inert reveal', async () => {
|
||||
effectiveDirectory = '/repo-worktree';
|
||||
useTerminalStore.getState().ensureDirectory('/repo-worktree');
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true, directory: '/missing-repo' }));
|
||||
});
|
||||
|
||||
expect(ensureDirectoryCalls).not.toContain('/missing-repo');
|
||||
expect(createSessionCalls.length).toBe(0);
|
||||
expect(host.querySelector('[data-tabs-strip="terminal"]')).toBeNull();
|
||||
expect(host.querySelector('[data-terminal-viewport="true"]')?.getAttribute('data-chunk-count')).toBe('0');
|
||||
});
|
||||
|
||||
test('includes the terminal directory in the viewport identity key', async () => {
|
||||
effectiveDirectory = '/repo-worktree';
|
||||
useTerminalStore.getState().ensureDirectory('/repo-worktree');
|
||||
|
||||
useTerminalStore.setState((state) => {
|
||||
const repoTab = state.sessions.get('/repo')!.tabs[0]!;
|
||||
const sessions = new Map(state.sessions);
|
||||
sessions.set('/repo-worktree', {
|
||||
tabs: [{ ...repoTab, label: 'Mirrored Terminal' }],
|
||||
activeTabId: repoTab.id,
|
||||
});
|
||||
return { sessions };
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true }));
|
||||
});
|
||||
const contextKey = host.querySelector('[data-terminal-viewport="true"]')!.getAttribute('data-session-key');
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true, directory: '/repo' }));
|
||||
});
|
||||
const targetKey = host.querySelector('[data-terminal-viewport="true"]')!.getAttribute('data-session-key');
|
||||
|
||||
expect(contextKey).not.toBe(targetKey);
|
||||
expect(contextKey).toContain('/repo-worktree');
|
||||
expect(targetKey).toContain('/repo');
|
||||
});
|
||||
|
||||
test('would fail if revisit attach skipped the active running project-action snapshot restore', async () => {
|
||||
const state = useTerminalStore.getState().getDirectoryState('/repo');
|
||||
const actionTab = state?.tabs.find((tab) => tab.label === 'Build');
|
||||
expect(actionTab).toBeDefined();
|
||||
if (!actionTab) throw new Error('action tab missing');
|
||||
|
||||
useTerminalStore.getState().setTabSessionId('/repo', actionTab.id, 'srv-build', { expectedExecutionId: 'exec-running' });
|
||||
useTerminalStore.getState().setActiveTab('/repo', actionTab.id);
|
||||
|
||||
const snapshotData = 'snapshot history\nfinal line\n';
|
||||
let replaceCount = 0;
|
||||
const unsubscribe = useTerminalStore.subscribe((nextState, previousState) => {
|
||||
const next = nextState.buffers.get(bufferEntryKey('/repo', actionTab.id));
|
||||
const previous = previousState.buffers.get(bufferEntryKey('/repo', actionTab.id));
|
||||
const nextContent = next?.chunks.map((chunk) => chunk.data).join('') ?? '';
|
||||
const previousContent = previous?.chunks.map((chunk) => chunk.data).join('') ?? '';
|
||||
if (nextContent === snapshotData && previousContent !== snapshotData && next?.lastSequence === 7) {
|
||||
replaceCount += 1;
|
||||
}
|
||||
});
|
||||
connectBehavior = (_sessionId, handlers) => {
|
||||
void Promise.resolve().then(() => {
|
||||
handlers.onEvent({ type: 'snapshot', data: snapshotData, sequence: 7, status: 'running' });
|
||||
});
|
||||
return { close: () => undefined };
|
||||
};
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true }));
|
||||
});
|
||||
await flushEffects();
|
||||
unsubscribe();
|
||||
|
||||
expect(connectCalls).toEqual(['srv-build']);
|
||||
expect(createSessionCalls.length).toBe(0);
|
||||
expect(readBufferContent('/repo', actionTab.id)).toBe(snapshotData);
|
||||
expect(useTerminalStore.getState().getBuffer('/repo', actionTab.id).lastSequence).toBe(7);
|
||||
expect(replaceCount).toBe(1);
|
||||
});
|
||||
|
||||
test('would fail if retained parent action targets rendered worktree tabs or attached the wrong session', async () => {
|
||||
effectiveDirectory = '/repo-worktree';
|
||||
useTerminalStore.getState().ensureDirectory('/repo-worktree');
|
||||
const worktreeTabId = useTerminalStore.getState().getDirectoryState('/repo-worktree')!.tabs[0]!.id;
|
||||
useTerminalStore.getState().setTabLabel('/repo-worktree', worktreeTabId, 'Worktree Terminal');
|
||||
|
||||
const repoState = useTerminalStore.getState().getDirectoryState('/repo');
|
||||
const repoActionTab = repoState?.tabs.find((tab) => tab.label === 'Build');
|
||||
expect(repoActionTab).toBeDefined();
|
||||
if (!repoActionTab) throw new Error('repo action tab missing');
|
||||
|
||||
useTerminalStore.getState().setTabLabel('/repo', repoActionTab.id, 'Repo Build');
|
||||
useTerminalStore.getState().setTabSessionId('/repo', repoActionTab.id, 'srv-parent-build', { expectedExecutionId: 'exec-running' });
|
||||
useTerminalStore.getState().setActiveTab('/repo', repoActionTab.id);
|
||||
|
||||
await act(async () => {
|
||||
root.render(React.createElement(TerminalView, { visible: true, directory: '/repo' }));
|
||||
});
|
||||
await flushEffects();
|
||||
|
||||
const tabLabels = Array.from(host.querySelectorAll('[data-tab-label]')).map((node) => node.textContent);
|
||||
expect(tabLabels).toContain('Repo Build');
|
||||
expect(tabLabels).toContain('Interactive');
|
||||
expect(tabLabels).not.toContain('Worktree Terminal');
|
||||
expect(connectCalls).toEqual(['srv-parent-build']);
|
||||
expect(createSessionCalls.length).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
import { EMPTY_TERMINAL_BUFFER, useTerminalStore } from '@/stores/useTerminalStore';
|
||||
import { ACTIVE_PROJECT_ACTION_LIFECYCLES, EMPTY_TERMINAL_BUFFER, useTerminalStore } from '@/stores/useTerminalStore';
|
||||
import { useEffectiveDirectory } from '@/hooks/useEffectiveDirectory';
|
||||
import { type TerminalStreamEvent } from '@/lib/api/types';
|
||||
import { useThemeSystem } from '@/contexts/useThemeSystem';
|
||||
@@ -14,22 +14,29 @@ import { useUIStore } from '@/stores/useUIStore';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SortableTabsStrip } from '@/components/ui/sortable-tabs-strip';
|
||||
import { Icon } from "@/components/icon/Icon";
|
||||
import type { IconName } from '@/components/icon/icons';
|
||||
import { useDeviceInfo } from '@/lib/device';
|
||||
import { useRuntimeAPIs } from '@/hooks/useRuntimeAPIs';
|
||||
import { extractTerminalPreviewUrl, isTerminalPreviewUrlAvailable } from '@/lib/terminalPreview';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { PROJECT_ACTION_ICON_MAP, type ProjectActionIconKey } from '@/lib/projectActions';
|
||||
import { PROJECT_ACTION_ICONS } from '@/lib/projectActions';
|
||||
import { useInlineCommentDraftStore } from '@/stores/useInlineCommentDraftStore';
|
||||
import { applyTerminalModifier, terminalControlCharacter, terminalSequenceForKey, type TerminalModifier as Modifier, type TerminalQuickKey as MobileKey } from '@/lib/terminalInput';
|
||||
import { formatShortcutForDisplay } from '@/lib/shortcuts';
|
||||
import { reconcileTerminalSessionAuthority } from '@/lib/projectActionTerminal';
|
||||
|
||||
type TerminalViewProps = {
|
||||
visible?: boolean;
|
||||
directory?: string | null;
|
||||
};
|
||||
|
||||
const FALLBACK_TERMINAL_SIZE = { cols: 80, rows: 24 } as const;
|
||||
const resolveTabIconName = (iconKey: string | null): IconName => {
|
||||
const matchedIcon = PROJECT_ACTION_ICONS.find((entry) => entry.key === iconKey);
|
||||
return matchedIcon?.Icon ?? 'terminal';
|
||||
};
|
||||
|
||||
export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
export const TerminalView: React.FC<TerminalViewProps> = ({ visible, directory }) => {
|
||||
const { t } = useI18n();
|
||||
const { terminal, runtime } = useRuntimeAPIs();
|
||||
const { currentTheme } = useThemeSystem();
|
||||
@@ -51,15 +58,19 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
const newSessionDraft = useSessionUIStore((s) => s.newSessionDraft);
|
||||
const hasActiveContext = currentSessionId !== null || newSessionDraft?.open === true;
|
||||
|
||||
const effectiveDirectory = useEffectiveDirectory() ?? null;
|
||||
const directoryTerminalState = useTerminalStore((s) => effectiveDirectory ? s.sessions.get(effectiveDirectory) : undefined);
|
||||
const contextDirectory = useEffectiveDirectory() ?? null;
|
||||
const targetDirectory = directory ?? null;
|
||||
const terminalDirectory = targetDirectory || contextDirectory;
|
||||
const hasExplicitTerminalTarget = targetDirectory !== null;
|
||||
const directoryTerminalState = useTerminalStore((s) => terminalDirectory ? s.sessions.get(terminalDirectory) : undefined);
|
||||
const terminalHydrated = useTerminalStore((s) => s.hasHydrated);
|
||||
const ensureDirectory = useTerminalStore((s) => s.ensureDirectory);
|
||||
const createTab = useTerminalStore((s) => s.createTab);
|
||||
const setActiveTab = useTerminalStore((s) => s.setActiveTab);
|
||||
const closeTab = useTerminalStore((s) => s.closeTab);
|
||||
const setTabSessionId = useTerminalStore((s) => s.setTabSessionId);
|
||||
const adoptServerSessions = useTerminalStore((s) => s.adoptServerSessions);
|
||||
const reconcileServerSessions = useTerminalStore((s) => s.reconcileServerSessions);
|
||||
const captureStartedActionMutationRevisions = useTerminalStore((s) => s.captureStartedActionMutationRevisions);
|
||||
const setTabLifecycle = useTerminalStore((s) => s.setTabLifecycle);
|
||||
const setConnecting = useTerminalStore((s) => s.setConnecting);
|
||||
const appendToBuffer = useTerminalStore((s) => s.appendToBuffer);
|
||||
@@ -89,8 +100,20 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
const terminalTabItems = React.useMemo(() => {
|
||||
return (directoryTerminalState?.tabs ?? []).map((tab) => ({
|
||||
icon: (() => {
|
||||
const tabIconName = tab.iconKey ? PROJECT_ACTION_ICON_MAP[tab.iconKey as ProjectActionIconKey] ?? 'terminal' : 'terminal';
|
||||
return <Icon name={tabIconName} className="h-4 w-4" />;
|
||||
const showProjectActionSpinner = tab.purpose.type === 'project-action'
|
||||
&& ACTIVE_PROJECT_ACTION_LIFECYCLES.has(tab.lifecycle);
|
||||
const tabIconName = showProjectActionSpinner
|
||||
? 'loader-4'
|
||||
: resolveTabIconName(tab.iconKey);
|
||||
return (
|
||||
<Icon
|
||||
name={tabIconName}
|
||||
className={cn(
|
||||
'h-4 w-4',
|
||||
showProjectActionSpinner && 'animate-spin text-muted-foreground motion-reduce:animate-none'
|
||||
)}
|
||||
/>
|
||||
);
|
||||
})(),
|
||||
id: tab.id,
|
||||
label: tab.label,
|
||||
@@ -101,9 +124,10 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
|
||||
const terminalSessionId = activeTab?.terminalSessionId ?? null;
|
||||
const terminalLifecycle = activeTab?.lifecycle ?? 'idle';
|
||||
const isActionTab = activeTab?.purpose.type === 'project-action';
|
||||
// Scrollback is a leaf subscription: streaming output must not rerender the tab strip.
|
||||
const bufferChunks = useTerminalStore((s) => (
|
||||
effectiveDirectory && activeTabId ? s.getBuffer(effectiveDirectory, activeTabId).chunks : EMPTY_TERMINAL_BUFFER.chunks
|
||||
terminalDirectory && activeTabId ? s.getBuffer(terminalDirectory, activeTabId).chunks : EMPTY_TERMINAL_BUFFER.chunks
|
||||
));
|
||||
const isConnecting = activeTab?.isConnecting ?? false;
|
||||
const previewUrl = activeTab?.previewUrl ?? null;
|
||||
@@ -118,7 +142,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
const activeTerminalIdRef = React.useRef<string | null>(null);
|
||||
const activeTabIdRef = React.useRef<string | null>(activeTabId);
|
||||
const terminalIdRef = React.useRef<string | null>(terminalSessionId);
|
||||
const directoryRef = React.useRef<string | null>(effectiveDirectory);
|
||||
const directoryRef = React.useRef<string | null>(terminalDirectory);
|
||||
const terminalControllerRef = React.useRef<TerminalController | null>(null);
|
||||
const lastViewportSizeRef = React.useRef<{ cols: number; rows: number } | null>(null);
|
||||
const pendingTerminalCreatesRef = React.useRef(new Set<string>());
|
||||
@@ -173,52 +197,32 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
}, [activeTabId, resetTerminalPreviewScan]);
|
||||
|
||||
React.useEffect(() => {
|
||||
directoryRef.current = effectiveDirectory;
|
||||
}, [effectiveDirectory]);
|
||||
directoryRef.current = terminalDirectory;
|
||||
}, [terminalDirectory]);
|
||||
|
||||
// The tab list is a per-client projection, so ask the server what actually
|
||||
// exists for this directory and adopt sessions no local tab references
|
||||
// (another device, a fresh browser tab, or a reload with cleared storage).
|
||||
// A failed listing changes nothing: adoption is additive only.
|
||||
React.useEffect(() => {
|
||||
if (!terminalHydrated || !effectiveDirectory || !terminal.listSessions) {
|
||||
if (!terminalHydrated || !terminalDirectory || !terminal.listSessions) {
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
const directory = effectiveDirectory;
|
||||
void terminal.listSessions(directory)
|
||||
.then((serverSessions) => {
|
||||
if (cancelled || directoryRef.current !== directory) return;
|
||||
adoptServerSessions(directory, serverSessions);
|
||||
})
|
||||
.catch(() => { /* keep local tabs; the next mount or directory switch retries */ });
|
||||
const directory = terminalDirectory;
|
||||
void reconcileTerminalSessionAuthority(terminal, directory, {
|
||||
captureStartedActionMutationRevisions,
|
||||
})
|
||||
.then((result) => {
|
||||
if (cancelled || directoryRef.current !== directory || !result) return;
|
||||
reconcileServerSessions(directory, result.sessions, {
|
||||
startedActionMutationRevisions: result.startedActionMutationRevisions,
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [terminalHydrated, effectiveDirectory, terminal, adoptServerSessions]);
|
||||
|
||||
// The server reaps terminals with no attached socket after an idle timeout,
|
||||
// but only the active tab holds an attachment. While this client is open,
|
||||
// periodically mark every session its tabs reference as active so
|
||||
// background tabs (and other directories' terminals) are not reaped.
|
||||
React.useEffect(() => {
|
||||
if (!terminal.touchSessions) {
|
||||
return;
|
||||
}
|
||||
const touch = () => {
|
||||
if (typeof navigator !== 'undefined' && !navigator.onLine) return;
|
||||
const ids: string[] = [];
|
||||
for (const dirState of useTerminalStore.getState().sessions.values()) {
|
||||
for (const tab of dirState.tabs) {
|
||||
if (tab.terminalSessionId) ids.push(tab.terminalSessionId);
|
||||
}
|
||||
}
|
||||
if (ids.length > 0) void terminal.touchSessions?.(ids).catch(() => {});
|
||||
};
|
||||
touch();
|
||||
const interval = setInterval(touch, 10 * 60 * 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [terminal]);
|
||||
}, [captureStartedActionMutationRevisions, terminalHydrated, terminalDirectory, terminal, reconcileServerSessions]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!showQuickKeys && activeModifier !== null) {
|
||||
@@ -345,7 +349,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
const currentTab = useTerminalStore.getState()
|
||||
.getDirectoryState(directory)
|
||||
?.tabs.find((t) => t.id === tabId);
|
||||
const isActionTab = Boolean(currentTab?.label?.startsWith('Action:'));
|
||||
const isActionTab = currentTab?.purpose.type === 'project-action';
|
||||
appendToBuffer(
|
||||
directory,
|
||||
tabId,
|
||||
@@ -384,7 +388,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
setIsReconnectPending(false);
|
||||
if (error.code === 'SESSION_NOT_FOUND') {
|
||||
const currentTab = useTerminalStore.getState().getDirectoryState(directory)?.tabs.find((tab) => tab.id === tabId);
|
||||
if (!currentTab?.label?.startsWith('Action:')) {
|
||||
if (currentTab?.purpose.type !== 'project-action') {
|
||||
setConnectionError(null);
|
||||
setIsFatalError(false);
|
||||
setConnecting(directory, tabId, false);
|
||||
@@ -432,7 +436,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!effectiveDirectory) {
|
||||
if (!terminalDirectory) {
|
||||
setConnectionError(
|
||||
hasActiveContext
|
||||
? t('terminalView.empty.noWorkingDirectory')
|
||||
@@ -443,11 +447,14 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
}
|
||||
|
||||
const ensureSession = async () => {
|
||||
const directory = effectiveDirectory;
|
||||
const directory = terminalDirectory;
|
||||
if (!directoryRef.current || directoryRef.current !== directory) return;
|
||||
|
||||
const existingState = useTerminalStore.getState().getDirectoryState(directory);
|
||||
if (!existingState) {
|
||||
if (hasExplicitTerminalTarget) {
|
||||
return;
|
||||
}
|
||||
ensureDirectory(directory);
|
||||
return;
|
||||
}
|
||||
@@ -467,17 +474,14 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
const tab = state.tabs.find((t) => t.id === tabId) ?? state.tabs[0];
|
||||
const terminalId = tab?.terminalSessionId ?? null;
|
||||
const terminalLifecycle = tab?.lifecycle ?? 'idle';
|
||||
const isActionTab = Boolean(tab?.label?.startsWith('Action:'));
|
||||
const buffer = useTerminalStore.getState().getBuffer(directory, tabId);
|
||||
const hasBufferedOutput = buffer.byteLength > 0 || buffer.chunks.length > 0;
|
||||
|
||||
const tabIsActionTab = tab?.purpose.type === 'project-action';
|
||||
if (!terminalId) {
|
||||
if (terminalLifecycle === 'exited') {
|
||||
setConnecting(directory, tabId, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isActionTab && hasBufferedOutput) {
|
||||
if (tabIsActionTab) {
|
||||
setConnecting(directory, tabId, false);
|
||||
return;
|
||||
}
|
||||
@@ -574,7 +578,8 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
};
|
||||
}, [
|
||||
hasActiveContext,
|
||||
effectiveDirectory,
|
||||
terminalDirectory,
|
||||
hasExplicitTerminalTarget,
|
||||
terminalSessionId,
|
||||
terminalLifecycle,
|
||||
activeTabId,
|
||||
@@ -613,10 +618,11 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
}, [activeTabId, focusTerminalWhenWindowActive, isTerminalVisible, useTouchTerminalInput]);
|
||||
|
||||
const handleRestart = React.useCallback(async () => {
|
||||
if (!effectiveDirectory) return;
|
||||
if (!terminalDirectory) return;
|
||||
if (isRestarting) return;
|
||||
if (isActionTab) return;
|
||||
|
||||
const state = useTerminalStore.getState().getDirectoryState(effectiveDirectory);
|
||||
const state = useTerminalStore.getState().getDirectoryState(terminalDirectory);
|
||||
const tabId = enableTabs
|
||||
? (activeTabId ?? state?.activeTabId ?? state?.tabs[0]?.id ?? null)
|
||||
: (state?.tabs[0]?.id ?? null);
|
||||
@@ -634,19 +640,19 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
|
||||
try {
|
||||
const size = lastViewportSizeRef.current ?? FALLBACK_TERMINAL_SIZE;
|
||||
const restarted = await terminal.restartSession(originalSessionId, { cwd: effectiveDirectory, shell: terminalShell, loginShell: terminalLoginShell, ...size, ...terminalAppearanceRef.current });
|
||||
const owningTab = useTerminalStore.getState().getDirectoryState(effectiveDirectory)?.tabs.find((tab) => tab.id === tabId);
|
||||
const restarted = await terminal.restartSession(originalSessionId, { cwd: terminalDirectory, shell: terminalShell, loginShell: terminalLoginShell, ...size, ...terminalAppearanceRef.current });
|
||||
const owningTab = useTerminalStore.getState().getDirectoryState(terminalDirectory)?.tabs.find((tab) => tab.id === tabId);
|
||||
if (owningTab?.terminalSessionId !== originalSessionId) return;
|
||||
setTabSessionId(effectiveDirectory, tabId, restarted.sessionId);
|
||||
setTabLifecycle(effectiveDirectory, tabId, 'running');
|
||||
if (directoryRef.current !== effectiveDirectory || activeTabIdRef.current !== tabId) return;
|
||||
setTabSessionId(terminalDirectory, tabId, restarted.sessionId);
|
||||
setTabLifecycle(terminalDirectory, tabId, 'running');
|
||||
if (directoryRef.current !== terminalDirectory || activeTabIdRef.current !== tabId) return;
|
||||
terminalIdRef.current = restarted.sessionId;
|
||||
startStream(effectiveDirectory, tabId, restarted.sessionId);
|
||||
startStream(terminalDirectory, tabId, restarted.sessionId);
|
||||
} catch (error) {
|
||||
const owningTab = useTerminalStore.getState().getDirectoryState(effectiveDirectory)?.tabs.find((tab) => tab.id === tabId);
|
||||
const owningTab = useTerminalStore.getState().getDirectoryState(terminalDirectory)?.tabs.find((tab) => tab.id === tabId);
|
||||
if (
|
||||
owningTab?.terminalSessionId !== originalSessionId
|
||||
|| directoryRef.current !== effectiveDirectory
|
||||
|| directoryRef.current !== terminalDirectory
|
||||
|| activeTabIdRef.current !== tabId
|
||||
) return;
|
||||
setConnectionError(
|
||||
@@ -655,11 +661,11 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
setIsFatalError(false);
|
||||
setIsReconnectPending(false);
|
||||
terminalIdRef.current = originalSessionId;
|
||||
startStream(effectiveDirectory, tabId, originalSessionId);
|
||||
startStream(terminalDirectory, tabId, originalSessionId);
|
||||
} finally {
|
||||
setIsRestarting(false);
|
||||
}
|
||||
}, [activeTabId, disconnectStream, effectiveDirectory, enableTabs, isRestarting, resetTerminalPreviewScan, setTabLifecycle, setTabSessionId, startStream, t, terminal, terminalLoginShell, terminalShell]);
|
||||
}, [activeTabId, disconnectStream, terminalDirectory, enableTabs, isActionTab, isRestarting, resetTerminalPreviewScan, setTabLifecycle, setTabSessionId, startStream, t, terminal, terminalLoginShell, terminalShell]);
|
||||
|
||||
const handleHardRestart = React.useCallback(async () => {
|
||||
// Keep semantics: “close tab -> new clean tab”.
|
||||
@@ -667,20 +673,20 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
}, [handleRestart]);
|
||||
|
||||
const handleCreateTab = React.useCallback(() => {
|
||||
if (!effectiveDirectory) return;
|
||||
const tabId = createTab(effectiveDirectory);
|
||||
setActiveTab(effectiveDirectory, tabId);
|
||||
if (!terminalDirectory) return;
|
||||
const tabId = createTab(terminalDirectory);
|
||||
setActiveTab(terminalDirectory, tabId);
|
||||
setConnectionError(null);
|
||||
setIsFatalError(false);
|
||||
setIsReconnectPending(false);
|
||||
disconnectStream();
|
||||
}, [createTab, disconnectStream, effectiveDirectory, setActiveTab]);
|
||||
}, [createTab, disconnectStream, terminalDirectory, setActiveTab]);
|
||||
|
||||
const handleAttachSelection = React.useCallback(() => {
|
||||
const selection = terminalControllerRef.current?.getSelection();
|
||||
const sessionKey = currentSessionId ?? (newSessionDraft?.open ? 'draft' : null);
|
||||
if (!selection || !sessionKey || !activeTab || !effectiveDirectory) return;
|
||||
addContextDraft({ directory: effectiveDirectory, sessionKey }, {
|
||||
if (!selection || !sessionKey || !activeTab || !contextDirectory) return;
|
||||
addContextDraft({ directory: contextDirectory, sessionKey }, {
|
||||
source: 'terminal',
|
||||
fileLabel: activeTab.label,
|
||||
startLine: selection.startLine,
|
||||
@@ -690,23 +696,23 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
terminalId: activeTab.terminalSessionId ?? activeTab.id,
|
||||
text: '',
|
||||
});
|
||||
}, [activeTab, addContextDraft, currentSessionId, effectiveDirectory, newSessionDraft?.open]);
|
||||
}, [activeTab, addContextDraft, contextDirectory, currentSessionId, newSessionDraft?.open]);
|
||||
|
||||
const handleSelectTab = React.useCallback(
|
||||
(tabId: string) => {
|
||||
if (!effectiveDirectory) return;
|
||||
setActiveTab(effectiveDirectory, tabId);
|
||||
if (!terminalDirectory) return;
|
||||
setActiveTab(terminalDirectory, tabId);
|
||||
setConnectionError(null);
|
||||
setIsFatalError(false);
|
||||
setIsReconnectPending(false);
|
||||
disconnectStream();
|
||||
},
|
||||
[disconnectStream, effectiveDirectory, setActiveTab]
|
||||
[disconnectStream, terminalDirectory, setActiveTab]
|
||||
);
|
||||
|
||||
const handleCloseTab = React.useCallback(
|
||||
(tabId: string) => {
|
||||
if (!effectiveDirectory) return;
|
||||
if (!terminalDirectory) return;
|
||||
|
||||
if (tabId === activeTabId) {
|
||||
disconnectStream();
|
||||
@@ -715,13 +721,13 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
setConnectionError(null);
|
||||
setIsFatalError(false);
|
||||
setIsReconnectPending(false);
|
||||
const sessionId = useTerminalStore.getState().getDirectoryState(effectiveDirectory)?.tabs.find((tab) => tab.id === tabId)?.terminalSessionId;
|
||||
const sessionId = useTerminalStore.getState().getDirectoryState(terminalDirectory)?.tabs.find((tab) => tab.id === tabId)?.terminalSessionId;
|
||||
void (async () => {
|
||||
if (sessionId) await terminal.close(sessionId);
|
||||
closeTab(effectiveDirectory, tabId);
|
||||
closeTab(terminalDirectory, tabId);
|
||||
})().catch((error) => setConnectionError(error instanceof Error ? error.message : t('terminalView.error.sessionEnded')));
|
||||
},
|
||||
[activeTabId, closeTab, disconnectStream, effectiveDirectory, t, terminal]
|
||||
[activeTabId, closeTab, disconnectStream, terminalDirectory, t, terminal]
|
||||
);
|
||||
|
||||
const handleViewportInput = React.useCallback(
|
||||
@@ -862,7 +868,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
// here tore down and rebuilt the Ghostty terminal (WASM VT + canvas + font
|
||||
// atlas) a second time the moment `createSession` resolved, doubling the cost
|
||||
// of every terminal open. Session changes are handled by the chunk replay path.
|
||||
const terminalViewportKey = `${effectiveDirectory ?? 'no-dir'}::${activeTabId ?? 'no-tab'}`;
|
||||
const terminalViewportKey = `${terminalDirectory ?? 'no-dir'}::${activeTabId ?? 'no-tab'}`;
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isTerminalVisible || useTouchTerminalInput) {
|
||||
@@ -914,7 +920,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (!effectiveDirectory) {
|
||||
if (!terminalDirectory) {
|
||||
return (
|
||||
<div className="flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground">
|
||||
<p>{t('terminalView.empty.noWorkingDirectoryForSession')}</p>
|
||||
@@ -1077,7 +1083,7 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
</Button>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-1 overflow-visible">
|
||||
<Button type="button" size="xs" variant="ghost" className="h-7 w-7 p-0" onClick={() => void handleRestart()} disabled={isRestarting} title={t('terminalView.actions.restart')} aria-label={t('terminalView.actions.restart')}>
|
||||
<Button type="button" size="xs" variant="ghost" className="h-7 w-7 p-0" onClick={() => void handleRestart()} disabled={isRestarting || isActionTab} title={t('terminalView.actions.restart')} aria-label={t('terminalView.actions.restart')}>
|
||||
<Icon name="restart" className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
@@ -1098,8 +1104,8 @@ export const TerminalView: React.FC<TerminalViewProps> = ({ visible }) => {
|
||||
variant="outline"
|
||||
className="h-6 shrink-0 gap-1 px-2"
|
||||
onClick={() => {
|
||||
if (!effectiveDirectory) return;
|
||||
openContextPreview(effectiveDirectory, previewUrl);
|
||||
if (!contextDirectory) return;
|
||||
openContextPreview(contextDirectory, previewUrl);
|
||||
}}
|
||||
title={t('terminalView.preview.openTitle')}
|
||||
>
|
||||
|
||||
@@ -32,8 +32,8 @@ const viewportKeyDeclaration = terminalViewSource
|
||||
.find((line) => line.includes('const terminalViewportKey =')) ?? '';
|
||||
|
||||
describe('terminal viewport remount guard', () => {
|
||||
test('viewport identity excludes the PTY session id', () => {
|
||||
expect(viewportKeyDeclaration).toContain('effectiveDirectory');
|
||||
test('viewport identity uses the authoritative terminal directory and excludes the PTY session id', () => {
|
||||
expect(viewportKeyDeclaration).toContain('terminalDirectory');
|
||||
expect(viewportKeyDeclaration).toContain('activeTabId');
|
||||
expect(viewportKeyDeclaration).not.toContain('terminalSessionId');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user