mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 18:17:36 +00:00
* perf(mobile): skip re-rendering unchanged worktree rows Rows reach the host list freshly parsed and copied on every changed worktree.ps poll, so the row memo never skipped and every mounted row re-rendered each poll. The row memo now compares the item by value with the catalog's areWorktreesEqual, extended to every Worktree and agent row field, and every other prop by identity. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * refactor(mobile): compare worktree rows by structural equality The hand-written Worktree field list needed a completeness guard that no compiler checks, since mobile test files sit outside tsc. A generic structural equality covers every field by construction, so a new field can never be skipped and freeze a row. Rows memo on it directly: the item and repo icon compare by value, callbacks and `now` by identity. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
24 lines
655 B
TypeScript
24 lines
655 B
TypeScript
// Why: polls re-parse rows into fresh objects, so lists and rows compare by value to skip renders.
|
|
export function areStructurallyEqual(a: unknown, b: unknown): boolean {
|
|
if (Object.is(a, b)) {
|
|
return true
|
|
}
|
|
if (
|
|
!a ||
|
|
!b ||
|
|
typeof a !== 'object' ||
|
|
typeof b !== 'object' ||
|
|
Array.isArray(a) !== Array.isArray(b)
|
|
) {
|
|
return false
|
|
}
|
|
const leftEntries = Object.entries(a)
|
|
const rightEntries = new Map(Object.entries(b))
|
|
return (
|
|
leftEntries.length === rightEntries.size &&
|
|
leftEntries.every(
|
|
([key, value]) => rightEntries.has(key) && areStructurallyEqual(value, rightEntries.get(key))
|
|
)
|
|
)
|
|
}
|