Skip to content

feat(web): show who each thread came from, and filter by it - #82

Merged
nullStack65 merged 2 commits into
release/native-0.1.10from
feat/native-0.1.10-thread-attribution
Nov 18, 2026
Merged

nullStack65 merged 2 commits into
release/native-0.1.10from
feat/native-0.1.10-thread-attribution

Conversation

@nullStack65

@nullStack65 nullStack65 commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Kameron (2026-11-18, about 21:27 UTC, relayed by Lead through the Thread hygiene lane): "id also like to know which threads came from me or my agents vs jeff and his and such".

This is stacked on the sidebar filter menu PR, #79, and extends that same menu instead of adding a second control. Review this PR's own commit only: git diff 01d578e1ac..HEAD.

What changed

  1. Sender badge on every thread row. "K" or "J", plus a bot icon for agent work, and a muted "?" when nothing says who it's from. The row's accessible name carries the full sender, for example "…, from Jeff's agents". Unknown is left out of the name, so existing row names don't change.
  2. "From" section in the filter menu: Kameron · Kameron's agents · Jeff · Jeff's agents · Unknown. It's multi-select with counts, like Inbox. By default everything is shown, and it's stored as the hidden senders. Reset clears it, and the button's accessible name spells out the selection.
  3. Shared helper at @t3tools/client-runtime/state/thread-attribution, so every client resolves a sender the same way. Rules, in order:
    • A human inbox.origin or requestedBy names that founder.
    • Work an agent started takes its founder from requestedBy, else owner, else its parent thread's sender. That makes it "X's agents".
    • Only history with no inbox fields (from before inbox routing) falls back to the machine's owner.
    • Otherwise it's Unknown. Nothing is guessed.
  4. Settings → Threads → Inbox → Machine owners: one Kameron / Jeff / Not set choice per known machine, saved per device as founderByEnvironmentId. Nothing is hard-coded.
  5. CI runs the new helper test.

Choices worth knowing

  • Refiling an agent thread can change its sender. Following the requested rule order, the owner comes before the machine. An agent thread with no human requester that gets routed to Jeff therefore reads "Jeff's agents".
  • Notifications ignore the From filter. They still follow Inbox and Environments, because the coordinator doesn't have the parent chain this needs.
  • Agent work with no founder anywhere shows as Unknown, even on a machine with an owner. That covers threads filed to Agents with no human requester or owner, and no parent that names one. A shared machine runs both founders' agents, so crediting that work to the machine's owner would be a guess. They resolve once filed to a founder.
  • Mobile doesn't use the helper yet. Only web imports it. Mobile has no client-settings store for the machine-owner map, and no inbox filter today. The helper lives in client-runtime so a mobile pass can reuse it.
  • The search results list shows no badge.

Review round

One independent bot review (Claude Sonnet 5.5 via T3 delegation) at `32cbb62238`: no blocking findings. A Codex attempt before it hit a rate limit and reviewed nothing.

Fixed in `298b6000ca`:

  • Machine fallback (1): it now applies only to history with no inbox fields, and a test covers unowned and orphaned agent work on a machine with an owner.
  • Mobile claim (2): the description no longer says mobile uses the helper.
  • Stable empty owner map (3).
  • Machine owners are read at edit time (4), so quick edits don't overwrite each other.
  • Higher-contrast "?" (5).

Skipped: which thread inside a malformed lineage cycle gets which sender (6).

Screenshots (dev server with demo data, after the fix)

The From section with every sender kind: a thread Kameron started, an agent thread filed to Kameron, two agent threads filed to Jeff, and two unowned agent threads shown as Unknown:

From section

Row badges: "K", "K" with a bot icon, "J" with a bot icon, and "?":

Badges

Machine owners:

Machine owners setting

Verification

  • vp test run on threadAttribution.test.ts (founder, agents, parent chain listed out of order, machine fallback, Unknown, a lineage cycle), threadListFilter.logic.test.ts (From facet counts, notifications skipping From), threadInbox.test.ts, settingsSearch.test.ts, Sidebar.logic.test.ts and Sidebar.browser.test.tsx: 6 files, 139 tests passed. After the review fix, the helper, filter-logic and Sidebar tests were rerun: 4 files, 102 tests passed.
  • Typecheck of contracts, client-runtime and web is clean; format and lint pass.
  • In a real browser against isolated dev state:
    • Agent threads filed to Kameron read "from Kameron's agents".
    • Agent threads filed to Jeff read "from Jeff's agents".
    • Unowned agent threads on a machine with an owner read as Unknown.
    • A thread a human started reads "from Kameron".
    • The From counts match, and unchecking a sender hides its rows.

Opus 5.5 via Claude Code in T3 Code.

🤖 Generated with Claude Code

@nullStack65

Copy link
Copy Markdown
Owner Author

Independent bot review (Claude Sonnet 5.5 via T3 delegation), head 32cbb62

Scope: only this PR's commit (git diff 01d578e1ac..32cbb62238). I read the code and ran threadAttribution.test.ts and threadListFilter.logic.test.ts: 2 files, 7 tests, all pass. I did not run a dev server.

No blocking findings. There are two should-fix items and four nits. The most important is the first: the machine fallback is wider than the stated rule 3.

Should-fix

1. Machine-owner fallback applies to threads that do have inbox fields, which contradicts rules 3 and 4.
packages/client-runtime/src/state/threadAttribution.ts:70-77

The founder chain ends with ?? founderByEnvironmentId[thread.environmentId] for every thread. The stated rule is that only "history with no inbox fields" falls back to the machine. Anything else with no founder should be Unknown.

  • Failure scenario: an agent launches a top-level thread into the Agents inbox. It has origin = agent, requestedBy = agent (makeThreadInbox defaults requestedBy to the actor), owner: null and no parent.
  • Rule 2 gives no founder, so rule 4 says Unknown. With founderByEnvironmentId[asus] = "kameron", the code returns kameron-agents.
  • The same happens when the parent isn't in the threads list (byKey.get returns undefined) or when it resolves to Unknown. The result is a founder badge on a thread nothing says belongs to that founder, which is the guess rule 4 forbids.
  • It also makes every agent thread on a mapped machine look like that founder's, so the From filter loses its Unknown bucket.
  • The test at threadAttribution.test.ts:63-80 only covers inbox-less history and cycles with no machine map. It never covers an inbox-bearing agent thread on a mapped machine, so this passes unnoticed.

Fix: apply the machine fallback only when the thread has no inbox:

const machineFounder = inbox ? null : (founderByEnvironmentId[thread.environmentId] ?? null);

Then add a test with an agent inbox, no requester/owner/parent, and a mapped machine, expecting unknown.

If you meant to treat "inbox exists but names nobody" as history too, say so in the PR text and in rule 3. As written, the code and the stated rules disagree. The screenshots ("Agent threads on a machine owned by Kameron read from Kameron's agents") suggest this may be the intent, so decide which one is right.

2. The PR description is wrong about mobile.
The "Choices worth knowing" section says "Mobile uses the same helper but shows no badge yet." Nothing under apps/mobile imports @t3tools/client-runtime/state/thread-attribution. The helper is used only by apps/web (Sidebar.tsx, SidebarThreadRow.tsx, SidebarThreadFilterMenu.tsx, threadListFilter.logic.ts). Mobile does not use it. Correct the text to "No mobile client uses it yet".

Nits

3. Memoization is not protected against Sidebar re-renders.
apps/web/src/components/Sidebar.tsx:1111-1113

resolveThreadAttributions(threads, founderByEnvironmentId ?? {}) runs on every Sidebar render. Each run allocates two Maps plus a template-string key per thread, and attributionOf builds another key string on each call.

  • The rows themselves are safe. SidebarThreadRow is memo'd and receives attribution as a string primitive, so there is no extra row churn. attributionOf is passed only to the filter menu, which already received a fresh countedThreads closure each render.
  • The cost is O(n) work on renders that don't change threads (hover, search typing, modifier keys).
  • ?? {} also creates a new object each render, which would defeat a useMemo keyed on it.
  • Fix: useMemo(() => resolveThreadAttributions(threads, founderByEnvironmentId ?? EMPTY), [threads, founderByEnvironmentId]) with a module-level EMPTY.

4. The Machine owners row can drop a rapid second edit.
apps/web/src/components/settings/NewThreadInboxSettings.tsx:46-52

setOwner copies the owners closure from the last render and writes the whole record. Two quick changes before a re-render, or a concurrent write from another tab, can overwrite the earlier one. persistClientSettingsUpdate in useSettings.ts:248, documented as "reapply to newer snapshots to avoid losing concurrent changes", exists for this read-modify-write case.

  • The row also shows entries only for known environments, so a stale entry for a removed machine stays in the saved record. That is harmless.

5. Accessibility details on the badge.
SidebarThreadRow.tsx (ThreadAttributionBadge)

  • The badge sits inside aria-hidden wrappers and the row's accessible name carries "from X". That is correct for screen readers.
  • Sighted users get a bare "K" or "J" with a small bot icon and no tooltip or title that names the sender, so "K" and "K + bot" rely on the icon alone. Consider a title with THREAD_ATTRIBUTION_LABELS[...].
  • The Unknown "?" uses text-sidebar-muted-foreground/60 at text-2xs, which is probably below 3:1 contrast.
  • The From menu items use aria-label ("From Kameron, 3 active", plus the "last one shown" note when disabled). That matches the Inbox and Environment items. No finding there.

6. A cycle's result depends on traversal order.
threadAttribution.ts:50-77

The cycle guard works (a and b terminate), but the first node entered resolves its parent without its own contribution, and that partial result is cached. Which of the two gets which attribution depends on iteration order. This only matters for malformed lineage and is acceptable. Mention it in a comment, or skip it.

Checked and fine

  1. Rule order. humanFounder(origin) then humanFounder(requestedBy) then agent owner then the parent's founder is the stated order. X-agents is applied only when the thread was agent-started and has no human origin.
    • One edge: createdBy === "agent" with no agent origin (or no inbox) skips owner and parent and goes straight to the machine. That is covered by finding 1's fix.
  2. Parent recursion. parentThreadId is a bare ThreadId (orchestrationV2.ts:169), so a parent is always in the child's own environment. Keying the parent as ${thread.environmentId}:${parentThreadId} is correct, and there is no cross-environment parent to resolve. Parents listed after their children resolve correctly because the helper memoizes recursively, and the test covers that.
  3. Settings schema round trips. ThreadAttribution is the same literal set in the full schema and the patch. founderByEnvironmentId is an optionalKey Record(EnvironmentId, Founder) in both. updateClientSettings replaces whole values ({...snapshot, ...patch}), so the hidden-senders array and the record round trip as whole values. Absent keys stay absent. No other file lists client-settings keys that would need updating (checked with grep).
  4. Filter logic. The facet counts exclude only the section being counted, which matches the existing Inbox and Environment behavior. Notifications skip From when attribution is undefined, as the PR says. Reset clears the new key. The last-checked-option guard matches the other sections.
  5. Anti-overengineering. The helper is a single pure function. The change adds no new store or new RPC, and it extends the existing menu instead of adding a control. The generic T on the menu's attributionOf is a bit more than needed but small. I have no objection.
  6. CI. The new test is added to the explicit list in .github/workflows/closura-arc-ci.yml.

Test gaps

  • A mapped machine with an inbox-bearing agent thread and no founder (finding 1).
  • A parent that is absent from the list.
  • Two environments with the same thread id (the keying handles it; a one-line test would pin it).

@nullStack65
nullStack65 changed the base branch from feat/native-0.1.10-sidebar-filter-menu to release/native-0.1.10 November 18, 2026 21:55
nullStack65 and others added 2 commits November 18, 2026 21:56
Kameron wants to tell his own and his agents' threads apart from Jeff's.
Each row now carries a small sender badge (K or J, plus a bot icon for agent
work, "?" when nothing says), and the filter menu gains a multi-select From
section with counts: Kameron, Kameron's agents, Jeff, Jeff's agents, Unknown.

The attribution helper lives in client-runtime so every client resolves it
the same way: a human origin or requester names the founder; agent work takes
its requester's or owner's founder, else its parent's; history with no inbox
fields falls back to the machine's owner, chosen per machine in Settings >
Threads > Inbox > Machine owners. Nothing is guessed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Routed agent work with no founder in its requester, owner or parent chain is
now Unknown instead of the machine owner's agents: a shared machine runs both
founders' agents, so that would be a guess. Also keeps the empty owner map
stable across renders, reads machine owners at edit time so quick edits don't
overwrite each other, and raises the contrast of the "?" badge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nullStack65
nullStack65 force-pushed the feat/native-0.1.10-thread-attribution branch from 298b600 to 2eddce7 Compare November 18, 2026 21:56
@nullStack65
nullStack65 merged commit 2349389 into release/native-0.1.10 Nov 18, 2026
2 checks passed
@nullStack65

Copy link
Copy Markdown
Owner Author

Fleet build artifacts from release/native-0.1.10 at 2349389883, which includes PRs 77, 78, 79 and 82. Built on ASUS with the same recipe as the c5408753 build. Not installed anywhere; install and restart belong to the fleet cutover owner.

Artifact Path on ASUS sha256 Checks
Linux x64 headless server (t3 serve, ASUS and R720) ~/.local/share/closura/t3-release-staging/closura-fleet-server-0.1.10-23493898/t3-0.1.10-linux-x64.tar.gz af6dceaa9d6c8e4afe081bd8f409469f85d89ffa7157c867ce0895506ed98507 smoke-cli-archive.ts --expect-version 0.1.10 passes (--version, service launcher, serve). Max GLIBC 2.34. Linked environments defaults on. Build steps are in manifest.json.
Linux x64 desktop AppImage (laptop) ~/.local/share/closura/t3-release-staging/closura-fleet-desktop-0.1.10-23493898/T3-Code-0.1.10-x86_64.AppImage 15a398d7eb91f91cf90a7d5c67c0c2bbf0971346c8a3b5d4db921d8e54aa40ea Built with build-linux-desktop-noble.sh --build-version 0.1.10 --provide-build-tools. No app-update.yml, so no update feed. Bundled server reports 0.1.10. manifest.json has failed_gates: [].
Linux x64 desktop .deb same folder, T3-Code-0.1.10-amd64.deb 0ed9ce8f99f38c9d2d996dfe7b1311441b98510760d94f05d04ebae66c307747 Same build.

Qualification note: with the committed qualify script, this AppImage fails two founder inbox marker gates, because PR 79 renamed founderInboxView to founderInboxFilter and removed the "All threads" picker. The app is fine; the markers were stale. PR 86 (#86) updates them. The manifest above was produced with that script and passes every gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant