Skip to content

Port upstream 0.66.0: Doubao Agent Plan tray icon fallback - #637

Closed
Finesssee wants to merge 2 commits into
port/upstream-0.66.0from
port/micro-0.66.0-doubao-agent-icon
Closed

Finesssee wants to merge 2 commits into
port/upstream-0.66.0from
port/micro-0.66.0-doubao-agent-icon

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

An account that has only Doubao Agent Plan lanes (no Coding Plan session/weekly) drew a 0% tray icon: coding_plan_snapshot filled the missing session with a non-informational RateWindow::new(0.0) and the shell never looked at the doubao-agent-* extras.

  • The missing Coding Plan session is now the canonical informational placeholder (RateWindow::no_active_session()), so no 0% is invented.
  • The provider declares which extras may stand in for an absent core icon lane: doubao-agent-session -> primary, doubao-agent-weekly -> secondary (new in-memory NamedRateWindow::icon_fallback: Option<IconLane>, same pattern as the existing fallback_lane). Team and monthly buckets carry no hint.
  • usage_metric.rs resolves the hints generically (with_icon_fallbacks): a lane is filled only when the primary is informational / the secondary is missing, with the extra's own percent, window minutes and reset. There is no provider-name branch in shared code. Lanes absent on both sides stay absent.
  • The reported snapshot (identity, lanes, extras) is unchanged; only the metric/icon selection view is resolved. iconFallback is exposed on the bridge DTO and types/bridge.ts (serialised only when set).

Upstream reference

Ported / Deferred

Ported: both upstream test cases (4 coding-lane combinations; levels session, agent_5h, agent_weekly, agent_monthly, agent_team_5h) as Rust tests in rust/src/providers/doubao/icon_lane_tests.rs and apps/desktop-tauri/src-tauri/src/usage_metric.rs.

Notes:

  • Upstream's icon is always (primary, secondary). Win-CodexBar's icon is (selected metric, companion). The four-combination test pins the explicit Session metric, which reproduces upstream's pair exactly. Under Automatic, Doubao still ranks extras as before (highest window), unchanged by this PR.
  • The informational primary now shows the standard "No active 5h session" row for Agent-Plan-only accounts instead of a fake 0% row (intended).
  • Nothing deferred.

Validation

  • cargo +1.98.0 fmt --all: clean
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass
  • cargo +1.98.0 test -p codexbar doubao: 13 passed (3 new)
  • cargo +1.98.0 test -p codexbar-desktop-tauri usage_metric: 22 passed (4 new)
  • cargo +1.98.0 test -p codexbar (full): 2162 passed, 1 failed: claude_swap::runner::tests::timeout_does_not_hang_on_a_pipe_holding_descendant is load-flaky and passes alone (1 passed)
  • cargo +1.98.0 test -p codexbar-desktop-tauri (full): 465 passed, 1 failed: commands::tests::bootstrap_payload_exposes_every_provider_variant (79 vs 78). It fails identically on the unmodified base origin/port/upstream-0.66.0, so it is not caused by this PR.
  • pnpm --dir apps/desktop-tauri run build: pass; run lint: only pre-existing warnings in untouched files

Affected areas

  • Provider (Doubao) / shared core snapshot model
  • Tray icon / metric selection
  • Settings, float bar, CLI

UI proof

Pending: coordinator will capture CUA proof on a fresh build. CODEXBAR_SEED_USAGE_JSON seeds Codex only, so a Doubao tray proof needs a real Agent-Plan-only account or a unit-level proof; unit-level coverage is in the tests above.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Finesssee commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

CUA proof (attempt 1)

Result: FAIL on assertion 3 (tray icon lanes). Team-plan 91% reaches the icon.

  • Build commit: ba6c3df0c88fb9a3849346b79335d3130a8d7e96 (equals PR head at capture time; no rebuild).
  • Proof-only patches (not committed, reverted in the worktree): workspace Cargo.toml [patch.crates-io] dirs = { path = ".../port-audit/proof-shim/dirs" } plus the resulting Cargo.lock. No source changes, no seed; the real Doubao fetch path runs against a mock arkcli.cmd (agent-plan 42%/67%, agent-plan-team 91%/88%, coding-plan unsubscribed).
  • Isolated home under port-audit\proof\637\home; the user's real settings were not touched. Only Doubao is enabled; no personal data visible.
  • Commands: bash launch.sh trayPanel, then bash launch.sh settings:providers; driven with the cua-driver CLI (mcp stdio session for stateful element tokens, get_window_state, click, get_desktop_state, zoom).
# Assertion Result Evidence
1 No real account/personal data visible PASS panel, settings, tray overflow show only mock Doubao (plan "oauth", source arkcli)
2 Tray panel rows: 5-hour 42%, Weekly 67%, team 91/88, informational primary PARTIAL Panel shows "Requests: No active 5h session" and "5-hour 42% used" only; Weekly 67% and team rows are not in the tray panel (all five rows are checked in Settings options, so not hidden by the user)
3 Icon lanes top 42% used, bottom 67% used; must not reflect 91/88 FAIL Zoomed icon: top lane color is orange (RGB ~255,146-158,0 = High level, 80-95%), bottom lane amber (~255,206,5 = Medium, 50-80%). 42% would be green. Fill widths ~10.5px vs ~8px of the bar, about 88-91% and 67%. Consistent with Automatic selecting the max over all non-informational windows (automatic_window includes every extra_rate_windows entry, so team 91% wins), with the agent weekly 67% as companion lane
4 Tooltip shows 42%, not 0%/91% N/A Tooltip reads CodexBar / Doubao: No active 5h session (no percent; tooltip path not changed by this PR)
5 Settings Doubao detail same rows; webview dark under theme auto PASS Session: No active 5h session; 5-hour 42%, Weekly 67%, 5-hour 91%, Weekly 88%; dark theme held
6 No auth error / no error state PASS Doubao shows data, "arkcli, Updated 9d" (mock updated_at), no error state

Suggested cause: in usage_metric.rs, with_icon_fallbacks fills the primary/secondary lanes correctly, but select_window then runs Automatic over all extras, so the team 91% extra becomes the selected (top) lane. Hint-less extras (team, monthly) should not take part in icon selection for Doubao.

Screenshots (local, not committed), all under %LOCALAPPDATA%\Win-CodexBar\port-audit\proof\637\shots\:

  • panel2.png (tray panel), settings-doubao.png (Settings, Doubao detail)
  • tray-overflow.png, tray-icon-zoom.png, tray-icon-zoom-x12.png (icon)

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Reviewed by Claude (fix for the CUA attempt 1 failure on ba6c3df; Codex not used per operator request to use fewer agents)

Fixes for the three CUA findings:

  1. Tray icon lanes: a provider that declares icon-lane fallback hints (Doubao Agent Plan) now renders its two lanes directly under Automatic (top = agent 5-hour 42%, bottom = agent weekly 67%). Extra windows without a hint (team, monthly) no longer take part in Automatic selection, so team 91%/88% cannot reach the icon or the selected metric. Explicit metric preferences are unchanged.
  2. Tray panel: the compact overview shows two rows and the informational "No active 5h session" placeholder consumed one of them. It now yields its slot when two measured lanes exist, so the panel shows 5-hour 42% and Weekly 67%. Team rows remain in the full detail (Settings); the compact panel is limited to two rows by design, so plan assertion 2's team rows are not expected there.
  3. Tooltip: headline_window now uses the same Agent Plan fallback when the primary is informational, so it reads a percent (42%) instead of "No active 5h session".

Tests: new doubao_automatic_icon_uses_agent_lanes_not_team_windows (icon 42/67, selected metric 67, tooltip window 42) and a MenuCard compact-overview test.
Commands: cargo +1.98.0 fmt --all; clippy -D warnings on the Tauri crate (rust crate untouched); tauri crate tests 466 pass, 1 fail (commands::tests::bootstrap_payload_exposes_every_provider_variant, provider catalog size, code this PR does not touch); vitest MenuCard + TrayPanel pass.
Needs CUA re-proof on the new head.

@Finesssee

Finesssee commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Result: PASS on build 8c065d2d47504e525952e4469b9426b9bd498d92 (current PR head, "Fix CUA regression"). The three things that failed on ba6c3df0 are fixed wherever a webview can check them. The tray icon and native tooltip can't be reached over CDP, so unit tests cover them (see below).

At the maintainer's direction, this proof drove the app's WebView2 over CDP with the browser-use CLI (0.1.13) instead of CUA. It used no keyboard, mouse or focus, and the proof windows were kept on the second display.

Setup

  • Build: debug tauri:build:debug at 8c065d2d, detached worktree.
  • Proof-only patch: a workspace Cargo.toml [patch.crates-io] dirs = { path = ".../port-audit/proof-shim/dirs" } driven by CODEXBAR_PROOF_HOME, plus the resulting Cargo.lock change. It was reverted after the build and never committed. There are no source changes and no seed.
  • Data path: the real Doubao fetch_usage path with usage_source = "cli". ARKCLI_PATH points at a mock arkcli.cmd that prints a fixed arkcli usage plan JSON, shaped like the arkcli fixture in rust/src/providers/doubao/mod.rs:
    • agent-plan: session 42%, weekly 67%
    • agent-plan-team: session 91%, weekly 88%
    • coding-plan: subscribed=false
  • Refresh: every refresh re-runs the mock. A per-call counter logged 500 invocations during the run, and the data stayed identical, so the earlier "Authentication required" replacement cannot happen.
  • Isolation: USERPROFILE, HOME, APPDATA, LOCALAPPDATA and the provider homes all point into the kit's home\. Only Doubao is enabled and the theme is auto.
  • Commands: bash launch.sh trayPanel (exports WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9335 ...), then BU_CDP_URL=http://127.0.0.1:9335 BU_NAME=proof-637 BH_TAB_MARKER=0 browser-use <<'PY' ... PY. The scripts used list_tabs, switch_tab, the AX tree, click_at_xy, js, and cdp Page.captureScreenshot. Settings was opened with invoke('open_settings_window', {tab:'providers'}), and refreshes were triggered with invoke('refresh_providers').

Results

# Assertion Result
1 No real email or account from the host is visible. DOM scan of the panel, settings and float bar found no @ addresses and no host user name; the plan shows only oauth. PASS
2 The tray panel overview (compact) shows 5-hour 42% used and Weekly 67% used. The informational "No active 5h session" row no longer takes one of the two slots (the MenuCard fix). PASS
3 The tray panel Doubao detail shows Requests "No active 5h session" (informational, not 0%), agent 5-hour 42%, Weekly 67%, and the team rows 5-hour 91% and Weekly 88%. PASS
4 Bridge get_cached_providers: primary.isInformational=true, secondary=null. Only the agent session and weekly windows carry iconFallback (primary / secondary); the team windows have none. selectedMetric = 67 (Automatic picks the higher agent lane and never the team 91/88), which matches doubao_automatic_icon_uses_agent_lanes_not_team_windows. PASS
5 The float bar (a webview surface for selectedMetric) reads 67%, with the tooltip "Doubao: 67% used". It is not 91% and not 0%. PASS
6 After two forced refresh_providers calls plus the background refreshes, the data is unchanged (42/67/91/88, error=null). PASS
7 Settings → Providers → Doubao detail shows the same rows: Session "No active 5h session", 42%, 67%, 91%, 88%. PASS
8 Dark under theme auto: matchMedia('(prefers-color-scheme: dark)') is true on the panel, settings and float bar. Panel and settings body background is rgb(28,28,30) with text rgb(245,245,247). PASS
9 The top tray icon lane is 42% (not the team 91%) and the bottom lane is 67%. Not covered (native, no CUA per user). Covered by the unit test doubao_automatic_icon_uses_agent_lanes_not_team_windows (selected_usage_icon_windows → 42 / 67).
10 The tray tooltip and menu headline show 42%, not 0%. Not covered (native, no CUA per user). Covered by the same test (tray_bridge::headline_window → 42).

Screenshots

All paths are under %LOCALAPPDATA%\Win-CodexBar\port-audit\proof\637\shots\:

  • bu-panel-overview.png: compact panel with 42% and 67%
  • bu-panel-doubao-detail.png: panel detail with the informational session row and the 42 / 67 / 91 / 88 rows
  • bu-settings-providers.png and bu-settings-doubao.png: settings Doubao detail, dark theme
  • bu-floatbar.png and bu-floatbar-4x.png: float bar. The white text is not visible in the capture because the window has a transparent background; the 67% value comes from the DOM.

Not blocking

  1. Settings sidebar shows 0% for Doubao. The sidebar row under Settings → Providers uses the frontend selectSingleMetricUsageWindow (primary, or secondary when primary is informational). It ignores iconFallback and selectedMetric, so an Agent-Plan-only account shows the informational placeholder as 0%. This PR didn't cause it (before the PR the primary was a measured 0% and also showed 0%), but it's the one surface that still disagrees with the tray and float bar. A follow-up could switch it to selectedMetric.
  2. Refresh loop with the stale mock timestamp. The mock's updated_at is 9 days old, and with it the app called arkcli about 4 times a second: 500 calls during this run. That comes from the refresh engine, which this PR doesn't touch, not from the PR's selection code. It may deserve a separate look.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Port re-review: Doubao Agent Plan tray icon fallback (#637, GAP row 8b of 0.66.0)

Re-checked the branch at the current head 8c065d2d against the 0.66.0 manifest spec for item #8b / PR 8 (upstream Doubao Agent Plan icon fallback, release 0.66.0) and the full CUA fix/proof thread.

What I verified at the current head:

  • Icon-lane fallback hints: the provider declares icon-lane fallback hints so its two agent lanes (5-hour, weekly) render directly under Automatic; extra windows without a hint (team, monthly) no longer take part in Automatic selection, so team 91%/88% cannot reach the icon or the selected metric. Explicit metric preferences are unchanged. Covered by doubao_automatic_icon_uses_agent_lanes_not_team_windows (icon 42/67, selected metric 67, tooltip window 42).
  • Compact overview fix: the informational "No active 5h session" placeholder yields its slot when two measured lanes exist, so the tray panel shows 5-hour 42% and Weekly 67% (MenuCard fix, with a test).
  • Tooltip/headline: headline_window uses the same Agent Plan fallback when the primary is informational, so it reads a percent (42%) instead of "No active 5h session".
  • Existing evidence at this head: CUA attempt 1 FAIL (tray icon lanes) → Claude fix round (three CUA findings) → browser-use UI proof PASS on the current head 8c065d2d: real fetch_usage path with a mock arkcli, agent session 42%/weekly 67%, team rows only in detail, float bar 67%, bridge selectedMetric=67, dark under auto, no personal data. Native tray icon/tooltip not reachable over CDP (per user direction) and covered by the unit tests above.

Result: no new findings. The port matches the upstream Agent Plan icon-fallback semantics; the regression found in the first proof is fixed and proven at the current head. Tray metrics file stays under the cap; no dependency, locale or bridge-shape change beyond the existing iconFallback flags.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Combined build of integrate/v0.70.0-ports at ddd85594 (all 40 port PRs and the follow-ups). Debug desktop build in proof mode, isolated config/data dirs, driven by browser-use over the WebView2 DevTools protocol with DOM events only (no mouse or keyboard input, no focus changes). All data is synthetic: local mock servers for L1, a seeded usage snapshot plus synthetic local logs for L2.

Scenario Check Result
L1 tray (mock servers) #637 overview: Doubao compact card keeps placeholder + agent + team rows PASS
L1 tray (mock servers) #637 Doubao detail: 'No active 5h session' + agent 42/67 + team 91/88 PASS
L1 tray (mock servers) #637 float bar: Doubao pill reads 67% ('Doubao: 67% used'), not 91% or 0% PASS
L1 mock request logs #637 Doubao: arkcli stub invoked by the provider PASS

Every surface also passed the privacy check (no email-like text, account e-mail nodes or profile paths in the DOM) and theme auto rendered dark on the tray flyout, float bar and settings windows.

Validation at ddd85594: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p codexbar (3567 passed, 0 failed) and cargo test -p codexbar-desktop-tauri (606 passed, 0 failed). Screenshots were captured for each scenario and kept with the local proof kit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
junglesub-bot Bot pushed a commit to junglesub/Win-CodexBar that referenced this pull request Oct 4, 2026
…on fallback

Conflict in tray_bridge.rs: the release moved the tray status helpers to
tray_presentation.rs, so the block stays removed and the Agent Plan
headline fallback goes into tray_presentation::headline_window (the PR
test now calls it there).

Conflict in MenuCard.tsx: the release shows every quota row in compact
Overview (upstream 0.62.0 steipete#2616), so the PR's two-row slot rule for the
informational placeholder has nothing to protect. The release filter is
kept and the PR test now checks that both Agent Plan lanes show next to
the placeholder.

usage_metric.rs: both test sets kept. Release-only NamedRateWindowSnapshot
test literals (usage_metric, tray_presentation_tests) get
icon_fallback: None.
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