mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 16:02:55 +00:00
Refactor terminal record merge to extract snapshot-reconciliation helper
Split the inline merge logic in mergeTerminalRecordsByCurrentOrder into a named mergeTerminalSnapshotWithKnownRecord function for clarity, preserving the existing behavior of keeping the last known theme when a snapshot omits it.
This commit is contained in:
@@ -116,6 +116,20 @@ function mobileSessionTabEqual(
|
||||
}
|
||||
}
|
||||
|
||||
// Reconcile a partial session snapshot against the last known record for the
|
||||
// same terminal. The snapshot owns live fields (title, activity); the known
|
||||
// theme only survives when the snapshot omits it, since lightweight snapshots
|
||||
// can drop it.
|
||||
function mergeTerminalSnapshotWithKnownRecord(
|
||||
snapshot: TerminalRecord,
|
||||
known: TerminalRecord
|
||||
): TerminalRecord {
|
||||
return {
|
||||
...snapshot,
|
||||
terminalTheme: snapshot.terminalTheme ?? known.terminalTheme
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeTerminalRecordsByCurrentOrder(
|
||||
terminalTabs: TerminalRecord[],
|
||||
currentTerminals: TerminalRecord[]
|
||||
@@ -128,15 +142,9 @@ export function mergeTerminalRecordsByCurrentOrder(
|
||||
return [
|
||||
...currentTerminals.map((terminal) => {
|
||||
const snapshotTerminal = terminalTabsByHandle.get(terminal.handle)
|
||||
if (!snapshotTerminal) {
|
||||
return terminal
|
||||
}
|
||||
// Why: lightweight session snapshots can omit the theme; keep the last
|
||||
// known value while still accepting current title/activity fields.
|
||||
return {
|
||||
...snapshotTerminal,
|
||||
terminalTheme: snapshotTerminal.terminalTheme ?? terminal.terminalTheme
|
||||
}
|
||||
return snapshotTerminal
|
||||
? mergeTerminalSnapshotWithKnownRecord(snapshotTerminal, terminal)
|
||||
: terminal
|
||||
}),
|
||||
...terminalTabs.filter((terminal) => !currentHandles.has(terminal.handle))
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user