Skip to content

feat(native): close PN-TERMINAL and AP-USAGE parity gaps - #432

Merged
rynfar merged 2 commits into
nativefrom
nw/f5-usage-terminal
Nov 19, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/f5-usage-terminal

Conversation

@rynfar

@rynfar rynfar commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Closes the remaining parity gaps for PN-TERMINAL and AP-USAGE in apps/native, bringing both ledger rows honestly to done.

Summary of Changes

  1. PN-TERMINAL — Composer focus tracking & thread-enter focus restoration (crates/app/src/composer/mod.rs, crates/app/src/terminal/drawer.rs):

    • Wired TerminalDrawer::record_composer_focus on composer InputEvent::Focus, question_focus, and Composer::focus (for the active thread or draft:<project_id>, excluding fixed/embedded composers).
    • Wired ThreadEnterFocusDecision::FocusComposer in TerminalDrawer::sync_selection to cancel pending terminal focus and call composer::focus_for_thread, and return focus to the composer when closing an open terminal drawer (toggle / close_terminal).
    • Gated Composer::refresh's unconditional self.focus on !TerminalDrawer::is_active(cx) so the composer does not preempt TerminalDrawer::enter_thread focus decisions.
    • Added GPUI test terminal::drawer::focus_tests::composer_and_terminal_focus_restoration_across_thread_switches.
  2. AP-USAGE (#43) — Multi-environment Usage aggregation, stepped refresh spinner, and DST fall-back zone abbreviations (crates/app/src/usage/{data,header,mod,overview,dialog,limits,prices}.rs, crates/core/src/usage/{format,tests}.rs):

    • Refactored UsageData to track all environments from state.fleet.environments, fan out server.getUsageSummary (provisional → plain → awaitRefresh) and refresh (refreshUsageRates + getUsageSummary) per connected environment in parallel, merge series/breakdowns/limits/coverage diagnostics across selected environments, target redeem_reset and PriceOverridesDialog saves to selected environments, and populate the Environment filter dropdown (All environments + per-env checkboxes & status).
    • Replaced the static refreshing icon with an isolated stepped GPUI RefreshSpinner view (8 steps @ 125ms, repainting only the indicator while refreshing and dropping its timer when idle).
    • Added chrono_tz short zone abbreviation formatting (EDT/EST, falling back to GMT±H for numeric-only zones) for repeated DST fall-back hours in crates/core/src/usage/format.rs and wired it in crates/app/src/usage/overview.rs.
    • Verified existing composer /usage-limits, /compact + compact-before-send, prompt-length validation, and inherited fork context usage (contextTransfers / forkedFrom) already match current web.
    • Added GPUI test usage::tests::multi_environment_usage_fans_out_merges_filters_and_spins_during_refresh and extended t3-core DST formatting tests.
  3. AP-USAGE (#219, pingdotgg/t3code#27760) — Secret-ref Usage Limit Sources in Settings (crates/core/src/usage/limits/{mod->limits.rs,sources.rs}, crates/app/src/settings/providers/{usage_sources.rs},providers.rs):

    • Ported source_id_from_url, ConfiguredUsageLimitSource, decode_usage_limit_sources, ManagementKeyValue (Literal | Reference), and upsert/remove settings patches in crates/core/src/usage/limits/sources.rs with unit tests.
    • Ported UsageProviderSettings, AddUsageLimitSourceDialog (with SecretSourceDraft, SecretSourceSelect, reference validation, SecretCheckButton via server.checkSecretSource, optional label, and stale-draft clearing on env switch/leave/read-only/async replies), and remove confirmation dialog in crates/app/src/settings/providers/usage_sources.rs, wired into crates/app/src/settings/providers.rs.
    • Added GPUI test settings::providers::usage_sources::tests::add_secret_ref_usage_source_validates_checks_saves_and_drops_stale_drafts.
  4. Ledger (apps/native/parity/LEDGER.md):

    • Updated ONLY PN-TERMINAL (partial #249, #224, #235, #390 → done) and AP-USAGE (partial #43, #219 → done).

Verification Gates

  • cargo clippy --workspace --all-targets -- -D warnings: pass (0 warnings)
  • cargo test -p t3-core -- --test-threads=1: 1739 passed, 0 failed
  • cargo test -p t3-client -- --test-threads=1: 150 passed, 0 failed
  • T3_NATIVE_HOME=$(mktemp -d) cargo test -p t3-native --features snapshot terminal -- --test-threads=1: 12 passed, 0 failed
  • T3_NATIVE_HOME=$(mktemp -d) cargo test -p t3-native --features snapshot usage -- --test-threads=1: 5 passed, 0 failed
  • T3_NATIVE_HOME=$(mktemp -d) cargo test -p t3-native --features snapshot providers -- --test-threads=1: 12 passed, 0 failed
  • T3_NATIVE_HOME=$(mktemp -d) cargo test -p t3-native --features snapshot composer:: -- --test-threads=1: 23 passed, 0 failed
  • cargo build -p t3-native: pass
  • vp fmt --check apps/native/parity/LEDGER.md: pass
  • node apps/native/scripts/gen-theme.ts --check: pass
  • node --test apps/native/parity/sync.test.ts: 47 passed, 0 failed

Closes #43
Closes #219
Refs #249, #390

Authored with Antigravity (f5-usage-terminal).

@rynfar rynfar mentioned this pull request Nov 19, 2026
@rynfar
rynfar force-pushed the nw/f5-usage-terminal branch from edd588c to b9b9ae1 Compare November 19, 2026 16:49
rynfar added a commit that referenced this pull request Nov 19, 2026
1. Wrap usageLimitSources save/remove payloads in { "patch": ... }.\n2. Gate UsageProviderSettings edits and scoped dispatch on providers:manage (keeping settings:write on checkSecretSource only).\n3. Load/diff UsagePriceOverrides across all selected environments with per-target settings:write and usageModelAliases capability guards, keeping the dialog open with per-env status and Retry failed on partial failure.\n4. Focus surviving active split terminal pane in PanelTerminalView::close_terminal_confirmed.
Wire composer focus tracking into TerminalDrawer for thread-enter focus restoration and drawer-close fallback (PN-TERMINAL), add multi-environment Usage page aggregation/filtering/prices fan-out, isolated stepped refresh spinner, and DST fall-back short zone abbreviations (#43), and port UsageProviderSettings / AddUsageLimitSourceDialog with literal and SecretReference management keys, checkSecretSource, and stale-draft clearing (#219, `pingdotgg#27760`). Mark PN-TERMINAL and AP-USAGE done in apps/native/parity/LEDGER.md.
1. Wrap usageLimitSources save/remove payloads in { "patch": ... }.\n2. Gate UsageProviderSettings edits and scoped dispatch on providers:manage (keeping settings:write on checkSecretSource only).\n3. Load/diff UsagePriceOverrides across all selected environments with per-target settings:write and usageModelAliases capability guards, keeping the dialog open with per-env status and Retry failed on partial failure.\n4. Focus surviving active split terminal pane in PanelTerminalView::close_terminal_confirmed.
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