Skip to content

FIX-2398: Teammates shows what each coding task spent - #4710

Merged
jhoffner merged 5 commits into
fix/fix-2382-teammatesfrom
claude/project-thread-t857lk
Nov 4, 2026
Merged

jhoffner merged 5 commits into
fix/fix-2382-teammatesfrom
claude/project-thread-t857lk

Conversation

@jhoffner

@jhoffner jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

The problem

The Teammates lab shows a coding task's harness and model, but not what the task cost. You can't choose between Claude Code, Codex and Cursor by cost. Each task row already carries its spend (FIX-2288), and PR 1 (#4423) added the vendor's charge to orchestration's folded view. The lab doesn't read any of that yet.

What this does

  • The task's line in the thread shows tokens, plus the charge when the vendor reported one, after the harness tag: 14.7k tokens · $0.42.
  • The task's popup shows the model, with input and output apart: gpt-5.5-codex · 12.4k in · 2.3k out · $0.42.
  • Chief of Staff's panel totals that conversation's coding tasks: Coding tasks: 23.9k tokens · $0.42.
  • A run billed by subscription shows tokens and no dollar figure, never $0.00.
  • Cursor's host now passes onActivity, as Codex's already does. Spec D1 found this was the one thing Teammates dropped.

Each figure is read from the row's spend, which toBoardTask folds with orchestration's taskSpendView (the same fold it already used for harness and model). It's drawn through a byte copy of the registry's spend item.

This is PR 4, the last app PR in the spec's plan. PRs 1, 2 (#4602), 3 (#4522) and 5 are merged. It's stacked on FIX-2382's Teammates PR #4709, because both edit the task popup.

What's asked of you

Nothing to decide. Merge after #4709.

Decided, not asked: the spec's "Background list total" is now Chief of Staff's panel total. The lab no longer has a Background list, and its panel lists the same tasks. The total adds up the per-task views. It doesn't fold the ledger again. Attempts aren't shown: the row's attempts also counts re-claims (task schema), so it would overcount.

Parts worth reviewing closely

  • labs/teammates/src/adapter.ts: spendViewOf now returns the whole view, and BoardTask.spend carries it. An unreadable ledger reads as no spend, so the row still renders.
  • labs/teammates/src/components/TeammatePanel.tsx → CodingSpend. It shows the cost only when some task reported a charge.
  • The popup's line is marked data-task-spend, not data-step. It isn't a run step, and the screen test pins the step order.

Verification

  • labs/teammates/test/task-spend.test.tsx has six cases: card with charge, card with subscription, popup, panel total, a stored ledger folded by the adapter, and no spend or an unreadable ledger. Red states: removing the card's Spend fails the two card cases. Removing the popup's or the panel's fails its own case. Removing spend from toBoardTask fails the stored-ledger case.
  • The full Teammates suite passes (24 files, 173 tests), as do pnpm typecheck and pnpm fallow:new-dead-code against the base.
  • The fixture lab's Codex run reports a charge and its Claude Code run reports tokens only, so the screen tests exercise both billing kinds.

No changeset: Teammates is a private lab.

Links: FIX-2398 · epic FIX-2369 · spec #4398 · base #4709


Generated by Claude Code

A coding task's line gives its tokens and, when the vendor reported one, the
charge; its popup gives the model with input and output apart; the teammate's
panel totals its coding tasks. All read from the row's spend, folded by
orchestration's taskSpendView, through the registry's spend copy. A
subscription run shows tokens and no dollar figure. Cursor's host now passes
onActivity, as Codex's does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Nov 4, 2026 9:24pm UTC
flow-state-dev-kitchen-sink Ignored Ignored Nov 4, 2026 9:24pm UTC
flow-state-dev-ui Ignored Ignored Preview Nov 4, 2026 9:24pm UTC
flow-state-dev-build-site Skipped Skipped Nov 4, 2026 9:24pm UTC

Request Review

@jhoffner jhoffner assigned jhoffner and Copilot and unassigned jhoffner Nov 4, 2026
@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

FIX-2398

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T21:22:44.156569Z 86f20e3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Overall: the approach is right. It reads the already-folded taskSpendView, adds no new summing of ledgers, and the registry copy is byte-identical (I diffed all four installed copies against packages/ui/registry/components/spend.tsx). Findings below are in priority order. None block the merge, but #1 is a user-visible correctness question.

1. Panel total mixes two populations (worth fixing here)

TeammatePanel.tsx → CodingSpend: tokens sum over all tasks with spend, but cost sums only over tasks where costUsd != null. With one API-billed task and one subscription task, the line reads 23.9k tokens · $0.42, which looks like $0.42 is the cost of all 23.9k tokens. The test pins exactly this output, so it's an intended shape, but it reads as a bug to the user. Options: label the dollar figure as covering only the charged tasks ($0.42 charged), or show it only when every task with tokens reported a charge. Also, per-task unreported / live flags are dropped in the total, so a run still in flight or missing a source is totaled as if final, whereas the card and popup mark (partial). The total should carry the same (partial) marker if any contributing view has unreported.

2. { ...task.spend, model: null } in TaskCard is a workaround for a missing option

It forges a view to suppress the model in a byte-copied component. Since the copy can't diverge (registry drift test), the lean fix is upstream: a model?: boolean (or hideModel) option on SpendLineOptions in the registry, then re-copy. Not required for this PR, but file it, because the next consumer (Shift Manager's Tasks surface already has its own spend rendering) will hit the same thing.

3. Totaling logic now exists twice

packages/shift-manager/src/lib/usage.ts already totals tokens/cost across tasks. CodingSpend re-implements a smaller version inline in a component. The PR description says "adds up the per-task views", which is the same job. If the registry (or @flow-state-dev/orchestration/tasks) had a sumSpendViews(views) that handled the partial/charged-only semantics from #1 once, both apps would share one definition, and the fix for #1 would land in one place. This PR is a reasonable opportunity because #1 forces touching that logic anyway. If that's too big for a stacked PR, leave a note in the spec/Linear rather than a third copy later.

4. Minor

  • adapter.ts: spendViewOf swallows every exception to null. That's consistent with "row still renders", but a malformed ledger is then indistinguishable from "never ran" (the second test pins both to undefined). Fine for a lab; a console.debug or devtool-visible marker would help diagnosing.
  • spendOf(view) is now a two-line projection of view used once. Could inline into harnessAndModel(...), though keeping it is harmless.
  • data-task-spend wrapper div in Popups.tsx duplicates the data-spend span's role; the test could read data-spend inside the popup instead and drop one attribute. Low value; mention only because the PR explains it as a deliberate choice about data-step ordering, which is sound.
  • isCoding(task.to) gating appears in three places (card, popup, panel filter). A single task.harness != null check would be derivable, since harness is already on BoardTask. Optional.

Not recommended

No larger refactor. The byte-copy-plus-fallow-ignore convention is the established one here (four existing precedents), so I'd keep it rather than propose a shared package import.


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/simplify review (FIX-2398)

Verdict: The overall shape is right for this repo — fold spend in the adapter, render with the same registry Spend line the other workforce UIs use, and prove it with tests. This is a single commit (~249 lines, 10 files), not a sprawling bundle.

What works

  • Vendoring flow-state/spend.tsx via fallow matches kitchen-sink, shift-manager, and claude-code-style; fighting that with a new shared import path would be more complexity, not less.
  • Splitting spendViewOf (full TaskSpendView) from harness/model extraction keeps BoardTask honest for UI while preserving existing harnessAndModel behavior.
  • Wiring Cursor onActivity in host.mts is the minimal harness hook so live spend can update (Codex already had it).
  • task-spend.test.tsx encodes the product rules well (subscription → no $, popup split, panel total, ledger fold).

Simpler alternatives considered (optional follow-ups, not blockers)

  1. spendViewOf vs orchestration — packages/orchestration/src/inbox/row-view.ts already folds row spend the same way; shift-manager reads .spend through taskRowView. Teammates already calls taskRowView in waitingOf. A follow-up could merge to one taskRowView call per toBoardTask and drop spendViewOf + the small spendOf(view) helper, avoiding drift and row as never.
  2. Card line model: null spread — Prefer a SpendLineOptions flag (e.g. hideModel) in the registry copy so the card does not mutate the view object for presentation.
  3. Panel total vs spend.tsx header — The file comment says totals are "never summed here"; CodingSpend correctly sums for the panel but the comment will mislead. Either a one-line exception in the copy's header or a tiny codingTasksSpendLine(views) helper next to spendLine (with a unit test) would keep aggregation rules in one place.
  4. Partial / unreported tokens in the panel total — Summing with (inputTokens ?? 0) can read as fully reported when some tasks are still partial; worth a conscious product call (maybe only sum rows with !unreported and both sides non-null).

Performance: No concerns at lab scale.

Tests run locally: pnpm test task-spend in labs/teammates — 6/6 passed.

Happy to merge as-is; the items above are polish if you want a cleaner second pass.

Open in Web View Automation 

Sent by Cursor Automation: Review For Best Approach

Comment thread labs/teammates/src/adapter.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35ad93d307

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Snob — already tight. No POC.

Read labs/teammates/src/adapter.ts, components/TaskCard.tsx, components/Popups.tsx, components/TeammatePanel.tsx, components/flow-state/spend.tsx, host.mts, test/task-spend.test.tsx, test/fake-lab.ts, README.md, and .fallowrc.json. spend.tsx matches packages/ui/registry/components/spend.tsx byte for byte (and the kitchen-sink, claude-code-style, and shift-manager copies). Also read taskRowView / taskSpendView and packages/shift-manager/src/lib/usage.ts.

A rewrite does not shrink this contract:

  • The registry copy keeps durationText, attempts, and harnessLabel so the file stays the copy fallow ignores. This lab does not call them. Cutting them is a fork.
  • Cursor onActivity is the one feed argument Codex already forwards.
  • spendViewOf is the fold this adapter already used for harness and model, now returned whole. spendOf turns a null harness or model into an absent field so harnessAndModel does not store model: null. Inlining that projection lengthens the call. waitingOf already calls taskRowView for the hold. Reading spend off that same view deletes spendViewOf, and it also runs status normalization (blocked → held) into the live flag. That is a different read.
  • CodingSpend is the panel total this PR decided: sum of the per-task views, a charge only when some task reported one, attempts left off. usage.ts totals the workerUsage query over a period, in different words (12.5 K tokens). A shared summer is new API. spendLine joins with · and has no Coding tasks: prefix, so a fake view is longer and changes the pinned string.
  • { ...task.spend, model: null } hides the model the harness tag already shows, with no new option on the copied component.
  • The data-task-spend wrapper is the marker this PR names so the line is not a data-step. The six tests are six pins: charge, subscription, popup, panel, stored ledger, unreadable ledger.

Left as recorded: panel total in place of a Background list, no second ledger fold, attempts omitted, byte copy, no changeset.

Head 35ad93d3079a1632fe8836bbc3cb7a77ad5a7496.

Open in Web View Automation 

Sent by Cursor Automation: Code Snob

…artial total says so

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG

jhoffner commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Typecheck is red, and the cause is outside this PR. @flow-state-dev/goals typecheck can't resolve Shift Manager's @/lib/utils and @/components/ui/button imports in flow-state/connection-banner.tsx and connection-screen.tsx. Those imports came from FIX-2373.


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiDfgRv9riWiVVdj8JG
@jhoffner
jhoffner added this pull request to stack #4714 November 4, 2026 21:25
@jhoffner
jhoffner added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 82cc9db Nov 4, 2026
20 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-t857lk branch November 4, 2026 21:26
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.

3 participants