Skip to content

Comments

feat: add per-file WakaTime heartbeats for write operations#449

Open
kianhub wants to merge 9 commits intoRunMaestro:mainfrom
kianhub:feat/wakatime-file-heartbeats
Open

feat: add per-file WakaTime heartbeats for write operations#449
kianhub wants to merge 9 commits intoRunMaestro:mainfrom
kianhub:feat/wakatime-file-heartbeats

Conversation

@kianhub
Copy link
Contributor

@kianhub kianhub commented Feb 24, 2026

Summary

Adds detailed file tracking to the WakaTime integration. When enabled, Maestro sends per-file heartbeats for every write operation across all supported agents — so your WakaTime dashboard shows exactly which files were modified, not just "time spent in Maestro."

When heartbeats are sent

High-level behavior

Maestro sends two kinds of WakaTime heartbeats:

  1. App-level heartbeats — "the user is active in Maestro." These fire continuously while an agent is working (streaming output, thinking, completing a query). WakaTime sees this as time spent in the Maestro project. This has been shipping since the initial WakaTime integration.

  2. File-level heartbeats (new, opt-in) — "the agent just wrote to src/index.ts." These fire when an agent finishes a turn that included write operations. Your WakaTime dashboard breaks down time by individual file and language, just like it does for VS Code or JetBrains.

File heartbeats require two explicit opt-ins: WakaTime enabled + "Detailed file tracking" toggled on. Only file paths are sent to WakaTime, never file content.

When exactly each heartbeat fires

Signal What fires When it happens
Agent streams output (data event) App heartbeat Every stdout chunk from the agent. WakaTimeManager debounces to 1 per 2 minutes per session.
Agent is thinking (thinking-chunk event) App heartbeat During extended thinking / reasoning. Same 2-min debounce.
Batch query finishes (query-complete event) App heartbeat + file flush When an auto-run/batch process completes. File heartbeats are flushed immediately.
Agent turn ends (usage event) File flush (debounced 500ms) When the agent reports token usage at end-of-turn. Covers interactive chat sessions. A short debounce batches rapid multi-usage turns into a single flush.
Agent exits (exit event) Cleanup Pending file data and timers are discarded. No heartbeat sent.

How file paths are collected

During an agent turn, every tool-execution event is checked:

  • If the tool is a write operation (Write, Edit, NotebookEdit, write_to_file, etc.), the file path is extracted and accumulated in a per-session map
  • Duplicate paths are deduplicated, keeping the latest timestamp
  • Read operations and shell commands are ignored

When the turn ends (via query-complete for batch, or debounced usage for interactive), the accumulated files are flushed as a single batched WakaTime CLI call. The first file goes as the primary --entity; additional files go via --extra-heartbeats on stdin.

Double-flush prevention

For batch sessions, both query-complete and usage can fire. query-complete flushes first and cancels any pending usage debounce timer, so files are never sent twice.

Changes

Core logic:

  • wakatime-manager.tssendFileHeartbeats(), WRITE_TOOL_NAMES, extractFilePathFromToolExecution(), detectLanguageFromPath() with 50+ extension→language map
  • wakatime-listener.tstool-execution collection, usage-based debounced flush for interactive sessions, query-complete flush for batch, shared flushPendingFiles() helper, timer cleanup on exit

Settings:

  • New wakatimeDetailedTracking field in store types, defaults, settings store, and useSettings hook
  • Toggle UI in SettingsModal.tsx (shown only when WakaTime is enabled)

Docs:

  • configuration.md — WakaTime section with setup instructions and tracked tools table
  • features.md — feature bullet
  • CLAUDE-IPC.md — integrations section

Tests:

  • ~1,100 lines of new test coverage across wakatime-manager.test.ts and wakatime-listener.test.ts

Supported write tools by agent

Agent Tracked Tools
Claude Code Write, Edit, NotebookEdit
Codex write_to_file, str_replace_based_edit_tool, create_file
OpenCode write, patch

Test plan

  • npm run test — all WakaTime tests pass (72 manager + 44 listener)
  • npm run lint — no type errors
  • Enable WakaTime + Detailed file tracking, run an interactive chat that writes files, verify per-file entries on wakatime.com
  • Run an auto-run document that writes files, verify per-file entries appear
  • Disable detailed tracking, verify only app-level heartbeats are sent
  • Verify toggle is hidden when WakaTime itself is disabled

Summary by CodeRabbit

  • New Features

    • Detailed WakaTime integration with optional per-file write activity tracking across agents.
    • New "Detailed file tracking" toggle in settings to enable per-file heartbeats.
  • Documentation

    • Added WakaTime integration docs and updated configuration and features pages.
  • Tests

    • Expanded test coverage for WakaTime behavior, file detection, and heartbeat flushing.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

Adds optional per-file WakaTime tracking: collects file paths from tool-execution events, detects language and branch (with TTL cache), batches per-file heartbeats via the WakaTime CLI, debounces flushes on usage, and exposes a UI setting to enable detailed tracking.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE-IPC.md, docs/configuration.md, docs/features.md
Added WakaTime integration docs, configuration entries (toggle, API key, detailed tracking docs), and feature listing; duplicate block present in configuration.md.
WakaTime Manager Core Logic
src/main/wakatime-manager.ts
Added extension->language map, detectLanguageFromPath(), WRITE_TOOL_NAMES, extractFilePathFromToolExecution(), branch TTL cache, and sendFileHeartbeats() to batch per-file heartbeats with language/branch metadata and CLI invocation.
Process Listener Integration
src/main/process-listeners/wakatime-listener.ts
Collects per-session file paths from tool-execution events, deduplicates by latest timestamp, debounced flush on usage, flush on query-complete, cleanup on exit, and integrates extractFilePathFromToolExecution.
Settings Backend Defaults & Types
src/main/stores/defaults.ts, src/main/stores/types.ts
Added wakatimeDetailedTracking: boolean to MaestroSettings and defaulted it to false.
Renderer Settings Layer
src/renderer/stores/settingsStore.ts, src/renderer/hooks/settings/useSettings.ts, src/renderer/components/SettingsModal.tsx
Exposed wakatimeDetailedTracking state and setWakatimeDetailedTracking setter, persisted/loaded via settings store, and added UI toggle in SettingsModal shown when WakaTime is enabled.
Tests
src/__tests__/main/wakatime-manager.test.ts, src/main/process-listeners/__tests__/wakatime-listener.test.ts
Added extensive tests for new exports (detectLanguageFromPath, extractFilePathFromToolExecution, WRITE_TOOL_NAMES, sendFileHeartbeats) and for listener behaviors: accumulation, deduplication, debounce flush, query-complete flush, exit cleanup, and settings gating.

Sequence Diagram

sequenceDiagram
    participant Process as Process Listener
    participant Manager as WakaTime Manager
    participant CLI as WakaTime CLI
    participant Cache as Branch Cache

    rect rgba(100, 150, 200, 0.5)
    Note over Process,Cache: File path collection & debounce
    Process->>Process: Receive tool-execution
    Process->>Manager: extractFilePathFromToolExecution(...)
    Process->>Process: Accumulate per-session (dedupe by path/timestamp)
    Process->>Process: On usage -> schedule debounced flush
    end

    rect rgba(150, 100, 200, 0.5)
    Note over Manager,CLI: Batch heartbeat send
    Process->>Manager: sendFileHeartbeats(files[], projectPath, projectCwd)
    Manager->>Manager: validate enabled / API key / CLI present
    Manager->>Manager: detectLanguageFromPath(file)
    Manager->>Cache: get/refresh branch (with TTL)
    Manager->>CLI: execute wakatime-cli --extra-heartbeats ...
    CLI-->>Manager: success / failure
    Manager-->>Process: resolve
    end

    rect rgba(200, 100, 150, 0.5)
    Note over Process: Cleanup
    Process->>Process: On exit -> clear pending files & timers
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective: adding per-file WakaTime heartbeats for write operations. It is specific, concise, and directly reflects the primary change across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

…e map

Add new `wakatimeDetailedTracking` boolean setting (default false) to
types, defaults, settingsStore, and useSettings hook. This setting will
gate file-level heartbeat collection in a future phase.

Add EXTENSION_LANGUAGE_MAP (50+ extensions) and exported
detectLanguageFromPath() helper to wakatime-manager.ts for resolving
file paths to WakaTime language names.

Includes 22 new tests for detectLanguageFromPath covering common
extensions, case insensitivity, multi-dot paths, and unknown extensions.
…file heartbeats

Add WRITE_TOOL_NAMES set (Write, Edit, write_to_file, str_replace_based_edit_tool,
create_file, write, patch, NotebookEdit) and extractFilePathFromToolExecution()
function that inspects tool-execution events and extracts file paths from
input.file_path or input.path fields. Supports Claude Code, Codex, and OpenCode
agent tool naming conventions.
…rtbeats

Add public async method to WakaTimeManager that sends file-level heartbeats
collected from tool executions. The first file is sent as the primary
heartbeat via CLI args; remaining files are batched via --extra-heartbeats
on stdin as a JSON array. Includes language detection per file, branch
detection, and gating on both wakatimeEnabled and wakatimeDetailedTracking
settings. 12 new tests cover all code paths.
…Time listener

Add per-session file path accumulation from tool-execution events and
flush as file-level heartbeats on query-complete. Controlled by the
wakatimeDetailedTracking setting. Pending files are cleaned up on exit
to prevent memory leaks.
Add WakaTime section to configuration.md covering setup, detailed file
tracking, and per-agent supported tools. Add wakatime namespace to
CLAUDE-IPC.md and feature bullet to features.md. Fix detailed file
tracking toggle padding and shorten description to one line.
File heartbeats were only flushed on query-complete (batch/auto-run).
Interactive chat sessions accumulated file paths but never sent them.

Add a usage event handler with 500ms per-session debounce that flushes
accumulated file heartbeats at end-of-turn for all session types.
Extract shared flushPendingFiles() helper. query-complete cancels any
pending usage timer to prevent double-flush.
@kianhub kianhub force-pushed the feat/wakatime-file-heartbeats branch from 08e8da6 to 5b10a1c Compare February 24, 2026 17:55
@kianhub
Copy link
Contributor Author

kianhub commented Feb 24, 2026

Branch detection fix (detectBranch in wakatime-manager.ts)

  • Failed git lookups are no longer cached. Previously an empty string was stored permanently, meaning a single transient git rev-parse failure (lock contention, timing during startup) would suppress the branch field for the entire session lifetime. Now failures are evicted from the cache so the next heartbeat retries.
  • Successful branch results now expire after 5 minutes, so mid-session branch switches are picked up instead of reporting the stale initial branch forever.
  • File-level heartbeats now cache branch per project directory (file:<cwd>) instead of a single shared 'file-heartbeat' key, preventing concurrent sessions in different repos from cross-contaminating each other's branch value.

…artbeats

Failed git lookups are no longer cached, so transient failures retry on
the next heartbeat instead of suppressing the branch field for the entire
session. Successful results expire after 5 minutes to pick up branch
switches. File-level heartbeats now cache per project directory instead
of sharing a single key across all sessions.
@kianhub kianhub marked this pull request as ready for review February 24, 2026 22:11
Copy link

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/stores/settingsStore.ts (1)

1807-1811: ⚠️ Potential issue | 🟠 Major

setWakatimeDetailedTracking is missing from getSettingsActions().

setWakatimeEnabled and setWakatimeApiKey are both present in the returned map, but setWakatimeDetailedTracking is not. Any non-React code (main-process utilities, services) that calls getSettingsActions() will find the action undefined and silently fail to persist the toggle.

🐛 Proposed fix
 		setWakatimeApiKey: state.setWakatimeApiKey,
 		setWakatimeEnabled: state.setWakatimeEnabled,
+		setWakatimeDetailedTracking: state.setWakatimeDetailedTracking,
 		setUseNativeTitleBar: state.setUseNativeTitleBar,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/renderer/stores/settingsStore.ts` around lines 1807 - 1811,
getSettingsActions() is returning a map of action setters but omits
setWakatimeDetailedTracking, causing callers to receive undefined; update the
returned object in settingsStore (the getSettingsActions() implementation) to
include setWakatimeDetailedTracking: state.setWakatimeDetailedTracking alongside
setWakatimeApiKey and setWakatimeEnabled so external code can persist the
detailed-tracking toggle.
🧹 Nitpick comments (1)
src/main/process-listeners/wakatime-listener.ts (1)

59-61: Prefer explicit boolean coercion in onDidChange callback.

The enabled watcher on line 54 already uses !!v, but the detailedEnabled watcher assigns val as boolean directly. If the store ever emits null or undefined, the cast silently produces a falsy non-boolean. Using !!val is consistent with the adjacent pattern.

♻️ Proposed fix
-	settingsStore.onDidChange('wakatimeDetailedTracking', (val: unknown) => {
-		detailedEnabled = val as boolean;
-	});
+	settingsStore.onDidChange('wakatimeDetailedTracking', (val: unknown) => {
+		detailedEnabled = !!val;
+	});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/process-listeners/wakatime-listener.ts` around lines 59 - 61, The
watcher for 'wakatimeDetailedTracking' currently assigns detailedEnabled = val
as boolean which can silently accept null/undefined; change the callback in
settingsStore.onDidChange('wakatimeDetailedTracking', ...) to coerce to a true
boolean (e.g. detailedEnabled = !!val) to match the pattern used by the
'enabled' watcher and ensure consistent, explicit boolean values.
🤖 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/main/wakatime-manager.ts`:
- Around line 682-689: The call to execFileNoThrow in the file-heartbeat send
path ignores its result so failures still produce the "Sent file heartbeats"
log; update the heartbeat-sending code that calls execFileNoThrow (using
this.cliPath and args) to inspect the returned result (exitCode and stderr), and
only log logger.info('Sent file heartbeats', LOG_CONTEXT, { count: files.length
}) when exitCode === 0; otherwise emit logger.warn (include exitCode and stderr)
and avoid the success message so failures aren't reported as successful. Ensure
you reference execFileNoThrow's result variable and use LOG_CONTEXT and
files.length in the logs for consistent context.

In `@src/renderer/components/SettingsModal.tsx`:
- Around line 2205-2235: The new detailed file tracking toggle button
(controlled by wakatimeDetailedTracking and toggled via
setWakatimeDetailedTracking) is missing focus accessibility props; update that
button element to include tabIndex={0} (or tabIndex={-1} if you intend to skip
it), add the "outline-none" class to its className, and if it should auto-focus
on mount add a ref={(el) => el?.focus()} (or a useRef/useEffect pattern) so
keyboard users can reach and see focus; keep the existing role="switch" and
aria-checked as-is.

---

Outside diff comments:
In `@src/renderer/stores/settingsStore.ts`:
- Around line 1807-1811: getSettingsActions() is returning a map of action
setters but omits setWakatimeDetailedTracking, causing callers to receive
undefined; update the returned object in settingsStore (the getSettingsActions()
implementation) to include setWakatimeDetailedTracking:
state.setWakatimeDetailedTracking alongside setWakatimeApiKey and
setWakatimeEnabled so external code can persist the detailed-tracking toggle.

---

Nitpick comments:
In `@src/main/process-listeners/wakatime-listener.ts`:
- Around line 59-61: The watcher for 'wakatimeDetailedTracking' currently
assigns detailedEnabled = val as boolean which can silently accept
null/undefined; change the callback in
settingsStore.onDidChange('wakatimeDetailedTracking', ...) to coerce to a true
boolean (e.g. detailedEnabled = !!val) to match the pattern used by the
'enabled' watcher and ensure consistent, explicit boolean values.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 183a792 and d58ba72.

📒 Files selected for processing (12)
  • CLAUDE-IPC.md
  • docs/configuration.md
  • docs/features.md
  • src/__tests__/main/wakatime-manager.test.ts
  • src/main/process-listeners/__tests__/wakatime-listener.test.ts
  • src/main/process-listeners/wakatime-listener.ts
  • src/main/stores/defaults.ts
  • src/main/stores/types.ts
  • src/main/wakatime-manager.ts
  • src/renderer/components/SettingsModal.tsx
  • src/renderer/hooks/settings/useSettings.ts
  • src/renderer/stores/settingsStore.ts

@greptile-apps
Copy link

greptile-apps bot commented Feb 24, 2026

Greptile Summary

Added detailed file tracking to WakaTime integration. When enabled via two explicit opt-ins (WakaTime + detailed tracking toggle), Maestro sends per-file heartbeats for write operations across all supported agents (Claude Code, Codex, OpenCode). File paths are accumulated during agent turns and flushed as batched heartbeats either immediately on query-complete (batch sessions) or after a 500ms debounced usage event (interactive sessions). Double-flush prevention ensures files aren't sent twice when both events fire.

Key changes:

  • wakatime-manager.ts — Added sendFileHeartbeats() with 50+ language mappings, extractFilePathFromToolExecution() for 8 write tool types, detectLanguageFromPath(), and improved branch caching with 5-minute TTL that doesn't cache failures
  • wakatime-listener.ts — Tool-execution event collection, per-session file accumulators, debounced flush on usage, immediate flush on query-complete with timer cancellation
  • Settings layer — New wakatimeDetailedTracking field with defaults, UI toggle (shown only when WakaTime enabled), store integration
  • Tests — ~1,100 lines of new coverage across manager (500 lines) and listener (570 lines) test files
  • Docs — Comprehensive setup instructions, privacy clarifications, supported tools table

Implementation quality:

  • Proper separation of concerns between collection (listener) and transmission (manager)
  • Efficient batching using WakaTime's --extra-heartbeats stdin API
  • Race condition handling for batch vs interactive flush
  • Memory-safe cleanup of timers and pending data on exit
  • Follows existing codebase patterns (tabs for indentation, settings flow, testing standards)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-architected feature with comprehensive test coverage (~1,100 new test lines), proper privacy controls (double opt-in, paths-only transmission), efficient batching, race condition handling, and clean integration with existing patterns. No logic errors, security issues, or architectural concerns found.
  • No files require special attention

Important Files Changed

Filename Overview
src/main/wakatime-manager.ts Added sendFileHeartbeats method, file extension language mapping, write tool detection, and improved branch cache with TTL. Well-structured with comprehensive test coverage.
src/main/process-listeners/wakatime-listener.ts Added file path accumulation on tool-execution events, flush logic for batch (query-complete) and interactive (debounced usage) sessions, proper cleanup of timers and pending data.
src/renderer/components/SettingsModal.tsx Added detailed tracking toggle UI (conditionally shown when WakaTime enabled), consistent with existing settings patterns.
src/tests/main/wakatime-manager.test.ts Added ~500 lines of tests covering WRITE_TOOL_NAMES, extractFilePathFromToolExecution, detectLanguageFromPath, and sendFileHeartbeats with extensive edge case coverage.
src/main/process-listeners/tests/wakatime-listener.test.ts Added ~570 lines of tests covering tool-execution collection, usage-based debounced flush, query-complete flush, double-flush prevention, and cleanup logic.
docs/configuration.md Added comprehensive WakaTime integration section documenting setup, what gets tracked, detailed file tracking, and supported tools per agent.

Sequence Diagram

sequenceDiagram
    participant Agent as AI Agent
    participant PM as ProcessManager
    participant WL as WakaTimeListener
    participant WM as WakaTimeManager
    participant CLI as WakaTime CLI

    Note over Agent,CLI: Interactive Session (Usage Event)
    Agent->>PM: tool-execution (Write/Edit)
    PM->>WL: emit('tool-execution', toolExecution)
    WL->>WL: extractFilePathFromToolExecution()
    WL->>WL: accumulate in pendingFiles Map
    
    Agent->>PM: usage (end of turn)
    PM->>WL: emit('usage', usageStats)
    WL->>WL: reset 500ms debounce timer
    
    Note over WL: After 500ms debounce
    WL->>WL: flushPendingFiles()
    WL->>WM: sendFileHeartbeats(filesArray)
    WM->>WM: detectLanguageFromPath() for each file
    WM->>WM: detectBranch() with TTL cache
    WM->>CLI: wakatime-cli --entity file1 --extra-heartbeats
    WM->>CLI: stdin: JSON array of extra files
    
    Note over Agent,CLI: Batch/Auto-Run Session (Query Complete)
    Agent->>PM: tool-execution (Write/Edit)
    PM->>WL: emit('tool-execution', toolExecution)
    WL->>WL: accumulate in pendingFiles Map
    
    Agent->>PM: query-complete
    PM->>WL: emit('query-complete', queryData)
    WL->>WL: flushPendingFiles() immediately
    WL->>WL: cancel any pending usage timer
    WL->>WM: sendFileHeartbeats(filesArray)
    WM->>CLI: wakatime-cli with batched heartbeats
    
    Note over Agent,CLI: Session Exit
    Agent->>PM: exit
    PM->>WL: emit('exit', sessionId)
    WL->>WL: clear timers and pendingFiles
    WL->>WM: removeSession(sessionId)
Loading

Last reviewed commit: d58ba72

- Check execFileNoThrow exit code and log warn on failure
- Add tabIndex and outline-none to detailed tracking toggle
- Export setWakatimeDetailedTracking from getSettingsActions()
- Use !!val for consistent boolean coercion in listener
Copy link

@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.

🧹 Nitpick comments (1)
src/main/process-listeners/wakatime-listener.ts (1)

57-84: Clear queued file heartbeats when detailed tracking is disabled.

Line 57-61 flips the flag but leaves pendingFiles / usageFlushTimers intact; if detailed tracking is disabled for a while, stale entries can linger and later flush when re-enabled. Consider clearing queues/timers on disable to keep the buffer accurate.

♻️ Suggested cleanup on disable
 settingsStore.onDidChange('wakatimeDetailedTracking', (val: unknown) => {
 	detailedEnabled = !!val;
+	if (!detailedEnabled) {
+		clearFileTracking();
+	}
 });
 
 // Per-session accumulator for file paths from tool-execution events.
 // Outer key: sessionId, inner key: filePath (deduplicates, keeping latest timestamp).
 const pendingFiles = new Map<string, Map<string, { filePath: string; timestamp: number }>>();
 
 // Per-session debounce timers for usage-based file flush.
 const usageFlushTimers = new Map<string, ReturnType<typeof setTimeout>>();
+
+function clearFileTracking(): void {
+	pendingFiles.clear();
+	for (const timer of usageFlushTimers.values()) {
+		clearTimeout(timer);
+	}
+	usageFlushTimers.clear();
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/process-listeners/wakatime-listener.ts` around lines 57 - 84, When
the wakatimeDetailedTracking flag is toggled off the handler that updates
detailedEnabled (the settingsStore.onDidChange callback) must also clear
per-session state to avoid stale flushes: on receiving a falsy val, iterate and
clear pendingFiles (Map pendingFiles) and cancel/clear all timers in
usageFlushTimers (Map usageFlushTimers) and then delete their entries; ensure
you don't call flushPendingFiles when disabling (only cancel), and keep existing
behavior when enabling. Update the settingsStore.onDidChange callback to perform
these cleanup steps atomically so stale entries won't later be flushed by
flushPendingFiles or leftover timers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/process-listeners/wakatime-listener.ts`:
- Around line 57-84: When the wakatimeDetailedTracking flag is toggled off the
handler that updates detailedEnabled (the settingsStore.onDidChange callback)
must also clear per-session state to avoid stale flushes: on receiving a falsy
val, iterate and clear pendingFiles (Map pendingFiles) and cancel/clear all
timers in usageFlushTimers (Map usageFlushTimers) and then delete their entries;
ensure you don't call flushPendingFiles when disabling (only cancel), and keep
existing behavior when enabling. Update the settingsStore.onDidChange callback
to perform these cleanup steps atomically so stale entries won't later be
flushed by flushPendingFiles or leftover timers.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d58ba72 and b13191a.

📒 Files selected for processing (4)
  • src/main/process-listeners/wakatime-listener.ts
  • src/main/wakatime-manager.ts
  • src/renderer/components/SettingsModal.tsx
  • src/renderer/stores/settingsStore.ts

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