Skip to content

Tray-anchored flyout: resize, drag-reorder, zoom + Claude OAuth auto-refresh - #1

Closed
darknight105 wants to merge 2 commits into
combined-buildfrom
feat/tray-flyout-suite
Closed

darknight105 wants to merge 2 commits into
combined-buildfrom
feat/tray-flyout-suite

Conversation

@darknight105

Copy link
Copy Markdown
Owner

Summary

Reworks the tray experience and fixes several Windows-specific bugs found along the way. Built on the local combined-build base (window-mode title controls + canonical Claude pricing), so the diff here is just the two commits below.

  1. Tray flyout suite — "Pop Out Dashboard" becomes a tray-anchored, resizable flyout with drag-reorder and a zoom slider.
  2. Claude OAuth auto-refresh — fixes the recurring "Claude sign-in expired".

Tray flyout (commit 1)

  • Anchored popover above the tray icon (SurfaceMode::TrayPanel): always-on-top, blur-to-dismiss, skip-taskbar; left-clicking the tray toggles it. Previously "Pop Out Dashboard" and "Show Window" both mapped to the same PopOut window and collided.
  • Frontend-owned sizing — auto-fits to content until the user drags an edge, then remembers the manual size (persisted via set_flyout_size).
  • DPI-safe — all sizing in Tauri physical units (innerSize / PhysicalSize) behind an in-flight guard. Fixes a grow-on-every-open bug on 150% displays where logical / physical / Win32 scale factors disagreed.
  • Resize grips — a borderless WebView2 can't drive native edge-resize, so top/left/corner grips call startResizeDragging. Root cause of "grips appear but never work": the core:window:allow-start-resize-dragging capability was never granted, so every call was denied by the ACL and swallowed by a .catch. Now granted (plus core:window:default for innerSize/scaleFactor, which the sizing bookkeeping depends on). ACL-gated calls no longer swallow errors silently.
  • Gesture blur-guard — the Win32 modal resize loop and OLE DoDragDrop each fire a transient Focused(false); without a guard the flyout hid the instant you pressed a grip or started a drag. A gesture-scoped guard suppresses blur-dismiss during the gesture, re-armed on refocus or after a 15s timeout.
  • Drag-reorder — dragDropEnabled: false on the main window so wry stops replacing Chromium's native OLE drop target (that hijack silently killed all in-page HTML5 drag-and-drop; dragover/drop never fired). Order persists via reorder_providers, which now emits settings-changed so the detail cards follow the new order.
  • Zoom — a Windows-volume-style slider in the footer applies CSS zoom to the surface (trayScalePercent, 100–200%, live preview + debounced persist), re-measured live so auto-fit tracks it; the footer pins to the bottom when user-sized; provider cards lay out side-by-side past 640px.
  • Off-screen fix — with no remembered geometry and no tray anchor, prefer the primary monitor so the flyout/popout can't open on a hidden secondary display.

Claude OAuth auto-refresh (commit 2)

The Claude Code OAuth access token lives only ~8h. CodexBar read it but never used the refresh token, so usage requests failed with "sign-in expired" until the CLI happened to refresh it. Now it refreshes proactively when the token is near expiry, atomically writing back the claudeAiOauth block (preserving mcpOAuth), with an in-memory fallback if the write fails and a re-read guard against a concurrent CLI refresh.

Verification

  • tsc --noEmit: clean
  • frontend (vitest): 112 passed
  • backend (cargo test -p codexbar-desktop-tauri): 266 passed
  • tauri build --no-bundle: success
  • Deployed and smoke-tested on Windows 11 @ 150% across dual monitors.

🤖 Generated with Claude Code

darknight105 and others added 2 commits July 3, 2026 23:06
Rework "Pop Out Dashboard" into a tray-anchored flyout (SurfaceMode::TrayPanel)
above the taskbar icon, so it no longer collides with the PopOut window
("Show Window").

- Anchored popover: always-on-top, blur-dismiss, skip-taskbar; left-click on the
  tray toggles it. The frontend owns sizing: auto-fit to content until the user
  drags an edge, then remember the manual size (persisted via set_flyout_size).
- DPI-safe sizing: use Tauri physical units end-to-end (innerSize + PhysicalSize)
  behind an in-flight guard, fixing a scale-factor growth bug on 150% displays.
- Resize grips: a borderless WebView2 can't drive native edge-resize, so expose
  top/left/corner grips that call startResizeDragging. This needs the
  core:window:allow-start-resize-dragging capability, now granted.
- Keep the flyout open during resize/drag: the Win32 modal size loop and OLE
  DoDragDrop each fire a transient Focused(false); a gesture guard suppresses
  blur-dismiss, re-armed on refocus or after a 15s timeout.
- Provider drag-reorder: set dragDropEnabled=false so wry stops hijacking
  Chromium's native drop target, then persist order via reorder_providers and
  emit settings-changed so the detail cards follow.
- Zoom: a Windows-volume-style slider in the footer applies CSS zoom to the
  surface (trayScalePercent 100-200%) and re-measures live; the footer pins to
  the bottom when user-sized, and provider cards go side-by-side past 640px.
- Positioning: with no remembered geometry and no tray anchor, prefer the
  primary monitor so the flyout/popout can't open off-screen on a secondary
  display.

Co-Authored-By: Claude Fable 5 <[email protected]>
The Claude Code OAuth access token lives only ~8h. CodexBar read it but never
used the refresh token, so usage requests failed with "sign-in expired" until
the CLI happened to refresh it. Refresh proactively against the token endpoint
when the token is near expiry, atomically writing back the claudeAiOauth block
(preserving mcpOAuth) with an in-memory fallback and a re-read guard against a
concurrent CLI refresh.

Co-Authored-By: Claude Fable 5 <[email protected]>
@darknight105

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR nesszer#120, rebased cleanly onto main (0.38.0).

@darknight105
darknight105 deleted the feat/tray-flyout-suite branch July 3, 2026 15:30
darknight105 added a commit that referenced this pull request Jul 3, 2026
…che by source

Addresses review items #1 and nesszer#2 (structure/ownership, not behavior).

#1 — `providers/claude/oauth.rs` had grown to ~1138 lines mixing usage fetching,
refresh HTTP, refreshed-token caching, credential persistence, JSON patching and
tests. Split into a directory module:
  - oauth/mod.rs             — ClaudeOAuthFetcher: usage fetching + orchestration
                               (fetch/fetch_usage/rate-limit/snapshot) + types.
  - oauth/refresh.rs         — the OAuth token refresh HTTP call + its response type.
  - oauth/credentials_store.rs — credential loading (env/file/keyring), persistence,
                               and the refreshed-credentials cache.
The public surface is unchanged: `pub use oauth::ClaudeOAuthFetcher` still resolves
(directory module), and ClaudeOAuthFetcher's external API (new/fetch/
fetch_with_access_token) is untouched.

nesszer#2 — the refreshed-credential cache was a single process-global
`Option<ClaudeOAuthCredentials>` shared across every credential source. Because
`load_credentials` tries env→file→keyring and env tokens have no `expires_at`, a
file-refreshed token could shadow a freshly-read environment token (the
`(Some(_), None) => true` freshness arm). The cache is now
`HashMap<CredentialSource, _>` keyed by an explicit
`CredentialSource { Environment, File(path), Keyring(account) }`; `load_credentials`
returns the source and `ensure_fresh_credentials` threads it through the cache
lookup/store. Regression test `env_source_not_shadowed_by_file_cache` covers it.

Behavior-preserving. cargo check clean; core `codexbar` 490 tests, tauri 280 tests,
frontend 127 tests all green.
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