diff options
| author | Adam <[email protected]> | 2026-02-02 09:21:08 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2026-02-02 14:24:23 -0600 |
| commit | 30a25e4edca0f3476ca63f83dbe95fcee75113e3 (patch) | |
| tree | a7c92a4e216c98cef9b067979f22c2c9db7a9dd4 /packages/app/src/context/global-sync.tsx | |
| parent | ea1aba4192fd356603e807144edf202328008ee6 (diff) | |
| download | opencode-30a25e4edca0f3476ca63f83dbe95fcee75113e3.tar.gz opencode-30a25e4edca0f3476ca63f83dbe95fcee75113e3.zip | |
fix(app): user messages not rendering consistently
Diffstat (limited to 'packages/app/src/context/global-sync.tsx')
| -rw-r--r-- | packages/app/src/context/global-sync.tsx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/packages/app/src/context/global-sync.tsx b/packages/app/src/context/global-sync.tsx index ad3d124b2..0facbdfff 100644 --- a/packages/app/src/context/global-sync.tsx +++ b/packages/app/src/context/global-sync.tsx @@ -119,6 +119,8 @@ type ChildOptions = { bootstrap?: boolean } +const cmp = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0) + function normalizeProviderList(input: ProviderListResponse): ProviderListResponse { return { ...input, @@ -297,7 +299,7 @@ function createGlobalSync() { const aUpdated = sessionUpdatedAt(a) const bUpdated = sessionUpdatedAt(b) if (aUpdated !== bUpdated) return bUpdated - aUpdated - return a.id.localeCompare(b.id) + return cmp(a.id, b.id) } function takeRecentSessions(sessions: Session[], limit: number, cutoff: number) { @@ -325,7 +327,7 @@ function createGlobalSync() { const all = input .filter((s) => !!s?.id) .filter((s) => !s.time?.archived) - .sort((a, b) => a.id.localeCompare(b.id)) + .sort((a, b) => cmp(a.id, b.id)) const roots = all.filter((s) => !s.parentID) const children = all.filter((s) => !!s.parentID) @@ -342,7 +344,7 @@ function createGlobalSync() { return sessionUpdatedAt(s) > cutoff }) - return [...keepRoots, ...keepChildren].sort((a, b) => a.id.localeCompare(b.id)) + return [...keepRoots, ...keepChildren].sort((a, b) => cmp(a.id, b.id)) } function ensureChild(directory: string) { @@ -457,7 +459,7 @@ function createGlobalSync() { const nonArchived = (x.data ?? []) .filter((s) => !!s?.id) .filter((s) => !s.time?.archived) - .sort((a, b) => a.id.localeCompare(b.id)) + .sort((a, b) => cmp(a.id, b.id)) // Read the current limit at resolve-time so callers that bump the limit while // a request is in-flight still get the expanded result. @@ -559,7 +561,7 @@ function createGlobalSync() { "permission", sessionID, reconcile( - permissions.filter((p) => !!p?.id).sort((a, b) => a.id.localeCompare(b.id)), + permissions.filter((p) => !!p?.id).sort((a, b) => cmp(a.id, b.id)), { key: "id" }, ), ) @@ -588,7 +590,7 @@ function createGlobalSync() { "question", sessionID, reconcile( - questions.filter((q) => !!q?.id).sort((a, b) => a.id.localeCompare(b.id)), + questions.filter((q) => !!q?.id).sort((a, b) => cmp(a.id, b.id)), { key: "id" }, ), ) @@ -986,7 +988,7 @@ function createGlobalSync() { .filter((p) => !!p?.id) .filter((p) => !!p.worktree && !p.worktree.includes("opencode-test")) .slice() - .sort((a, b) => a.id.localeCompare(b.id)) + .sort((a, b) => cmp(a.id, b.id)) setGlobalStore("project", projects) }), ), |
