Daily Report — 2026-04-27

Daily Overview

  • What was done: Debugged and resolved critical Windows platform bugs in TokenMonitor system tray application affecting window focus, process spawning, positioning, hover behavior, warning logic, and visual alignment; also built automated Cursor IDE connection recovery feature
  • How it was done: Combined Win32 API analysis (SetForegroundWindow foreground rights, CREATE_NO_WINDOW flags, work area calculations), multi-layer hover oscillation defense (state-based fake event detection, observer blocking, shrink guards), Rust IPC command additions (open_cursor_app, retry_cursor_auth), and data pipeline logic refinements (dual API fallback, auto-retry polling)
  • Impact: Eliminates all major Windows visual glitches and false positive warnings, breaks feedback loops causing rapid oscillation, automates connection recovery without app restart, and moves TokenMonitor toward production-ready cross-platform support

Fixed 6+ Windows-specific TokenMonitor bugs (tray focus, PowerShell popups, window anchor detection, hover oscillation, warning thresholds, bottom edge alignment) and implemented one-click Cursor IDE auto-reconnect with token refresh polling

Tasks

Architecture & Strategy

  • Root cause diagnosis and fix of Windows hover oscillation bug — Analyzed feedback loop where window resize → position change → fake browser mouseLeave → detail panel toggle → repeat. Implemented three-layer defense: hoveredIdx state check in onLeave timer (300ms delay), observer-driven resize blocking during chartHoverActive, and shrink-guard in applyWindowHeight
  • Implement Cursor IDE auto-reconnect feature — Added open_cursor_app and retry_cursor_auth Rust IPC commands; implemented frontend button with 4-second polling (max 8 attempts, 32s total) that launches Cursor, auto-detects token refresh, and clears warnings without requiring app restart
  • Fix tray icon first-click animation failure — Windows tray icon first click shows blank window; second click works. Diagnosed SetFocus race condition where calling thread lacks foreground ownership, implemented SetForegroundWindow (has implicit tray context rights) with 200ms fallback timeout
  • Implement dynamic window anchor detection — Built anchor detection system (AnchorCorner enum, detect_anchor_corner, AtomicU8 storage) to adapt window positioning to taskbar location and eliminate visual flashing when taskbar is not at bottom
  • Fix Cursor usage warning false positives — Refined dual-pipeline warning logic to only trigger when both rate limits and usage events APIs fail; downgraded usage events failure from warning to logging when rate limits work correctly
  • Fix window bottom-edge alignment and transparency gap — Changed anchored_resize_origin to use work.bottom instead of current_rect.bottom for stable anchor during resize; added data-anchor attribute to conditionally remove bottom border-radius when bottom-anchored to eliminate transparent gap with taskbar
  • Eliminate PowerShell window popups — sqlite3 process spawn in cursor_parser.rs missing CREATE_NO_WINDOW flag, causing console windows to flash on Windows during database operations

Implementation & Fixes

  • Add ‘x of y enabled’ format to Model Visibility settings — Updated HiddenModelsSettings.svelte to show ‘x of y enabled’ format instead of ‘x hidden’, matching Provider visibility UI for consistency

Problems & Solutions

Critical Issues

1. Window height oscillates rapidly (150-200ms cycles) when hovering chart bars, causing detail panel to flash on/off in continuous feedback loop

Solution: Implemented three-layer defense: (1) onLeave timer checks hoveredIdx >= 0 to skip fake leaves, (2) ResizeOrchestrator blocks observer-driven resize during chartHoverActive, (3) shrink-guard prevents window from shrinking during hover

Key Insight: The oscillation was a feedback loop where SetWindowPos changing window position caused browser to fire fake mouseLeave events; breaking the loop required intervention at multiple points, not just blocking resize

2. SetFocus Win32 API requires calling thread to own foreground window, but tray click handler doesn’t have foreground ownership

Solution: Use SetForegroundWindow which has implicit foreground rights in tray icon context, combined with 200ms fallback timer in Svelte to handle edge cases

Key Insight: Win32 foreground window rules are context-dependent: tray icon events grant foreground permission to SetForegroundWindow but not SetFocus; understanding the context is critical

3. Window bottom edge drifts from taskbar during resize, creating visual gap; using current_rect.bottom causes bottom edge to jump unpredictably

Solution: Changed anchored_resize_origin from current_rect.bottom - height to work.bottom - height; work area boundary is stable constant while current_rect reflects intermediate async SetWindowPos states

Key Insight: In async window management systems, ‘current state’ queries during rapid changes return intermediate values leading to instability; anchor to fixed reference points (work area bounds) instead of current state

4. Hardcoded bottom-right anchor causes flashing when taskbar is elsewhere, or window gets repositioned by user or system

Solution: Built dynamic anchor detection: compare window center to work area center, store result in AtomicU8, use detected anchor in all positioning functions

Key Insight: Window anchor must be detected dynamically based on actual position relative to work area, not assumed from default taskbar location

5. Cursor usage warning appears even when rate limits API works correctly, confusing users about actual connection status

Solution: Downgraded remote usage events API failure from set_cursor_warning to logging; only warn when authentication genuinely unavailable (both pipelines fail)

Key Insight: Multi-tier data pipelines serving different features should fail independently - don’t warn user about one pipeline failure when another works

6. Mouse position detection using clientX/Y + getBoundingClientRect failed to prevent fake leave events during window movement

Solution: Abandoned coordinate-based detection; instead used hoveredIdx state check in timer callback - if hoveredIdx >= 0 after 300ms, a re-enter happened, so skip the leave

Key Insight: When window moves, pointermove doesn’t fire (mouse didn’t actually move), so tracked coordinates become stale; state-based detection (hoveredIdx) is more reliable than coordinate-based

7. Users had to manually reopen Cursor and restart TokenMonitor to fix yellow ‘Connected’ warning state when auth token became stale

Solution: Implemented open_cursor_app command for cross-platform app launching (macOS open -a, Windows .exe paths, Linux cursor command) and retry_cursor_auth polling mechanism that automatically detects token refresh and clears warnings

Key Insight: Auto-retry pattern with timer cleanup prevents resource leaks; polling every 4 seconds for ~32 seconds balances responsiveness with resource usage

8. Window bottom edge showed transparent gap due to 14px border-radius when bottom-anchored to taskbar

Solution: Query window anchor direction on startup via get_window_anchor_edge IPC, set data-anchor attribute on , conditionally remove bottom border-radius in CSS when data-anchor=‘bottom’

Key Insight: Transparent windows with border-radius create visual gaps when edges are meant to align with screen boundaries; need conditional styling based on runtime anchor position

9. sqlite3 Command spawn missing CREATE_NO_WINDOW flag causes console windows to pop up on Windows

Solution: Added const CREATE_NO_WINDOW: u32 = 0x0800_0000 and .creation_flags() call with #[cfg(target_os = “windows”)] guard to cursor_parser.rs

Key Insight: All Windows process spawns need explicit CREATE_NO_WINDOW flag; one missed spawn in any module breaks entire UX

Human vs AI Approaches

Strategic Level

Bottom edge ’not moving’ interpretation

Role Approach
Human Clarified ‘bottom edge not moving’ means both window bottom AND content bottom (cache text) should stay visually fixed on screen, not just window bottom coordinate staying constant in logs
AI Initially interpreted as window.bottom coordinate staying constant in logs, missing the visual/content positioning aspect

Difference Analysis: Human focused on end-user visual experience, AI focused on technical measurements; highlights importance of understanding user intent behind technical requirements

Iterative debugging vs complete solution attempts

Role Approach
Human Repeatedly asked to check logs, describe current changes, and verify specific behaviors step-by-step before implementing fixes
AI Attempted to implement complete solutions based on hypotheses without confirming intermediate diagnostic data

Difference Analysis: Human preferred incremental validation of hypotheses, AI tended toward ‘complete fix’ implementations; human’s approach prevented wasted effort on wrong assumptions

Cursor warning conditions and user experience

Role Approach
Human Recognized that if rate limits work, warning is wrong - ‘working’ means ‘don’t warn’ regardless of internal pipeline details; applied holistic UX reasoning
AI Explained dual pipeline architecture accurately but didn’t immediately suggest changing warning threshold until user pointed out UX gap

Difference Analysis: Human applied holistic UX reasoning (working feature = no warning); AI focused on technical accuracy without synthesizing UX implication

Symptom description vs root cause focus

Role Approach
Human Emphasized clear symptom description (‘window jumps up and down rapidly’) before diving into root cause; requested focus on visual behavior user experiences
AI Initially jumped to root cause analysis and technical implementation details without clearly articulating the user-facing symptom

Difference Analysis: Human wanted clear problem statement first (what user sees), AI defaulted to technical diagnosis mode; human’s approach ensures alignment on what we’re actually fixing

User experience improvement for Cursor connection issues

Role Approach
Human Identified opportunity to add a button that opens Cursor and auto-detects when connection is restored, eliminating restart requirement
AI Focused on technical exploration of existing code patterns (connection status, IPC mechanisms, platform-specific launching) and implementation planning

Difference Analysis: Human prioritized end-user pain point elimination; AI translated the UX goal into technical architecture with cross-platform considerations

AI Limitations

Critical Limitations

  • Initially focused on preventing resize rather than understanding that the oscillation was caused by fake mouseLeave events from window movement, not from resize itself; took multiple turns to identify the feedback loop
  • Over-reliance on log analysis without seeing actual console output; added console.warn logs but couldn’t verify if chartHoverActive was actually being set without user manually checking devtools
  • Made multiple attempts to modify aligned_window_origin before fully understanding the difference between ‘initial positioning’ vs ‘resize-time repositioning’ and the async nature of SetWindowPos
  • Attempted complex coordinate-based mouse position detection (clientX/Y + getBoundingClientRect) without recognizing that pointermove doesn’t fire when only window moves, leading to stale coordinate tracking
  • Didn’t immediately connect ‘rate limits working’ to ‘warning threshold wrong’ - required user to explicitly point out the UX gap between technical correctness and user-facing behavior

Learnings

Key Learnings

  • Feedback loops in UI systems can have non-obvious triggers: window resize → position change → browser event → state change → resize. Breaking the loop requires identifying correct intervention points at multiple layers
  • Win32 foreground window rules are context-dependent: SetFocus requires calling thread to own foreground, but SetForegroundWindow has implicit rights from tray icon event context - critical for system tray applications
  • Async window management (SetWindowPos) means ‘current state’ queries (GetWindowRect) during rapid changes return intermediate values; stable anchors (work area bounds) are more reliable than querying current state
  • Browser mouse events during window movement are ‘fake’ from user perspective but ‘real’ from browser perspective; need state-based rather than coordinate-based detection to distinguish genuine user actions from window-movement artifacts
  • Multi-tier data pipeline design: when pipelines serve different features (rate limits vs usage events), failure handling should reflect feature independence - don’t block one feature for another’s failure
  • Svelte 5 reactivity timing: $state updates queue DOM changes in micro-tasks, but CustomEvent dispatch is synchronous - can cause race conditions when measurements happen before DOM updates
  • Auto-retry pattern design: use onDestroy/cleanup to prevent timer leaks; balance polling frequency (4s) and max attempts (8) for 32-second window that covers typical auth refresh time
  • Transparent windows with border-radius require careful consideration of anchor position to avoid visual gaps at screen edges; conditional styling based on runtime anchor detection solves this
  • Tauri v2 IPC command pattern: define Rust command with #[tauri::command], register in invoke_handler, call from frontend with invoke(); requires platform-specific handling for external app launching

Conversation Summaries

✅ Windows hover oscillation bug - root cause diagnosis and multi-layer fix 05:35:35.315 | claude_code Diagnosed Windows-specific bug where hovering chart bars caused rapid window oscillation (150-200ms cycles between 1244↔1337↔1364px). Identified feedback loop: window resize → position change → fake browser mouseLeave → detail panel toggle → repeat. Attempted multiple solutions including coordinate-based detection before arriving at three-layer defense: hoveredIdx state check in onLeave timer (300ms delay), observer-driven resize blocking during hover, and shrink-guard in applyWindowHeight. Also fixed bottom-edge transparency gap by conditionally removing border-radius based on anchor direction.

✅ Cursor IDE auto-reconnect feature with token refresh 05:38:14.862 | claude_code Designed and implemented one-click fix for Cursor yellow warning state. Added Rust commands: open_cursor_app (cross-platform app launching) and retry_cursor_auth (token refresh + warning clear). Frontend: button triggers Cursor launch, then polls every 4s (max 8 attempts) until token refreshes. Auto-clears warnings and usage cache when auth succeeds. Includes timer cleanup on component destroy.

✅ Fix Windows tray icon first-click animation failure 05:39:18.949 | claude_code Diagnosed race condition where tray icon first click shows blank window (second click works). Root cause: SplashScreen.svelte animation depends on window focus event, but Win32 SetFocus API requires calling thread to own foreground. Implemented dual fix: Rust-side SetForegroundWindow (has implicit foreground rights in tray context) + frontend 200ms fallback timer. Verified with cargo check + 422 passing tests.

✅ Implement adaptive window anchor for taskbar position 05:43:36.127 | claude_code User reported window visual flashing when taskbar not at bottom or window gets repositioned. Built complete anchor detection system: AnchorCorner enum (TopLeft/TopRight/BottomLeft/BottomRight), detect_anchor_corner() comparing window/work area centers, AtomicU8 storage, updated aligned_window_origin and anchored_resize_origin to use detected anchor. Added 5 anchor detection tests. Fixed clippy warning (.map_or → .is_some_and). All 422 tests passed.

✅ Fix false ‘usage warning’ when rate limits work 18:23:28.135 | claude_code User noticed ‘Usage warning’ appears despite Cursor rate limits displaying correctly. Analyzed dual Cursor pipeline: rate limits API (working) vs usage events API (returning empty array). User pointed out that working rate limits means warning is wrong. Modified parser.rs to downgrade remote usage events failure from set_cursor_warning to logging. Now only warns when auth genuinely unavailable (both pipelines fail).

✅ Fix PowerShell window popups from sqlite3 calls 04:56:21.981 | claude_code User reported multiple PowerShell windows popping up when running TokenMonitor on Windows. Explored all process spawns in Rust backend, found sqlite3 command in cursor_parser.rs:490 missing CREATE_NO_WINDOW flag (all other spawns had it). Added const CREATE_NO_WINDOW with platform guard and creation_flags call. Verified with 410 passing tests.

✅ Add ‘x of y enabled’ format to Model Visibility 05:36:52.157 | claude_code User requested consistency between Provider and Model visibility sections in Settings. Modified HiddenModelsSettings.svelte to show ‘x of y enabled’ instead of ‘x hidden’, changing derived calculation from hiddenCount to visibleCount and updating template text.

Token Usage

AI Usage · 2026-04-27 Claude Code + Codex
Total cost
$270.80
Total tokens
312M
Output tokens
2M
Cache read
92.9%
Cost split Claude Code $231 · Codex $40
Token character Cache reads 92.9% · Active 7.1%

Most token volume came from cache reads; Claude Code drove nearly all cost.