Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
259 lines
8.1 KiB
TypeScript
259 lines
8.1 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
DEFAULT_WORKSPACE_TITLE,
|
|
buildMergedWorkspaceTitle,
|
|
buildMergedWorkspaceTitleFromSessions,
|
|
getSessionConnectionLabel,
|
|
resolveCodingCliProviderIconUpdate,
|
|
resolveSessionTabTitle,
|
|
resolveWorkspaceTabLabel,
|
|
shouldUpdateCodingCliTabIcon,
|
|
} from './sessionTabTitle';
|
|
|
|
test('getSessionConnectionLabel prefers customName over hostLabel', () => {
|
|
assert.equal(
|
|
getSessionConnectionLabel({ customName: 'Prod', hostLabel: 'web-01' }),
|
|
'Prod',
|
|
);
|
|
assert.equal(
|
|
getSessionConnectionLabel({ hostLabel: 'web-01' }),
|
|
'web-01',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle ignores dynamic title for non-agent sessions', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ hostLabel: 'web-01', dynamicTitle: 'root@v2022:/var/log' },
|
|
),
|
|
'web-01',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle uses dynamic title for agent sessions', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ hostLabel: 'web-01', dynamicTitle: 'claude: refactor auth', codingCliProviderId: 'claude' },
|
|
),
|
|
'claude: refactor auth',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle uses dynamic title for all sessions in all mode', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ hostLabel: 'web-01', dynamicTitle: 'root@v2022:/var/log' },
|
|
'all',
|
|
),
|
|
'root@v2022:/var/log',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle disables dynamic titles in off mode', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ hostLabel: 'web-01', dynamicTitle: 'claude: refactor auth', codingCliProviderId: 'claude' },
|
|
'off',
|
|
),
|
|
'web-01',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle falls back to connection label when dynamic title is empty', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle({ hostLabel: 'web-01', dynamicTitle: ' ' }),
|
|
'web-01',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle prefers user customName over dynamic title', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ customName: 'Prod deploy', hostLabel: 'web-01', dynamicTitle: 'claude: refactor auth' },
|
|
),
|
|
'Prod deploy',
|
|
);
|
|
});
|
|
|
|
test('resolveSessionTabTitle strips agent spinner prefixes from dynamic titles', () => {
|
|
assert.equal(
|
|
resolveSessionTabTitle(
|
|
{ hostLabel: 'web-01', dynamicTitle: '⠋ Droid', codingCliProviderId: 'droid' },
|
|
),
|
|
'Droid',
|
|
);
|
|
});
|
|
|
|
test('coding CLI icon updates stop without clearing the current icon when dynamic titles are off', () => {
|
|
assert.equal(shouldUpdateCodingCliTabIcon('off'), false);
|
|
assert.equal(shouldUpdateCodingCliTabIcon('agent'), true);
|
|
assert.equal(shouldUpdateCodingCliTabIcon('all'), true);
|
|
|
|
assert.equal(resolveCodingCliProviderIconUpdate({
|
|
dynamicTabTitleMode: 'off',
|
|
currentProviderId: 'claude',
|
|
nextProviderId: null,
|
|
}), undefined);
|
|
assert.equal(resolveCodingCliProviderIconUpdate({
|
|
dynamicTabTitleMode: 'off',
|
|
currentProviderId: 'claude',
|
|
nextProviderId: 'opencode',
|
|
}), undefined);
|
|
assert.equal(resolveCodingCliProviderIconUpdate({
|
|
dynamicTabTitleMode: 'agent',
|
|
currentProviderId: 'claude',
|
|
nextProviderId: null,
|
|
}), null);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel keeps a user-renamed workspace title', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: 'My Cluster', focusedSessionId: 's1' },
|
|
[{ id: 's1', hostLabel: 'web-01', hostId: 'host-web' }],
|
|
),
|
|
'My Cluster',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel derives the focused host name from a default-title workspace', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, focusedSessionId: 's2' },
|
|
[
|
|
{ id: 's1', hostLabel: 'Localhost', hostId: 'local-terminal' },
|
|
{ id: 's2', hostLabel: 'prod-db', hostId: 'host-db' },
|
|
],
|
|
),
|
|
// Two distinct hosts: focused host + "+1" for the other.
|
|
'prod-db +1',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel shows a single host name without a suffix', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, focusedSessionId: 's1' },
|
|
[
|
|
// Two local terminals share the stable local hostId.
|
|
{ id: 's1', hostLabel: 'Localhost', hostId: 'local-terminal' },
|
|
{ id: 's2', hostLabel: 'Localhost', hostId: 'local-terminal' },
|
|
],
|
|
),
|
|
'Localhost',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel does not add a suffix when a same-host pane is renamed', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, focusedSessionId: 's1' },
|
|
[
|
|
{ id: 's1', hostLabel: 'web-01', hostId: 'host-web' },
|
|
// Same host (hostId), but a rename rewrote this pane's customName AND
|
|
// hostLabel — hostId still ties it to the same host, so no "+1".
|
|
{ id: 's2', customName: 'logs', hostLabel: 'logs', hostId: 'host-web' },
|
|
],
|
|
),
|
|
'web-01',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel shows the focused rename while counting hosts', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, focusedSessionId: 's1' },
|
|
[
|
|
{ id: 's1', customName: 'my-web', hostLabel: 'my-web', hostId: 'host-web' },
|
|
{ id: 's2', hostLabel: 'db-02', hostId: 'host-db' },
|
|
],
|
|
),
|
|
'my-web +1',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel keeps a workspace explicitly named "Workspace"', () => {
|
|
// autoTitle:false marks the title as user-chosen even when it equals the
|
|
// default sentinel — it must not be replaced by a host label.
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, autoTitle: false, focusedSessionId: 's1' },
|
|
[{ id: 's1', hostLabel: 'web-01', hostId: 'host-web' }],
|
|
),
|
|
'Workspace',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel derives a label for an explicitly auto-titled workspace', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel(
|
|
{ title: DEFAULT_WORKSPACE_TITLE, autoTitle: true, focusedSessionId: 's1' },
|
|
[{ id: 's1', hostLabel: 'Localhost', hostId: 'local-terminal' }],
|
|
),
|
|
'Localhost',
|
|
);
|
|
});
|
|
|
|
test('resolveWorkspaceTabLabel falls back to the default title with no sessions', () => {
|
|
assert.equal(
|
|
resolveWorkspaceTabLabel({ title: DEFAULT_WORKSPACE_TITLE, focusedSessionId: null }, []),
|
|
DEFAULT_WORKSPACE_TITLE,
|
|
);
|
|
});
|
|
|
|
test('buildMergedWorkspaceTitle joins both tab labels with a slash', () => {
|
|
assert.equal(buildMergedWorkspaceTitle('01', '02'), '01/02');
|
|
assert.equal(buildMergedWorkspaceTitle('web-01', 'db-02'), 'web-01/db-02');
|
|
});
|
|
|
|
test('buildMergedWorkspaceTitle collapses identical labels to one name', () => {
|
|
assert.equal(buildMergedWorkspaceTitle('web-01', 'web-01'), 'web-01');
|
|
});
|
|
|
|
test('buildMergedWorkspaceTitle falls back to the labeled side', () => {
|
|
assert.equal(buildMergedWorkspaceTitle('', '02'), '02');
|
|
assert.equal(buildMergedWorkspaceTitle('01', ''), '01');
|
|
});
|
|
|
|
test('buildMergedWorkspaceTitle returns null when neither tab has a label', () => {
|
|
assert.equal(buildMergedWorkspaceTitle('', ''), null);
|
|
});
|
|
|
|
test('buildMergedWorkspaceTitleFromSessions recomputes from live membership', () => {
|
|
const sessions = [
|
|
{ id: 'a', customName: '01', hostLabel: '01', hostId: 'h1' },
|
|
{ id: 'b', customName: '02', hostLabel: '02', hostId: 'h2' },
|
|
];
|
|
assert.equal(buildMergedWorkspaceTitleFromSessions(sessions), '01/02');
|
|
// After renaming pane "02" the composed title follows.
|
|
assert.equal(
|
|
buildMergedWorkspaceTitleFromSessions([
|
|
sessions[0],
|
|
{ ...sessions[1], customName: 'prod', hostLabel: 'prod' },
|
|
]),
|
|
'01/prod',
|
|
);
|
|
// After removing a pane the title collapses to the remaining label.
|
|
assert.equal(buildMergedWorkspaceTitleFromSessions([sessions[1]]), '02');
|
|
// Identical labels still collapse; unlabeled panes are skipped.
|
|
assert.equal(
|
|
buildMergedWorkspaceTitleFromSessions([
|
|
sessions[0],
|
|
{ id: 'c', customName: '', hostLabel: '', hostId: 'h3' },
|
|
{ ...sessions[0], id: 'd' },
|
|
]),
|
|
'01',
|
|
);
|
|
assert.equal(buildMergedWorkspaceTitleFromSessions([]), null);
|
|
// A third pane whose label duplicates a non-adjacent member is collapsed too.
|
|
assert.equal(
|
|
buildMergedWorkspaceTitleFromSessions([
|
|
sessions[0],
|
|
sessions[1],
|
|
{ ...sessions[0], id: 'd' },
|
|
]),
|
|
'01/02',
|
|
);
|
|
});
|