Skip to content

fix: update after sync - #131

Merged
Friedrich482 merged 5 commits into
mainfrom
features
Apr 25, 2026
Merged

fix: update after sync#131
Friedrich482 merged 5 commits into
mainfrom
features

Conversation

@Friedrich482

@Friedrich482 Friedrich482 commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Commits

  • fix: update after sync

    • fixed the weird issue of the local data not being properly updated after a sync with the server, that could cause stale data locally, by handling the two cases (file frozen or not)
    • fixed some comments issues in types-schemas, update-files-data-frozen-states and update-files-data-elapsed-time
    • used the logError utility function instead of a raw console.error in the server-dashboard-prod and serve-dashboard-dev functions
    • in the get-global-state-data function, we now schema.safeParse to validate the data instead of schema.parse and handle it directly to avoid using a try/catch block
  • fix: data payload

    • only kept the necessary properties in the todayFilesData object sent to the api in the periodicSyncData function
  • chore: variable naming

    • renamed the timeSpentPerProject to timeSpentPerProjectToday for clarity in the periodicSyncData function
  • chore: extension version

    • bumped the extension version to v0.0.63

Summary by CodeRabbit

  • Chores

    • Version updated to 0.0.63
  • Bug Fixes

    • Improved handling of elapsed time calculation for frozen files during sync operations
    • Enhanced error reporting consistency across dashboard services
  • Documentation

    • Updated type documentation for clarity

- fixed the weird issue of the local data not being properly updated after a sync with the server, that could cause stale data locally, by handling the two cases (file frozen or not)
- fixed some comments issues in `types-schemas`, `update-files-data-frozen-states` and `update-files-data-elapsed-time`
- used the `logError` utility function instead of a raw console.error in the `server-dashboard-prod` and `serve-dashboard-dev` functions
- in the `get-global-state-data` function, we now schema.safeParse to validate the data instead of schema.parse and handle it directly to avoid using a try/catch block
- only kept the necessary properties in the `todayFilesData` object sent to the api in the `periodicSyncData` function
- renamed the `timeSpentPerProject` to `timeSpentPerProjectToday` for clarity in the `periodicSyncData` function
- bumped the extension version to `v0.0.63`
@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Friedrich482 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 32 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 32 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b38b61c-8fcd-4ca6-a07e-6f57a2446d8c

📥 Commits

Reviewing files that changed from the base of the PR and between 4b69c18 and f1c2691.

📒 Files selected for processing (2)
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts
  • apps/vscode-extension/src/utils/periodic-sync-data.ts
📝 Walkthrough

Walkthrough

Version bump to 0.0.63 accompanied by logging refactoring (replacing logDir with logInfo), consolidated error reporting to centralized logger, improved frozen file data handling during sync, and simplified time accounting computation in periodic sync operations.

Changes

Cohort / File(s) Summary
Version & Documentation
apps/vscode-extension/package.json, apps/vscode-extension/src/types-schemas.ts
Version incremented to 0.0.63; JSDoc descriptions updated for freezeStartTime and elapsedTime fields.
Logging & Error Handling
apps/vscode-extension/src/utils/commands/init-extension-commands.ts, apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts, apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts, apps/vscode-extension/src/utils/global-state/get-global-state-data.ts
Centralized logging: replaced logDir with logInfo for command output; replaced console.error with logError for WebSocket validation failures; switched from try/catch + parse to safeParse for global state validation.
File Data & Sync Logic
apps/vscode-extension/src/utils/files/update-files-data-after-sync.ts, apps/vscode-extension/src/utils/files/update-files-data-elapsed-time.ts, apps/vscode-extension/src/utils/files/update-files-data-frozen-states.ts, apps/vscode-extension/src/utils/periodic-sync-data.ts
Enhanced frozen file handling to preserve frozenTime and conditionally update startTime only for non-frozen entries; clarified elapsed time calculation logic; simplified time accounting to derive timeSpentPerProjectToday with explicit field destructuring.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Logs now flow through central streams,
Frozen files hold their gleaming dreams,
Version ticks to .63
Each sync now dances flawlessly!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: update after sync' is vague and doesn't clearly convey the main changes; it lacks specificity about what bug is being fixed or which components are affected. Consider a more specific title such as 'fix: preserve file data state after server sync' or 'fix: handle frozen files correctly during sync updates' to better communicate the primary intent.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch features

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (5)
apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts (2)

57-57: logError change LGTM; consider including validation issues.

Same suggestion as in serve-dashboard-dev.ts: attach validated.error.issues for better diagnosability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts`
at line 57, The logError call in serve-dashboard-prod.ts currently logs "Invalid
message shape" without details; update the error logging where logError("Invalid
message shape") is called (the message validation branch) to include the
validation failure details from validated.error.issues so callers can diagnose
issues—e.g., pass or append validated.error.issues to the processLogger/logError
invocation used in this file (same pattern as in serve-dashboard-dev.ts),
ensuring the log message includes both the descriptive string and the
validated.error.issues payload.

61-64: Inconsistency with serve-dashboard-dev.ts: log validated.data, not raw data.

The dev variant logs logDir(validated.data) (line 43), while this file still logs logDir(data) — the raw, unvalidated JSON. Since the rest of the handler uses validated.data (line 64), logging the same validated/transformed object keeps both paths consistent and matches what the code actually consumes.

♻️ Suggested change
         logInfo("Received from dashboard:");
-        logDir(data);
+        logDir(validated.data);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts`
around lines 61 - 64, The code logs the raw JSON variable data but then uses
validated.data downstream; update the logging to reflect the
validated/transformed object by replacing the call to logDir(data) with
logDir(validated.data) so logInfo/logDir show the same object your handler uses
(change the logDir invocation in serve-dashboard-prod.ts just before const {
type } = validated.data).
apps/vscode-extension/src/utils/files/update-files-data-after-sync.ts (1)

14-22: Minor: drop the redundant trailing return.

After the early-return at line 18, the only remaining path through the if (filesData[filePath]) block is the frozen branch which ends at line 21; the return on line 22 is unreachable as a control-flow exit (the forEach callback would return implicitly). Not a bug — just dead code now that the function shape changed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/vscode-extension/src/utils/files/update-files-data-after-sync.ts` around
lines 14 - 22, Remove the redundant trailing `return` at the end of the forEach
callback in update-files-data-after-sync: inside the block that updates
filesData[filePath].elapsedTime, keep the early return when
!filesData[filePath].isFrozen (which sets startTime) and then for the frozen
branch set filesData[filePath].frozenTime = file.timeSpent and let the function
exit implicitly; no change to variable names (filesData, filePath, isFrozen,
startTime, frozenTime, elapsedTime) — just delete the unreachable final
`return`.
apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts (1)

37-40: Consider including validation error details.

logError("Invalid message shape") discards the Zod issues which are the most actionable info for debugging malformed messages. Consider attaching validated.error.issues (or z.treeifyError(validated.error)) to the log for diagnosability.

♻️ Suggested change
-          logError("Invalid message shape");
+          logError(
+            `Invalid message shape: ${JSON.stringify(validated.error.issues)}`,
+          );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts`
around lines 37 - 40, The current early return discards Zod validation details;
update the failure branch where validated is checked (the validated variable and
logError call in serve-dashboard-dev.ts) to include the validation error
details—e.g., pass validated.error.issues or z.treeifyError(validated.error) (or
JSON.stringify thereof) into logError so the log contains actionable diagnostics
before returning; keep the existing message ("Invalid message shape") and append
or include the error payload for clarity.
apps/vscode-extension/src/utils/periodic-sync-data.ts (1)

46-57: Optional: collapse .map().reduce() into a single reduce.

The intermediate array allocation isn't needed — you can accumulate directly. Minor readability/perf nit.

♻️ Proposed simplification
-  const timeSpentPerProjectToday = Object.entries(filesDataToUpsert)
-    .map(([, fileData]) => ({
-      project: fileData.projectPath,
-      timeSpent: fileData.elapsedTime,
-    }))
-    .reduce(
-      (acc, curr) => {
-        acc[curr.project] = (acc[curr.project] || 0) + curr.timeSpent;
-        return acc;
-      },
-      {} as Record<string, number>,
-    );
+  const timeSpentPerProjectToday = Object.values(filesDataToUpsert).reduce(
+    (acc, { projectPath, elapsedTime }) => {
+      acc[projectPath] = (acc[projectPath] ?? 0) + elapsedTime;
+      return acc;
+    },
+    {} as Record<string, number>,
+  );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/vscode-extension/src/utils/periodic-sync-data.ts` around lines 46 - 57,
Collapse the intermediate array allocation by replacing the `.map().reduce()`
sequence that builds timeSpentPerProjectToday with a single `.reduce()` over
`Object.entries(filesDataToUpsert)`: iterate entries, extract
`fileData.projectPath` and `fileData.elapsedTime`, and directly accumulate into
the accumulator `Record<string, number>` (the same shape currently used) so you
avoid creating the mapped array; update the identifier
`timeSpentPerProjectToday` to use this single-pass reduction.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts`:
- Around line 37-40: The current early return discards Zod validation details;
update the failure branch where validated is checked (the validated variable and
logError call in serve-dashboard-dev.ts) to include the validation error
details—e.g., pass validated.error.issues or z.treeifyError(validated.error) (or
JSON.stringify thereof) into logError so the log contains actionable diagnostics
before returning; keep the existing message ("Invalid message shape") and append
or include the error payload for clarity.

In
`@apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts`:
- Line 57: The logError call in serve-dashboard-prod.ts currently logs "Invalid
message shape" without details; update the error logging where logError("Invalid
message shape") is called (the message validation branch) to include the
validation failure details from validated.error.issues so callers can diagnose
issues—e.g., pass or append validated.error.issues to the processLogger/logError
invocation used in this file (same pattern as in serve-dashboard-dev.ts),
ensuring the log message includes both the descriptive string and the
validated.error.issues payload.
- Around line 61-64: The code logs the raw JSON variable data but then uses
validated.data downstream; update the logging to reflect the
validated/transformed object by replacing the call to logDir(data) with
logDir(validated.data) so logInfo/logDir show the same object your handler uses
(change the logDir invocation in serve-dashboard-prod.ts just before const {
type } = validated.data).

In `@apps/vscode-extension/src/utils/files/update-files-data-after-sync.ts`:
- Around line 14-22: Remove the redundant trailing `return` at the end of the
forEach callback in update-files-data-after-sync: inside the block that updates
filesData[filePath].elapsedTime, keep the early return when
!filesData[filePath].isFrozen (which sets startTime) and then for the frozen
branch set filesData[filePath].frozenTime = file.timeSpent and let the function
exit implicitly; no change to variable names (filesData, filePath, isFrozen,
startTime, frozenTime, elapsedTime) — just delete the unreachable final
`return`.

In `@apps/vscode-extension/src/utils/periodic-sync-data.ts`:
- Around line 46-57: Collapse the intermediate array allocation by replacing the
`.map().reduce()` sequence that builds timeSpentPerProjectToday with a single
`.reduce()` over `Object.entries(filesDataToUpsert)`: iterate entries, extract
`fileData.projectPath` and `fileData.elapsedTime`, and directly accumulate into
the accumulator `Record<string, number>` (the same shape currently used) so you
avoid creating the mapped array; update the identifier
`timeSpentPerProjectToday` to use this single-pass reduction.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94dcbcf8-61fb-40cf-b67c-23e6badea743

📥 Commits

Reviewing files that changed from the base of the PR and between 0f2de9e and 4b69c18.

📒 Files selected for processing (10)
  • apps/vscode-extension/package.json
  • apps/vscode-extension/src/types-schemas.ts
  • apps/vscode-extension/src/utils/commands/init-extension-commands.ts
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-dev.ts
  • apps/vscode-extension/src/utils/dashboard/serve-dashboard/serve-dashboard-prod.ts
  • apps/vscode-extension/src/utils/files/update-files-data-after-sync.ts
  • apps/vscode-extension/src/utils/files/update-files-data-elapsed-time.ts
  • apps/vscode-extension/src/utils/files/update-files-data-frozen-states.ts
  • apps/vscode-extension/src/utils/global-state/get-global-state-data.ts
  • apps/vscode-extension/src/utils/periodic-sync-data.ts

- in the `periodicSyncData` simplified the `timeSpentPerProjectToday` calculation
- logged the validated data in the `serveDashboardProd` function
@Friedrich482
Friedrich482 merged commit 374da38 into main Apr 25, 2026
1 check 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.

1 participant