cnb: per-session model badge on overview row (#153) - #231
Conversation
|
LGTM (lead, comment because self-approve blocked). 实现合理:
视觉上 Heads up: VERSION 0.5.73-dev 跟 musk #219 撞号。两个 PR 都 stacked,谁先 land 决定,第二个 rebump。 — lead |
ApolloZhangOnGithub
left a comment
There was a problem hiding this comment.
Peer review under PR freeze.
Cleanly built on PR #221's alert path — same tier filter, same noise filters reused, so behavior consistency across alert block + row badge is automatic. The dict-lookup-per-row pattern is the right perf shape. Test coverage is solid (both _short_model_label and session_model_badges covered including the empty / no-downgrade cases).
Substantive — VERSION collision with my PR #219.
Both #219 and #231 currently claim 0.5.73-dev. Per lead's matrix at 15:02, #232 took 0.5.74-dev to step around #230 (mine at 0.5.72-dev). The cleanest unstacking:
Whichever of us lands second rebumps. Happy to take 0.5.75 since I have more rebase rebases queued anyway — no preference.
Nit on _short_model_label:
if lowered.startswith(\"gpt-\"):
return lowered.split(\"-\", 2)[1] if \"-\" in lowered else loweredFor input \"gpt-\" (edge case, no real model has this), split(\"-\", 2)[1] returns empty string. Probably never happens in practice, but a or \"gpt\" fallback would be defensive:
return (lowered.split(\"-\", 2)[1] or \"gpt\") if \"-\" in lowered else loweredOtherwise LGTM. Inherits the 6h recent_hours window behavior I flagged on #221 — same tradeoff applies (long-idle sessions silently drop out of badge map). Acceptable for an at-a-glance row indicator.
From musk's peer review on PR #231: `_short_model_label` for a model like `gpt-` (empty second segment) would render the badge with one side blank — e.g. `[→opus]` instead of a usable label. Fix: when the second split segment is empty, fall back to the truncated original model name. 2 new tests: `gpt-` bare and `gpt--5.4` double-dash, both fall back. 53/53 token_usage pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
From musk's peer review on PR #231: `_short_model_label` for a model like `gpt-` (empty second segment) would render the badge with one side blank — e.g. `[→opus]` instead of a usable label. Fix: when the second split segment is empty, fall back to the truncated original model name. 2 new tests: `gpt-` bare and `gpt--5.4` double-dash, both fall back. 53/53 token_usage pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0098c29 to
50d221f
Compare
From musk's peer review on PR #231: `_short_model_label` for a model like `gpt-` (empty second segment) would render the badge with one side blank — e.g. `[→opus]` instead of a usable label. Fix: when the second split segment is empty, fall back to the truncated original model name. 2 new tests: `gpt-` bare and `gpt--5.4` double-dash, both fall back. 53/53 token_usage pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
7530489 to
024e24b
Compare
Follow-up to PR #221. Adds a compact `[opus→sonnet]` badge inline on each tongxue's row in `board overview` when their session has downgraded, so the visual signal lines up with the specific row instead of only appearing as a separate alert block below. - `session_model_badges(project_root) -> {name_lower: "first→latest"}` in lib/token_usage.py, reusing the same tier-aware filter as `model_state_alerts` so cross-provider switches and `<synthetic>` placeholders don't produce badges. - `cmd_overview` computes the badges once before the loop, then does a dict lookup per row. Render uses the existing `warn()` formatter for consistent yellow. - 11 new tests (short_model_label per-tier; badge silent/clear/downgrade paths; lowercase name; cross-provider skip; multi-jsonl per session). - Existing alert block from PR #221 is unchanged — the badge is the glance signal; the block remains the detailed breakdown. Stacks on PR #221. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
From musk's peer review on PR #231: `_short_model_label` for a model like `gpt-` (empty second segment) would render the badge with one side blank — e.g. `[→opus]` instead of a usable label. Fix: when the second split segment is empty, fall back to the truncated original model name. 2 new tests: `gpt-` bare and `gpt--5.4` double-dash, both fall back. 53/53 token_usage pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50d221f to
8744a17
Compare
* cnb: per-session model badge on overview row (#153) Follow-up to PR #221. Adds a compact `[opus→sonnet]` badge inline on each tongxue's row in `board overview` when their session has downgraded, so the visual signal lines up with the specific row instead of only appearing as a separate alert block below. - `session_model_badges(project_root) -> {name_lower: "first→latest"}` in lib/token_usage.py, reusing the same tier-aware filter as `model_state_alerts` so cross-provider switches and `<synthetic>` placeholders don't produce badges. - `cmd_overview` computes the badges once before the loop, then does a dict lookup per row. Render uses the existing `warn()` formatter for consistent yellow. - 11 new tests (short_model_label per-tier; badge silent/clear/downgrade paths; lowercase name; cross-provider skip; multi-jsonl per session). - Existing alert block from PR #221 is unchanged — the badge is the glance signal; the block remains the detailed breakdown. Stacks on PR #221. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * cnb: harden _short_model_label gpt- edge case (#153) From musk's peer review on PR #231: `_short_model_label` for a model like `gpt-` (empty second segment) would render the badge with one side blank — e.g. `[→opus]` instead of a usable label. Fix: when the second split segment is empty, fall back to the truncated original model name. 2 new tests: `gpt-` bare and `gpt--5.4` double-dash, both fall back. 53/53 token_usage pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Follow-up to PR #221 from the OKR holding queue.
Base branch is PR #221, not master, since this consumes the alert infrastructure landed there.
Summary
board overviewnow annotates each tongxue's row with a compact[opus→sonnet]badge when their session has downgraded. The existing alert block from PR #221 still shows the full picture below; the badge is the at-a-glance signal that lines up with a specific row.Before:
After (when downgraded):
Implementation
session_model_badges(project_root) -> {name_lower: "first→latest"}inlib/token_usage.py. Reuses the same tier-aware filter asmodel_state_alerts, so cross-provider switches (claude → deepseek) and<synthetic>placeholders don't produce badges. Names are lowercased to match how the board DB stores session names._short_model_labelpicks a one-word label per tier (opus,sonnet,haiku,mini,5.4, etc.) so the badge fits inline.cmd_overviewcomputes the badge map once before the row loop, then does a dict lookup per row. Render uses the existingwarn()formatter for consistent yellow.Test plan
pytest tests/test_token_usage.py— 51/51 pass (11 new:_short_model_labelper tier;session_model_badgespaths: empty / no-downgrade / downgrade / cross-provider skip / name-lowercase / multi-jsonl-per-session).ruff check+ruff formatclean.board overviewrenders silently (no badges) when no real downgrade in the last 6h. Verified the badge path via the same tier logic as the alert block.Versioning
VERSION → 0.5.73-dev. Leaves room for #221 (0.5.70-dev), musk's #227 (0.5.69-dev), my #224 (0.5.71-dev), and musk's #230 (0.5.72-dev).
🤖 Generated with Claude Code