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
118 lines
3.6 KiB
TypeScript
118 lines
3.6 KiB
TypeScript
import type { TerminalSession } from './models';
|
|
|
|
/**
|
|
* Session fields that affect terminal pane React trees (xterm host, layout,
|
|
* connect/startup chrome). Presentation-only fields used by TopTabs
|
|
* (`dynamicTitle`, `codingCliProviderId`) are intentionally ignored so title
|
|
* churn does not invalidate TerminalLayer / TerminalPanesHost memoization.
|
|
*
|
|
* Keep this list aligned with props TerminalPane passes into `<Terminal />`.
|
|
*/
|
|
export type TerminalPaneSessionFields = Pick<
|
|
TerminalSession,
|
|
| 'id'
|
|
| 'hostId'
|
|
| 'workspaceId'
|
|
| 'status'
|
|
| 'protocol'
|
|
| 'hostname'
|
|
| 'username'
|
|
| 'port'
|
|
| 'moshEnabled'
|
|
| 'etEnabled'
|
|
| 'fontSize'
|
|
| 'fontSizeOverride'
|
|
| 'customName'
|
|
| 'hostLabel'
|
|
| 'hiddenFromTabs'
|
|
| 'localShell'
|
|
| 'localShellName'
|
|
| 'localShellArgs'
|
|
| 'localStartDir'
|
|
| 'shellType'
|
|
| 'charset'
|
|
| 'serialConfig'
|
|
| 'pluginConnection'
|
|
| 'restoreState'
|
|
| 'pendingInitialCwd'
|
|
| 'startupCommand'
|
|
| 'noAutoRun'
|
|
| 'multiLineRunMode'
|
|
| 'pendingScriptId'
|
|
| 'pendingScript'
|
|
| 'reuseConnectionFromSessionId'
|
|
| 'requireFreshConnection'
|
|
| 'autoOpenSidePanel'
|
|
>;
|
|
|
|
function paneFieldEqual(
|
|
a: TerminalPaneSessionFields,
|
|
b: TerminalPaneSessionFields,
|
|
): boolean {
|
|
return a.id === b.id
|
|
&& a.hostId === b.hostId
|
|
&& a.workspaceId === b.workspaceId
|
|
&& a.status === b.status
|
|
&& a.protocol === b.protocol
|
|
&& a.hostname === b.hostname
|
|
&& a.username === b.username
|
|
&& (a.port ?? 22) === (b.port ?? 22)
|
|
&& Boolean(a.moshEnabled) === Boolean(b.moshEnabled)
|
|
&& Boolean(a.etEnabled) === Boolean(b.etEnabled)
|
|
&& a.fontSize === b.fontSize
|
|
&& Boolean(a.fontSizeOverride) === Boolean(b.fontSizeOverride)
|
|
&& a.customName === b.customName
|
|
&& a.hostLabel === b.hostLabel
|
|
&& Boolean(a.hiddenFromTabs) === Boolean(b.hiddenFromTabs)
|
|
&& a.localShell === b.localShell
|
|
&& a.localShellName === b.localShellName
|
|
&& a.localShellArgs === b.localShellArgs
|
|
&& a.localStartDir === b.localStartDir
|
|
&& a.shellType === b.shellType
|
|
&& a.charset === b.charset
|
|
&& a.serialConfig === b.serialConfig
|
|
&& a.pluginConnection === b.pluginConnection
|
|
&& a.restoreState === b.restoreState
|
|
&& a.pendingInitialCwd === b.pendingInitialCwd
|
|
&& a.startupCommand === b.startupCommand
|
|
&& Boolean(a.noAutoRun) === Boolean(b.noAutoRun)
|
|
&& a.multiLineRunMode === b.multiLineRunMode
|
|
&& a.pendingScriptId === b.pendingScriptId
|
|
&& a.pendingScript === b.pendingScript
|
|
&& a.reuseConnectionFromSessionId === b.reuseConnectionFromSessionId
|
|
&& Boolean(a.requireFreshConnection) === Boolean(b.requireFreshConnection)
|
|
&& a.autoOpenSidePanel === b.autoOpenSidePanel;
|
|
}
|
|
|
|
export function terminalPaneSessionsEqual(
|
|
prev: ReadonlyArray<TerminalPaneSessionFields> | null | undefined,
|
|
next: ReadonlyArray<TerminalPaneSessionFields> | null | undefined,
|
|
): boolean {
|
|
if (prev === next) return true;
|
|
if (!prev || !next) return false;
|
|
if (prev.length !== next.length) return false;
|
|
for (let i = 0; i < prev.length; i += 1) {
|
|
const a = prev[i];
|
|
const b = next[i];
|
|
if (!a || !b) return false;
|
|
if (a === b) continue;
|
|
if (!paneFieldEqual(a, b)) return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Keep the previous sessions array identity when only TopTabs presentation
|
|
* fields changed. Used by App domain memos so title/provider live updates do
|
|
* not rebuild appTerminalDomain / appChromeDomain.
|
|
*/
|
|
export function retainStableSessionsIgnoringPresentation(
|
|
previous: readonly TerminalSession[] | null | undefined,
|
|
next: readonly TerminalSession[],
|
|
): readonly TerminalSession[] {
|
|
if (previous && terminalPaneSessionsEqual(previous, next)) {
|
|
return previous;
|
|
}
|
|
return next;
|
|
}
|