Skip to content

perf(preview): symlink static deps#545

Open
iamgio wants to merge 1 commit into
mainfrom
06-08-perf_preview_symlink_static_deps
Open

perf(preview): symlink static deps#545
iamgio wants to merge 1 commit into
mainfrom
06-08-perf_preview_symlink_static_deps

Conversation

@iamgio

@iamgio iamgio commented Jun 9, 2026

Copy link
Copy Markdown
Owner
  • I have read the contributing guidelines.
  • I have tested the changes locally.
  • An issue for this change exists, and it was discussed with maintainers. This is required for new features and non-trivial changes. If present, append Closes #ISSUE_NUMBER at the end of this PR description.
  • (Optional) I have added necessary documentation to docs and CHANGELOG.md

Summary by CodeRabbit

  • Documentation

    • Changelog updated to describe faster live preview and reduced disk usage.
  • New Features

    • Preview mode emits dependency files as symbolic links to reduce copying and disk use.
  • Tests

    • Added/expanded tests for live preview edits, syntax highlighting across edits, and symlink-based dependency handling.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a symlink-first option for materializing script and third-party files in preview: new pipeline flag and artifact property, IO utilities for safe symlinking, exporter logic that prefers symlinks with checksum-copy fallback, rendering wiring, tests, and changelog updates.

Changes

Symlink-based Dependency Linking

Layer / File(s) Summary
Data model and configuration for symlink option
quarkdown-core/.../PipelineOptions.kt, quarkdown-core/.../FileReferenceOutputArtifact.kt, quarkdown-install-layout-navigator/.../InstallLayoutEntry.kt
PipelineOptions adds computed symlinkDependencies property tied to preview mode; FileReferenceOutputArtifact gains symlink: Boolean = false; InstallLayoutEntry.asOutputResource() accepts and forwards symlink.
Low-level filesystem symlink utilities
quarkdown-core/.../IOUtils.kt
Adds IOUtils.trySymlink() and helpers for safe symlink creation/replacement and recursive deletion that avoid following links.
File export with symlink-first resolution
quarkdown-core/.../FileResourceExporter.kt
Exporter tries symlink creation first via IOUtils.trySymlink, then checksum-invalidated copy with .checksum maintenance (skips only when checksum matches and target is not a symlink), otherwise falls back to unconditional copy.
Comprehensive filesystem symlink behavior tests
quarkdown-core/.../FileResourceExporterTest.kt
Adds symlink support detection and multiple tests covering file/dir symlinking, source-change reflection, stale target replacement, protected-source safety, nested-symlink deletion safety, reuse vs recreation, and symlink precedence over checksum invalidation.
HTML rendering integration with symlink flag
quarkdown-html/.../HtmlPostRenderer.kt, quarkdown-html/.../ScriptPostRendererResource.kt, quarkdown-html/.../ThirdPartyPostRendererResource.kt
HtmlPostRenderer reads symlinkDependencies and forwards it into script and third-party resource classes; those classes forward symlink into asOutputResource(symlink=...).
Integration tests for symlink marking in output resources
quarkdown-test/.../HtmlOutputResourceTest.kt, quarkdown-html/.../HtmlResourceGenerationTest.kt
Tests verify lib/ third-party artifacts are marked as symlinks in preview mode and copied in non-preview mode; also passes nonexistent library dir case with explicit symlink = false.
End-to-end highlight.js re-application across edits
quarkdown-html/.../live-preview.spec.ts
Adds Playwright e2e test verifying syntax highlighting updates after sequential live edits (Kotlin fun → Python def).
Changelog documentation
CHANGELOG.md
Updates "Faster live preview" entry to describe symlink-based third-party library referencing and SSE-based live preview transport.

"I hop and link with gentle paws,
Dependencies find their rightful cause,
No extra copies in the night,
Checksums guard, symlinks light,
Preview races on with nimble claws." 🐇✨

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enabling symlink-based static dependency management in preview mode for performance improvement.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-08-perf_preview_symlink_static_deps

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

iamgio commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@iamgio iamgio force-pushed the 06-08-perf_preview_symlink_static_deps branch 3 times, most recently from f611364 to 37d7f78 Compare June 9, 2026 07:24
@iamgio iamgio marked this pull request as ready for review June 9, 2026 07:24
@iamgio iamgio force-pushed the 06-08-perf_preview_symlink_static_deps branch from 37d7f78 to 827762f Compare June 9, 2026 07:27

@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 `@CHANGELOG.md`:
- Around line 19-23: Rewrite the "#### Faster live preview" changelog entry to
be fully user-facing: describe benefits (faster preview updates, reduced disk
usage, and more reliable preview transport) and add a documentation link to
https://quarkdown.com/wiki/Page; keep implementation details minimal (if needed,
put them parenthetically) and replace phrases like "symbolic links" and
"checksum-optimized" with user-centered wording such as "references libraries
via links (reducing duplicate files)"; also mention the transport change as "now
uses Server-Sent Events (SSE) for more reliable browser previews" and include
the wiki link inline for users to read more.

In `@quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt`:
- Around line 337-361: The tests `preview mode marks third-party libraries as
symlinks` and `non-preview mode copies third-party libraries instead of
symlinking` rely on a default empty `source = ""`; update both tests to provide
an explicit fixture source that requires a known third-party library so
`getThirdPartyLibraryArtifacts(group)` is guaranteed non-empty, keep using
`execute(..., previewMode = true|false, outputResourceHook = { group -> ... })`;
also add analogous assertions for the script resource path by calling the script
artifact accessor (e.g., getScriptArtifacts(group) or the project’s script
artifact helper) and assert its `symlink` flag matches the expected behavior
(true in previewMode test, false in non-preview test) so both third-party and
script wiring are covered.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d04e0b7-30b8-418d-a4a8-b1207d13ed6e

📥 Commits

Reviewing files that changed from the base of the PR and between e8900e2 and 827762f.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/PipelineOptions.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/FileReferenceOutputArtifact.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/visitor/FileResourceExporter.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/util/IOUtils.kt
  • quarkdown-core/src/test/kotlin/com/quarkdown/core/FileResourceExporterTest.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/HtmlPostRenderer.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ScriptPostRendererResource.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ThirdPartyPostRendererResource.kt
  • quarkdown-html/src/test/e2e/live-preview/live-preview.spec.ts
  • quarkdown-install-layout-navigator/src/main/kotlin/com/quarkdown/installlayout/InstallLayoutEntry.kt
  • quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt

Comment thread CHANGELOG.md
@iamgio iamgio force-pushed the 06-08-perf_preview_symlink_static_deps branch from 827762f to bd7349b Compare June 10, 2026 02:58
@iamgio iamgio force-pushed the 06-08-perf_preview_symlink_static_deps branch from bd7349b to 6c20216 Compare June 10, 2026 03:14

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

♻️ Duplicate comments (1)
quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt (1)

349-375: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make symlink tests deterministic by using an explicit third-party fixture source.

These assertions still depend on source = "" implicitly producing lib artifacts. Please switch both tests to a source that explicitly requires a known third-party library so failures only reflect symlink wiring, not default-library behavior drift. Line 356/Line 370 currently guard emptiness, but they don’t remove this coupling.

As per coding guidelines, “Aim for a test-driven development (TDD) approach when possible; add or update tests when making changes to the compiler or other modules; ensure high test coverage across unit tests, integration tests, and E2E tests.”

🤖 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 `@quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt`
around lines 349 - 375, Replace the implicit empty-source usage in both tests
with an explicit third-party fixture source so the tests deterministically
produce third-party artifacts: update the two execute(...) calls in the tests
`preview mode marks third-party libraries and script as symlinks` and
`non-preview mode copies third-party libraries and script instead of symlinking`
to pass a source that imports a known third-party library (so
getThirdPartyLibraryArtifacts(group) will always return the expected libs),
leaving the existing assertions and hooks (execute,
getThirdPartyLibraryArtifacts, getScriptArtifact) unchanged.

Source: Coding guidelines

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

Duplicate comments:
In `@quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt`:
- Around line 349-375: Replace the implicit empty-source usage in both tests
with an explicit third-party fixture source so the tests deterministically
produce third-party artifacts: update the two execute(...) calls in the tests
`preview mode marks third-party libraries and script as symlinks` and
`non-preview mode copies third-party libraries and script instead of symlinking`
to pass a source that imports a known third-party library (so
getThirdPartyLibraryArtifacts(group) will always return the expected libs),
leaving the existing assertions and hooks (execute,
getThirdPartyLibraryArtifacts, getScriptArtifact) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d5624482-f954-478d-9840-89dde0fe9b9e

📥 Commits

Reviewing files that changed from the base of the PR and between bd7349b and 6c20216.

📒 Files selected for processing (13)
  • CHANGELOG.md
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/PipelineOptions.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/FileReferenceOutputArtifact.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/visitor/FileResourceExporter.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/util/IOUtils.kt
  • quarkdown-core/src/test/kotlin/com/quarkdown/core/FileResourceExporterTest.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/HtmlPostRenderer.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ScriptPostRendererResource.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ThirdPartyPostRendererResource.kt
  • quarkdown-html/src/test/e2e/live-preview/live-preview.spec.ts
  • quarkdown-html/src/test/kotlin/com/quarkdown/rendering/html/HtmlResourceGenerationTest.kt
  • quarkdown-install-layout-navigator/src/main/kotlin/com/quarkdown/installlayout/InstallLayoutEntry.kt
  • quarkdown-test/src/test/kotlin/com/quarkdown/test/HtmlOutputResourceTest.kt
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (10)
  • quarkdown-html/src/test/kotlin/com/quarkdown/rendering/html/HtmlResourceGenerationTest.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ScriptPostRendererResource.kt
  • quarkdown-html/src/test/e2e/live-preview/live-preview.spec.ts
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/resources/ThirdPartyPostRendererResource.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/FileReferenceOutputArtifact.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/pipeline/output/visitor/FileResourceExporter.kt
  • quarkdown-install-layout-navigator/src/main/kotlin/com/quarkdown/installlayout/InstallLayoutEntry.kt
  • quarkdown-core/src/main/kotlin/com/quarkdown/core/util/IOUtils.kt
  • quarkdown-html/src/main/kotlin/com/quarkdown/rendering/html/post/HtmlPostRenderer.kt
  • quarkdown-core/src/test/kotlin/com/quarkdown/core/FileResourceExporterTest.kt

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