fix: restore WakaTime settings UI in Encore tab#697
fix: restore WakaTime settings UI in Encore tab#697pedramamini merged 2 commits intoRunMaestro:rcfrom
Conversation
The WakaTime integration controls (enable toggle, API key input, detailed file tracking toggle, CLI status check) were dropped from the EncoreTab during a prior refactor. Re-adds them inside the Usage & Stats expanded section where they previously lived.
📝 WalkthroughWalkthroughWakaTime integration added to the Settings UI: CLI availability detection with retry logic, API key input and on-blur validation, toggles for enabling tracking and detailed file tracking, Sentry error capture, and state to manage validation/CLI status. Changes
Sequence DiagramsequenceDiagram
actor User
participant EncoreTab
participant WakaTimeAPI as window.maestro.wakatime
participant Sentry
User->>EncoreTab: Open Settings tab (isOpen=true)
EncoreTab->>WakaTimeAPI: checkCli()
alt CLI available
WakaTimeAPI-->>EncoreTab: success
EncoreTab->>EncoreTab: set wakatimeCliStatus = available
else CLI unavailable or error
WakaTimeAPI-->>EncoreTab: failure/error
EncoreTab->>Sentry: captureException(error)
EncoreTab->>EncoreTab: set wakatimeCliStatus = unavailable
EncoreTab->>EncoreTab: schedule retry (~3s)
end
User->>EncoreTab: Toggle WakaTime on
EncoreTab->>EncoreTab: show API key input
User->>EncoreTab: Enter API key and blur
EncoreTab->>WakaTimeAPI: validateApiKey(keyAtBlur)
WakaTimeAPI-->>EncoreTab: validationResult
EncoreTab->>EncoreTab: if key matches wakatimeApiKeyRef -> update wakatimeKeyValid / wakatimeKeyValidating
EncoreTab->>Sentry: captureException(if validation call throws)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR restores the WakaTime integration UI that was dropped from the Encore tab's Usage & Stats section during an earlier refactor. The backend plumbing ( The restored UI is well-structured:
Three minor UX issues were found (all P2):
Confidence Score: 5/5Safe to merge; all backend wiring is intact and the restored UI correctly integrates with existing hooks and IPC. No P0 or P1 issues found. The three remaining findings are P2 UX polish items (transient spinner, brief status flicker, dual icons) that do not affect correctness, data integrity, or the primary user path. No files require special attention beyond the three P2 polish items in EncoreTab.tsx. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant ET as EncoreTab (Renderer)
participant IPC as window.maestro.wakatime
participant Main as Main Process (WakaTimeManager)
U->>ET: Toggle WakaTime on
ET->>IPC: checkCli()
IPC->>Main: ipcMain "wakatime:checkCli"
Main-->>IPC: { available, version? }
IPC-->>ET: status
alt CLI not available
ET->>ET: show "installing…" warning
ET->>ET: schedule 3 s retry
ET->>IPC: checkCli() (retry)
IPC->>Main: ipcMain "wakatime:checkCli"
Main-->>ET: updated status
end
U->>ET: Enter API key, blur input
ET->>IPC: validateApiKey(key)
IPC->>Main: ipcMain "wakatime:validateApiKey"
Main-->>IPC: { valid }
IPC-->>ET: result
alt valid
ET->>ET: show check icon
else invalid
ET->>ET: show X icon
end
U->>ET: Clear API key (X button)
ET->>ET: setWakatimeApiKey(""), setWakatimeKeyValid(null)
Note over ET: wakatimeKeyValidating NOT cleared — spinner lingers until in-flight IPC settles
Reviews (1): Last reviewed commit: "fix: restore WakaTime settings UI in Enc..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/renderer/components/Settings/tabs/EncoreTab.tsx`:
- Around line 399-441: The WakaTime API key input lacks a programmatic label and
the clear button is icon-only with only a title; update the markup so the input
rendered in the EncoreTab (the element bound to wakatimeApiKey and
handleWakatimeApiKeyChange) has an accessible label (either convert the "API
Key" div to a <label> with htmlFor matching a unique id on the input, or add
aria-label/aria-labelledby to the input) and give the clear button an explicit
accessible name (e.g., aria-label="Clear WakaTime API key") so screen readers
can identify both the field and the clear action; ensure any id used is unique
within the component.
- Around line 78-113: The current catch blocks on
window.maestro.wakatime.checkCli() are converting all rejections into
setWakatimeCliStatus({ available: false }), hiding real IPC/preload failures;
change these catches to distinguish expected "not installed" errors (handle by
setting available: false) from unexpected exceptions by reporting them to Sentry
(use your project's Sentry utility/capture function) and then rethrowing or
returning so they are not swallowed; update the retry catch branches the same
way and apply the same pattern to validateApiKey() handlers so only known
negative results update setWakatimeCliStatus / setWakatimeApiStatus while
unexpected errors are reported via Sentry and propagated.
- Around line 412-441: The validation result must be applied only if it matches
the key that was present when validation started and the CLI is still available;
to fix, capture the current wakatimeApiKey in a local const (e.g. const
keyToValidate = wakatimeApiKey) inside the onBlur handler before calling
window.maestro.wakatime.validateApiKey, then in the then/catch/finally handlers
only call setWakatimeKeyValid/setWakatimeKeyValidating if keyToValidate ===
wakatimeApiKey and window.maestro.wakatime is still reachable (or the CLI-ready
flag you have), and ensure handleWakatimeApiKeyChange('') can clear the input
without stale promises overwriting state. This keeps validateApiKey
(window.maestro.wakatime.validateApiKey), setWakatimeKeyValidating and
setWakatimeKeyValid updates scoped to the original key.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 55be36d3-afae-4b6c-8137-69fe2d35ac7a
📒 Files selected for processing (1)
src/renderer/components/Settings/tabs/EncoreTab.tsx
…tings - Reset wakatimeKeyValidating on key change/clear to stop stale spinner - Clear wakatimeCliStatus in effect cleanup to prevent stale "installing…" flash on disable/re-enable cycles - Replace dual X icons (error + clear) with single clear button that turns red when key is invalid - Report IPC errors from checkCli/validateApiKey to Sentry instead of silently swallowing them - Add proper <label> with htmlFor for API key input, aria-label on clear button for screen reader accessibility - Scope validation result to the key that was blurred using a ref, so stale promises from a cleared/changed input don't paint wrong state
Summary
Test plan
Summary by CodeRabbit