Skip to content

fix: restore WakaTime settings UI in Encore tab#697

Merged
pedramamini merged 2 commits intoRunMaestro:rcfrom
kianhub:restore-wakatime-settings-ui
Mar 31, 2026
Merged

fix: restore WakaTime settings UI in Encore tab#697
pedramamini merged 2 commits intoRunMaestro:rcfrom
kianhub:restore-wakatime-settings-ui

Conversation

@kianhub
Copy link
Copy Markdown
Contributor

@kianhub kianhub commented Mar 31, 2026

Summary

  • Restores the WakaTime integration controls that were dropped from the Encore tab's Usage & Stats section during a prior refactor
  • Adds back: enable toggle, API key input with validation, detailed file tracking toggle, and CLI availability check
  • All backend plumbing (IPC handlers, preload bridge, WakaTime manager, process listener, settings store) was already intact — only the UI was missing

Test plan

  • Open Settings > Encore Features > toggle Usage & Stats on
  • Verify WakaTime toggle, API key input, and detailed tracking toggle appear below the lookback window dropdown
  • Toggle WakaTime on and confirm CLI status check runs (shows "installing" message if CLI not found)
  • Enter a WakaTime API key and blur the input — verify validation indicator appears
  • Toggle detailed file tracking on/off
  • Confirm settings persist across settings modal close/reopen

Summary by CodeRabbit

  • New Features
    • Added WakaTime integration settings in Usage & Stats.
    • Enable/disable tracking with CLI availability monitoring and a conditional warning if the CLI is unavailable; automatic retry checks.
    • Optional detailed file tracking toggle.
    • API key input with on-blur validation, clear-key control, and protected validation feedback to avoid showing outdated results.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

WakaTime 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

Cohort / File(s) Summary
WakaTime Integration
src/renderer/components/Settings/tabs/EncoreTab.tsx
Added React hooks and refs for WakaTime state and validation (wakatimeCliStatus, wakatimeKeyValid, wakatimeKeyValidating, wakatimeApiKeyRef). Implemented CLI check effect with ~3s retry and cleanup. Added UI subsection: enable toggle, CLI-unavailable warning, "Detailed file tracking" toggle, API key input with on-blur validation, clear-key action, and Sentry captureException reporting.

Sequence Diagram

sequenceDiagram
    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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hopped into Settings, bright and quick,
I checked the CLI and gave it a kick,
Keys validated with a gentle thump,
Toggles flick, timers jump—hip-pip-hurp! ✨🕒

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: restore WakaTime settings UI in Encore tab' accurately summarizes the main change: restoring WakaTime integration controls to the Encore tab that were previously missing, which aligns with the PR objectives and the substantial UI additions detailed in the changeset.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR restores the WakaTime integration UI that was dropped from the Encore tab's Usage & Stats section during an earlier refactor. The backend plumbing (window.maestro.wakatime.checkCli / validateApiKey IPC handlers, preload bridge, settings store fields) was already fully intact; only the renderer-side form controls were missing.

The restored UI is well-structured:

  • useEffect for the CLI check correctly uses a cancelled flag and cleans up the retry setTimeout, guarding against stale state after unmount or toggle-off.
  • The API key onBlur validation delegates to the IPC handler and reflects result with check/X icons.
  • Settings fields (wakatimeEnabled, wakatimeApiKey, wakatimeDetailedTracking) are wired through the existing useSettings hook without touching the store or backend.

Three minor UX issues were found (all P2):

  • wakatimeKeyValidating is not cleared when the key is wiped via the clear button, leaving a stale spinner on an empty field.
  • wakatimeCliStatus is not reset to null during effect cleanup, causing a brief false "installing…" flash on re-enable.
  • An invalid key renders two X icons simultaneously (one for the error indicator, one for the clear button).

Confidence Score: 5/5

Safe 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

Filename Overview
src/renderer/components/Settings/tabs/EncoreTab.tsx Restores WakaTime UI controls (enable toggle, API key input with validation, detailed tracking toggle, CLI status check) inside the Usage & Stats section; all backend wiring was already present. Three minor P2 UX issues: validating spinner not cleared when key is manually wiped, stale CLI status on re-enable, and dual-X icon when key is invalid.

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (1): Last reviewed commit: "fix: restore WakaTime settings UI in Enc..." | Re-trigger Greptile

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 88b7e1b and 3383ab9.

📒 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
@pedramamini pedramamini merged commit 68337ad into RunMaestro:rc Mar 31, 2026
3 checks passed
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.

2 participants