[Init] Initial commit - NetMesh terminal manager
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
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
This commit is contained in:
190
domain/terminalAppearanceRuntime.test.ts
Normal file
190
domain/terminalAppearanceRuntime.test.ts
Normal file
@@ -0,0 +1,190 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import {
|
||||
getFollowAppTerminalThemeIds,
|
||||
getFollowAppTerminalThemeSelectionUpdate,
|
||||
} from './terminalAppearance';
|
||||
import {
|
||||
idleThemeUserIntent,
|
||||
isFollowAppIntentSettled,
|
||||
pickingThemeUserIntent,
|
||||
resolveGlobalTerminalAppearance,
|
||||
resolveSessionAppearanceThemeId,
|
||||
resolveTerminalAppearance,
|
||||
} from './terminalAppearanceRuntime';
|
||||
import type { Host } from './models';
|
||||
|
||||
const baseSettings = {
|
||||
terminalThemeId: 'netcatty-dark',
|
||||
terminalThemeDarkId: 'auto',
|
||||
terminalThemeLightId: 'auto',
|
||||
followAppTerminalTheme: true,
|
||||
resolvedTheme: 'dark' as const,
|
||||
lightUiThemeId: 'snow',
|
||||
darkUiThemeId: 'github',
|
||||
accentMode: 'theme' as const,
|
||||
customAccent: '',
|
||||
};
|
||||
|
||||
test('follow-app intent resolves to the picked theme before ui settings catch up', () => {
|
||||
const appearance = resolveGlobalTerminalAppearance({
|
||||
userIntent: pickingThemeUserIntent('system-flexoki-light'),
|
||||
settings: {
|
||||
...baseSettings,
|
||||
resolvedTheme: 'dark',
|
||||
lightUiThemeId: 'snow',
|
||||
},
|
||||
customThemes: [],
|
||||
});
|
||||
|
||||
assert.equal(appearance.themeId, 'system-flexoki-light');
|
||||
assert.equal(appearance.source, 'intent');
|
||||
assert.equal(appearance.appThemeUpdate?.uiThemeId, 'flexoki');
|
||||
assert.equal(appearance.appThemeUpdate?.appTheme, 'light');
|
||||
});
|
||||
|
||||
test('follow-app idle resolves from active ui preset', () => {
|
||||
const appearance = resolveGlobalTerminalAppearance({
|
||||
userIntent: idleThemeUserIntent(),
|
||||
settings: baseSettings,
|
||||
customThemes: [],
|
||||
});
|
||||
|
||||
assert.equal(appearance.themeId, 'system-github-dark');
|
||||
assert.equal(appearance.source, 'follow-app');
|
||||
});
|
||||
|
||||
test('follow-app intent settled requires ui theme id and resolved theme', () => {
|
||||
assert.equal(
|
||||
isFollowAppIntentSettled('system-flexoki-light', {
|
||||
...baseSettings,
|
||||
resolvedTheme: 'dark',
|
||||
lightUiThemeId: 'snow',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
isFollowAppIntentSettled('system-flexoki-light', {
|
||||
...baseSettings,
|
||||
resolvedTheme: 'light',
|
||||
lightUiThemeId: 'snow',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
isFollowAppIntentSettled('system-flexoki-light', {
|
||||
...baseSettings,
|
||||
resolvedTheme: 'light',
|
||||
lightUiThemeId: 'flexoki',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test('all follow-app theme ids round-trip through intent resolution', () => {
|
||||
for (const themeId of getFollowAppTerminalThemeIds()) {
|
||||
const selection = getFollowAppTerminalThemeSelectionUpdate(themeId);
|
||||
assert.ok(selection, `missing selection for ${themeId}`);
|
||||
const appearance = resolveGlobalTerminalAppearance({
|
||||
userIntent: pickingThemeUserIntent(themeId),
|
||||
settings: {
|
||||
...baseSettings,
|
||||
resolvedTheme: selection.appTheme,
|
||||
lightUiThemeId: selection.appTheme === 'light' ? selection.uiThemeId : 'snow',
|
||||
darkUiThemeId: selection.appTheme === 'dark' ? selection.uiThemeId : 'github',
|
||||
},
|
||||
customThemes: [],
|
||||
});
|
||||
assert.equal(appearance.themeId, themeId);
|
||||
}
|
||||
});
|
||||
|
||||
test('manual mode uses host override when idle', () => {
|
||||
const host = {
|
||||
id: 'host-1',
|
||||
theme: 'dracula',
|
||||
themeOverride: true,
|
||||
} as Host;
|
||||
|
||||
const appearance = resolveTerminalAppearance({
|
||||
userIntent: idleThemeUserIntent(),
|
||||
settings: {
|
||||
...baseSettings,
|
||||
followAppTerminalTheme: false,
|
||||
terminalThemeDarkId: 'netcatty-dark',
|
||||
},
|
||||
hostScope: { host, isEphemeral: false },
|
||||
customThemes: [],
|
||||
});
|
||||
|
||||
assert.equal(appearance.themeId, 'dracula');
|
||||
assert.equal(appearance.source, 'host-override');
|
||||
});
|
||||
|
||||
test('manual mode intent overrides host theme while picking', () => {
|
||||
const host = {
|
||||
id: 'host-1',
|
||||
theme: 'dracula',
|
||||
themeOverride: true,
|
||||
} as Host;
|
||||
|
||||
const appearance = resolveTerminalAppearance({
|
||||
userIntent: pickingThemeUserIntent('solarized-light', { scopeHostId: 'host-1' }),
|
||||
settings: {
|
||||
...baseSettings,
|
||||
followAppTerminalTheme: false,
|
||||
},
|
||||
hostScope: { host, isEphemeral: false },
|
||||
customThemes: [],
|
||||
});
|
||||
|
||||
assert.equal(appearance.themeId, 'solarized-light');
|
||||
assert.equal(appearance.source, 'intent');
|
||||
});
|
||||
|
||||
test('manual mode intent stays scoped to the picked host', () => {
|
||||
const focusedHost = {
|
||||
id: 'host-1',
|
||||
theme: 'dracula',
|
||||
themeOverride: true,
|
||||
} as Host;
|
||||
const otherHost = {
|
||||
id: 'host-2',
|
||||
theme: 'netcatty-dark',
|
||||
themeOverride: true,
|
||||
} as Host;
|
||||
|
||||
const intent = pickingThemeUserIntent('solarized-light', { scopeHostId: 'host-1' });
|
||||
|
||||
assert.equal(resolveTerminalAppearance({
|
||||
userIntent: intent,
|
||||
settings: { ...baseSettings, followAppTerminalTheme: false },
|
||||
hostScope: { host: focusedHost, isEphemeral: false },
|
||||
customThemes: [],
|
||||
}).themeId, 'solarized-light');
|
||||
|
||||
assert.equal(resolveTerminalAppearance({
|
||||
userIntent: intent,
|
||||
settings: { ...baseSettings, followAppTerminalTheme: false },
|
||||
hostScope: { host: otherHost, isEphemeral: false },
|
||||
customThemes: [],
|
||||
}).themeId, 'netcatty-dark');
|
||||
});
|
||||
|
||||
test('follow-app session appearance ignores host override', () => {
|
||||
const host = {
|
||||
id: 'host-1',
|
||||
theme: 'dracula',
|
||||
themeOverride: true,
|
||||
} as Host;
|
||||
|
||||
assert.equal(
|
||||
resolveSessionAppearanceThemeId(true, 'system-chai-light', host),
|
||||
'system-chai-light',
|
||||
);
|
||||
assert.equal(
|
||||
resolveSessionAppearanceThemeId(false, 'netcatty-dark', host),
|
||||
'dracula',
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user