Skip to content

Feat/cli replay cached diagnostics - #86

Merged
sake92 merged 5 commits into
mainfrom
feat/cli-replay-cached-diagnostics
Jun 15, 2026
Merged

Feat/cli replay cached diagnostics#86
sake92 merged 5 commits into
mainfrom
feat/cli-replay-cached-diagnostics

Conversation

@sake92

@sake92 sake92 commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Cached compilation results now replay diagnostics to CLI when cache hits occur
  • Tests

    • Added integration test to verify cache-hit diagnostics are properly replayed
    • Removed obsolete test assertions from multimodule project tests
  • Chores

    • Updated TODO items with pending improvements for CLI and initialization tooling

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an optional cliReplayFn hook to CachedTaskBuilder and CachedTask that is invoked on cache hits to re-emit stored diagnostics to the CLI. The compile task in CoreTasks wires this hook to map compiler diagnostics to server notifications. An integration test verifies the replay behavior, an outdated deder plan assertion is removed, and TODO.md is updated.

Changes

CLI Diagnostic Replay on Cache Hit

Layer / File(s) Summary
CachedTaskBuilder and CachedTask cliReplayFn hook
plugin-api/src/ba/sake/deder/Task.scala
CachedTaskBuilder gains an optional cliReplayFn field and a withCliReplay builder method; build and buildSummarized forward the hook to CachedTask; CachedTask stores the field and invokes it on cache hits with the cached value, module id, and logger.
CoreTasks compile wires withCliReplay
server/src/ba/sake/deder/CoreTasks.scala
The compile task calls .withCliReplay on its summarized task, mapping CompileSeverity to ServerNotification.LogLevel, formatting optional file/line/char location, and emitting each diagnostic via the module-scoped logger.
Integration tests and plan assertion removal
integration/test/src/ba/sake/deder/CachedTaskSuite.scala, integration/test/src/ba/sake/deder/IntegrationSuite.scala
A new CachedTaskSuite test corrupts Common.scala, asserts compile fails with diagnostics on first and second (cache-hit) runs, then restores the file. The IntegrationSuite multimodule test removes the deder plan assertion block.
TODO.md misc updates
TODO.md
Misc section revised: older items removed, new items added covering CLI replay, BSP notifications, CLI timestamps, Pkl publishing, and init tooling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • sake92/deder#81: Directly related — both implement compile-task cache-hit diagnostic replay via changes to Task.scala, CoreTasks.scala, and CachedTaskSuite.scala.
  • sake92/deder#85: Modifies the same compile task in CoreTasks.scala and adds cache-related assertions in CachedTaskSuite.scala.
  • sake92/deder#84: Fixes compile cache self-references in CoreTasks, directly affecting the cache-hit behavior this PR extends with CLI diagnostic replay.

Poem

🐇 Hop hop, the cache is hit!
No need to compile — just replay a bit.
Diagnostics flow from the build that was saved,
Each error re-shown, each warning re-waved.
The rabbit smiles — the CLI behaved! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat/cli replay cached diagnostics' clearly and concisely summarizes the main feature being added: replaying cached diagnostics to the CLI on cache hits.
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 feat/cli-replay-cached-diagnostics

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/src/ba/sake/deder/CoreTasks.scala`:
- Around line 714-716: The location formatting in the replay logic differs from
the live diagnostic formatter in CliServerMessage.scala. In the `location`
assignment around the `if diag.range.startLine > 0` condition, the code
unconditionally includes `startChar` in the formatted string, producing
`file:line:0` when the column is zero. Update the logic to only include the
column in the formatted string when `diag.range.startChar > 0`, matching the
live diagnostic formatter's behavior. This means you need to handle two cases:
when both startLine and startChar are greater than zero (include the column),
and when only startLine is greater than zero (omit the column).

In `@TODO.md`:
- Line 4: Remove the completed TODO item from line 4 of TODO.md. The line
"replay compile failures to CLI too!" describes functionality that is now
implemented in this PR through the cliReplayFn hook in CachedTask and the
.withCliReplay() wiring in CoreTasks.compile, as verified by the integration
test in CachedTaskSuite. Delete this line from the TODO list since it is no
longer a pending task.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e02364f9-621b-4ca7-9d02-dd5e1d9df6f1

📥 Commits

Reviewing files that changed from the base of the PR and between 4062840 and e57f35a.

⛔ Files ignored due to path filters (2)
  • config/DederProject.pkl is excluded by !**/*.pkl
  • deder.pkl is excluded by !**/*.pkl
📒 Files selected for processing (5)
  • TODO.md
  • integration/test/src/ba/sake/deder/CachedTaskSuite.scala
  • integration/test/src/ba/sake/deder/IntegrationSuite.scala
  • plugin-api/src/ba/sake/deder/Task.scala
  • server/src/ba/sake/deder/CoreTasks.scala

Comment on lines +714 to +716
val location = if diag.range.startLine > 0 then
Some(s"${fd.file.path}:${diag.range.startLine}:${diag.range.startChar}")
else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Location formatting inconsistency with live diagnostics when column is zero.

The replay logic always includes startChar when startLine > 0, producing file:line:0 when the column is zero. The live diagnostic formatter (in CliServerMessage.scala:70-75) only includes the column when both line and column are greater than zero, producing file:line in that case. Users comparing first-run and cached-run output may notice the discrepancy.

🔧 Proposed fix to match live diagnostic format
       val location = if diag.range.startLine > 0 then
-        Some(s"${fd.file.path}:${diag.range.startLine}:${diag.range.startChar}")
+        if diag.range.startChar > 0 then
+          Some(s"${fd.file.path}:${diag.range.startLine}:${diag.range.startChar}")
+        else
+          Some(s"${fd.file.path}:${diag.range.startLine}")
       else None
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
val location = if diag.range.startLine > 0 then
Some(s"${fd.file.path}:${diag.range.startLine}:${diag.range.startChar}")
else None
val location = if diag.range.startLine > 0 then
if diag.range.startChar > 0 then
Some(s"${fd.file.path}:${diag.range.startLine}:${diag.range.startChar}")
else
Some(s"${fd.file.path}:${diag.range.startLine}")
else None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/src/ba/sake/deder/CoreTasks.scala` around lines 714 - 716, The
location formatting in the replay logic differs from the live diagnostic
formatter in CliServerMessage.scala. In the `location` assignment around the `if
diag.range.startLine > 0` condition, the code unconditionally includes
`startChar` in the formatted string, producing `file:line:0` when the column is
zero. Update the logic to only include the column in the formatted string when
`diag.range.startChar > 0`, matching the live diagnostic formatter's behavior.
This means you need to handle two cases: when both startLine and startChar are
greater than zero (include the column), and when only startLine is greater than
zero (omit the column).

Comment thread TODO.md
- modules in stats history empty?
- init() plugin in new thread?

- replay compile failures to CLI too!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove completed TODO: cache-hit CLI replay is now implemented.

Line 4 lists "replay compile failures to CLI too!" as a TODO, but this PR implements exactly this feature via the cliReplayFn hook in CachedTask and the .withCliReplay() wiring in CoreTasks.compile. Verified by the integration test in CachedTaskSuite that asserts cache-hit compile diagnostics are replayed to the CLI. This TODO should be removed rather than left in the backlog.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TODO.md` at line 4, Remove the completed TODO item from line 4 of TODO.md.
The line "replay compile failures to CLI too!" describes functionality that is
now implemented in this PR through the cliReplayFn hook in CachedTask and the
.withCliReplay() wiring in CoreTasks.compile, as verified by the integration
test in CachedTaskSuite. Delete this line from the TODO list since it is no
longer a pending task.

@sake92
sake92 merged commit 2322fec into main Jun 15, 2026
4 checks passed
@sake92
sake92 deleted the feat/cli-replay-cached-diagnostics branch June 15, 2026 15:06
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