#8026 · Completion timestamps are absent from sibling ordering
Verdict: REPRODUCED · Root-cause confidence: high
Scope: real migrated SQLite lifecycle writes and the production sidebar tree model. No desktop or browser rendering claim is made.
1. TL;DR
A child that finishes most recently can remain below an earlier-finishing sibling in the sidebar model's default Updated at order. The database records the completion transition time, but successful child completion deliberately does not advance the separate unread-attention clock. The inactive-thread comparator sorts by that attention clock, and the public sidebar data does not expose the durable transition time. Three fresh scenarios fail identically at the recorded trusted main commit, including a grandchild pair and children of a pinned parent. This is a reproduced data/model defect; a running desktop build was not exercised.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A later-finishing older sibling can remain below its newer sibling. | Verified | The real lifecycle writer completes Second at 20000 and First at 30000; the production tree model returns Second before First in both checkouts. |
| The same defect reaches deeper nesting and pinned parents. | Verified, sampled | Depth 2 and pinned-root scenarios fail. Arbitrarily deep nesting was not exhaustively tested. |
| Completion and unread attention are different clocks. | Verified | The test asserts statusChangedAt equals each completion time while latestAttentionAt remains 10000 or 11000. |
| Server/sidebar contracts omit the durable transition time. | Verified by source inspection | The server list projection and SDK/sidebar adapter expose attention and update timestamps but not statusChangedAt. This report does not add a new runtime transport assertion. |
| Reading/renaming should not count as activity. | Source-supported limitation | The existing updateThread path writes updatedAt for metadata changes. This separate behavior was not newly exercised. |
| The visible desktop order follows the model result. | Unverified live | No desktop instance, provider turn, browser, or screenshot was used. |
3. Environment
- Public target repository: get-bb/bb; trusted origin/main resolved to
796cdcc0f4bf8a55e23664035c54e8db6fe9d272on 2026-11-22. - Linux x86_64; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.12.
- Each scenario opens its own SQLite database through createMigratedConnection(), using the real migration template. The connection and mocked clock are restored in finally.
- No provider process, user runtime database, live server, or network port is used. The configured codex string is only inert thread metadata.
- Frozen installation succeeded in both checkouts. The first full build initially encountered missing SDK output; after build:types, the normal full build passed all 74 tasks.
4. Minimal reproduction
- Prepare the exact trusted source and build it:
git clone https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach 796cdcc0f4bf8a55e23664035c54e8db6fe9d272 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build # Save the complete test below as packages/db/test/data/issue-8026-repro.test.ts. pnpm exec turbo run test --filter=@bb/db -- test/data/issue-8026-repro.test.ts
The final command should exit nonzero because it expresses the desired completion-order invariant, not the current behavior. It invokes the real lifecycle transition writer and verifies persisted timestamps before projecting existing supported fields into sidebar fixtures. No proposed or invented SDK property is supplied.
| Thread | Creation/attention time | Successful completion |
|---|---|---|
| First | 10000 | 30000 |
| Second | 11000 | 20000 |
Expected: First, Second. Actual: Second, First. The same result occurs for direct children, grandchildren, and direct children of a pinned root.
Observed output, both runs
{"depth":1,"pinned":false,"actual":["Second","First"],"expected":["First","Second"]}
{"depth":2,"pinned":false,"actual":["Second","First"],"expected":["First","Second"]}
{"depth":1,"pinned":true,"actual":["Second","First"],"expected":["First","Second"]}
AssertionError: expected [ 'Second', 'First' ] to deeply equal [ 'First', 'Second' ]
Test Files 1 failed (1)
Tests 3 failed (3)
Complete reproduction test
Save this entire block at packages/db/test/data/issue-8026-repro.test.ts. It was authored from the trusted main implementation, not copied from an issue script or a linked pull request.
import { describe, expect, it, vi } from "vitest";
import { createMigratedConnection } from "../../src/testing.js";
import { noopNotifier } from "../../src/notifier.js";
import { createProject } from "../../src/data/projects.js";
import { upsertHost } from "../../src/data/hosts.js";
import { createThread, getThread } from "../../src/data/threads.js";
import { writeThreadLifecycleStateInTransaction } from "../../src/data/thread-run-state.js";
import { makeSidebarThread } from "../../../../plugins/thread-list/app/model/fixtures.js";
import {
buildProjectThreadGroups,
type ProjectThreadItem,
} from "../../../../plugins/thread-list/app/model/project-thread-groups.js";
import { buildPinnedSidebarState } from "../../../../plugins/thread-list/app/model/pinned-sidebar-threads.js";
function childrenOf(items: ProjectThreadItem[], parentId: string): string[] {
for (const item of items) {
if (item.kind !== "thread") continue;
if (item.node.thread.id === parentId) {
return item.node.children.flatMap((child) =>
child.kind === "thread" ? [child.node.thread.title ?? ""] : [],
);
}
const found = childrenOf(item.node.children, parentId);
if (found.length > 0) return found;
}
return [];
}
describe("completed sibling activity reproduction", () => {
it.each([
{ depth: 1, pinned: false },
{ depth: 2, pinned: false },
{ depth: 1, pinned: true },
])("orders completion at depth $depth with pinned=$pinned", ({ depth, pinned }) => {
let now = 10_000;
const clock = vi.spyOn(Date, "now").mockImplementation(() => now);
const db = createMigratedConnection();
try {
const host = upsertHost(db, noopNotifier, { name: "reproduction" });
const { project } = createProject(db, noopNotifier, {
name: "reproduction",
source: { type: "local_path", hostId: host.id, path: "/tmp/repro-8026" },
});
const root = createThread(db, noopNotifier, {
projectId: project.id,
providerId: "codex",
title: "Root",
status: "idle",
pinned,
});
const threadIds = [root.id];
let parentId = root.id;
if (depth === 2) {
const parent = createThread(db, noopNotifier, {
projectId: project.id,
providerId: "codex",
parentThreadId: root.id,
title: "Parent",
status: "idle",
});
threadIds.push(parent.id);
parentId = parent.id;
}
const first = createThread(db, noopNotifier, {
projectId: project.id,
providerId: "codex",
parentThreadId: parentId,
title: "First",
status: "active",
});
now = 11_000;
const second = createThread(db, noopNotifier, {
projectId: project.id,
providerId: "codex",
parentThreadId: parentId,
title: "Second",
status: "active",
});
threadIds.push(first.id, second.id);
const emptyRun = { heldCompletion: null, requests: [], stop: null };
for (const [threadId, completedAt] of [
[second.id, 20_000],
[first.id, 30_000],
] as const) {
now = completedAt;
const result = db.transaction((transaction) =>
writeThreadLifecycleStateInTransaction(transaction, {
threadId,
expectedStatus: "active",
previous: emptyRun,
next: { ...emptyRun, status: "idle" },
}),
);
expect(result.kind).toBe("written");
if (result.kind !== "written") throw new Error("Completion was not written");
expect(result.thread.statusChangedAt).toBe(completedAt);
expect(result.thread.latestAttentionAt).toBe(threadId === first.id ? 10_000 : 11_000);
}
const sidebarThreads = threadIds.map((threadId) => {
const row = getThread(db, threadId);
if (!row) throw new Error("Missing reproduction thread");
return makeSidebarThread({
id: row.id,
projectId: row.projectId,
parentThreadId: row.parentThreadId,
title: row.title,
status: row.status,
createdAt: row.createdAt,
updatedAt: row.updatedAt,
latestAttentionAt: row.latestAttentionAt,
pinnedAt: row.pinnedAt,
pinSortKey: row.pinSortKey,
});
});
const items = pinned
? buildPinnedSidebarState({ threads: sidebarThreads }).rootItems
: buildProjectThreadGroups(sidebarThreads);
const actual = childrenOf(items, parentId);
console.log(JSON.stringify({ depth, pinned, actual, expected: ["First", "Second"] }));
expect(actual).toEqual(["First", "Second"]);
} finally {
clock.mockRestore();
db.$client.close();
}
});
});
5. Root cause
- Updated at is the descending updated sort option; the updated comparator selects compareStandardThreads.
- statusChangeNeedsAttention excludes successful child completion returns false for active-to-idle transitions with a non-null parent. The same writer always records statusChangedAt for actual transitions. Thus completion is persisted without changing attention.
- Inactive threads sort by latestAttentionAt, then creation time. Since Second has attention 11000 and First has attention 10000, First's completion at 30000 cannot affect this comparison.
- Pinned trees use the same child comparator. Pin-root sorting does not repair the descendant comparison.
- The public thread projection omits statusChangedAt; the list response spreads that projection. Realtime status metadata also exposes attention and updatedAt, not the transition clock. The SDK timestamp contract and the app sidebar adapter have no separate completion/activity timestamp.
Relevant comparator excerpt
const latestAttentionAtDelta =
right.latestAttentionAt - left.latestAttentionAt;
if (latestAttentionAtDelta !== 0) {
return latestAttentionAtDelta;
}
return compareByCreatedAtDescending(left, right);
The underlying mismatch is conflating attention-worthy events with ordering activity. A comparator-only change cannot recover a timestamp that never reaches its input. Using updatedAt would count metadata changes: updateThread assigns the current update time before changing metadata.
6. Proposed fix and simple-fix decision
Carry the existing durable transition/activity timestamp through the server list and realtime paths, client cache, and sidebar SDK contract, then use an appropriate attention/activity maximum for inactive descendants. Preserve active-first behavior, ordinary root ordering, and unread semantics. Keep reading or renaming out of the activity signal; test list/realtime consistency and metadata changes as distinct contracts.
No automatic fix or new pull request: the missing signal crosses the server/domain, client-cache, and public plugin SDK contracts. That violates this run's single-subsystem and no-public-contract-change safety gates. Changing the unread clock instead would alter product behavior; using updatedAt would be a symptom-level workaround. The fix was stopped before any production edit, branch, commit, or push to get-bb/bb. There is therefore no before/after fix claim.
7. Linked pull request: #8027
PR #8027 was CLOSED and unmerged when inspected. No open linking pull request was found in issue timeline metadata or an open-PR search for issue 8026. Metadata reports 34 files, 397 additions and 14 deletions (411 changed lines).
Static diff inspection only: it adds the stored timestamp to server list/status metadata, public domain/SDK types, client caches and the sidebar projection, then uses it for descendant sorting. That direction addresses the observed missing-signal mechanism. Its SDK addition at packages/plugin-sdk/src/app-contract.ts:1535 and server projection changes at apps/server/src/services/threads/thread-runtime-display.ts:582 illustrate why this is not a one-subsystem autopilot fix.
Review verdict: directionally consistent, not execution-validated. No additional severity finding is asserted from this limited inspection. No PR branch, script, patch, or test was checked out or run. All tests reported here ran on trusted main plus the locally authored reproduction test, not on PR #8027.
8. Related issues
Issue #7978 concerns ranking parent rows using subtree activity. This report tests sibling ordering inside a parent; it does not establish or modify parent-row ranking.
9. Verification
The same agent repeated the reproduction in a second, clean detached temporary worktree at 796cdcc0f4bf8a55e23664035c54e8db6fe9d272. The tracked working tree was clean before the locally authored test was copied in; no source file from a linked PR or fork was used. The reproduction test's SHA-256 matched in both checkouts: 76307a601e77445f938c6d05cdc6787664a511e31a8f6393d31685f42a7eed6b.
BASE=796cdcc0f4bf8a55e23664035c54e8db6fe9d272 VERIFY=$(mktemp -d) git worktree add --detach "$VERIFY" "$BASE" git -C "$VERIFY" status --porcelain # Expected: no output before adding the reproduction test. cp packages/db/test/data/issue-8026-repro.test.ts "$VERIFY/packages/db/test/data/issue-8026-repro.test.ts" cd "$VERIFY" pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run test --filter=@bb/db -- test/data/issue-8026-repro.test.ts
Run 1: 3 expected invariant failures in 3.29 seconds of Vitest execution. Run 2: the same 3 failures in 3.58 seconds, with a new migrated database in each case. Both runs reached the final ordering assertion; the earlier persistence, status-transition, and attention-clock assertions passed. No report correction was necessary. This is a repeat by the same agent, not an independent verification.
Existing focused checks passed on unchanged main: 36 sidebar project/pinned model tests, 3 database lifecycle tests, and 14 server runtime-display tests (53 tests total). These passing tests do not themselves prove the new completion-order invariant.
10. Appendix: commands and evidence
Evidence is embedded in this HTML; raw logs and test files remain outside the public reports repository, in accordance with its publishing rules.
pnpm exec turbo run test --filter=bb-plugin-thread-list -- app/model/project-thread-groups.test.ts app/model/pinned-sidebar-threads.test.ts Test Files 2 passed (2) Tests 36 passed (36) pnpm exec turbo run test --filter=@bb/db -- test/data/thread-lifecycle.test.ts Test Files 1 passed (1) Tests 3 passed (3) pnpm exec turbo run test --filter=@bb/server -- test/services/threads/thread-runtime-display.test.ts Test Files 1 passed (1) Tests 14 passed (14) pnpm exec turbo run build Tasks: 74 successful, 74 total
Read-only GitHub checks: repository visibility, issue fields/comments/labels/timeline, valid repository properties/labels, similar issue classifications, open pull-request search, and closed PR #8027 metadata/diff. Local checks: trusted origin/main fetch and commit verification, applicable instructions, normal frozen installs/builds, both reproduction runs, focused existing tests, and git diff --check. No issue-provided command or external issue link was executed or fetched.
Untrusted-data handling: issue prose, code blocks and linked change claims were treated only as allegations to test. No instructions from those sources were followed. No real user data, credentials, private machine identifiers, or browser screenshots were collected.
Agent-generated report · 2026-11-22