Skip to content

fix(editor): run-status checkmarks land on the right block, accumulate, and follow edits#225

Open
NicolaasGrobler wants to merge 1 commit into
mainfrom
fix/editor-run-status-glyphs
Open

fix(editor): run-status checkmarks land on the right block, accumulate, and follow edits#225
NicolaasGrobler wants to merge 1 commit into
mainfrom
fix/editor-run-status-glyphs

Conversation

@NicolaasGrobler

Copy link
Copy Markdown
Collaborator

Fixes #223.

Problem

The per-statement run-status glyphs in the editor gutter (green ✓ / red ✗ next to each SQL block that was run) were stored as line numbers frozen at run time and rebuilt from those numbers on every change. That broke three ways:

  1. Wrong block. When a multi-statement selection was run, it was re-split and its statements numbered relative to the selection (1, 2, 3…) instead of the document — a block on line 14 got a glyph on line 3.
  2. Wiped every run. statementResults was reset to [] at the start of each run, so running block 2 erased block 1's checkmark. Never one mark per block.
  3. Didn't follow edits / cut-paste. Glyphs were re-pinned to the frozen line on every rebuild, fighting Monaco's sticky tracking. Cutting a block and pasting it elsewhere left the checkmark on the old line, and nothing cleared a glyph whose block was destroyed.

Fix

Agreed target behavior: one checkmark per block that was run, on the correct line, that follows in-place edits and clears when its block is destroyed.

  • src/utils/statementGlyphs.ts (new, unit-tested): mapSelectionStatementsToDocumentLines maps a selection's statements back to document-absolute lines; mergeGlyphResults accumulates glyphs (one per block; re-running a block replaces its mark).
  • MainContent.tsx: selection statements now map to document-absolute lines; glyphs accumulate via appendGlyphResults (merge + dedup by line) instead of being wiped each run; the editor's position writeback goes through setGlyphResults.
  • QueryEditor.tsx: gutter glyphs are now id-keyed sticky Monaco decorations. reconcileGlyphs only creates new / removes gone glyphs (survivors keep their live, Monaco-tracked positions — they ride along as text shifts), and a throttled pruneGlyphs on content change drops glyphs whose anchor line was edited/cut and keeps survivors' line numbers fresh in tab state (so they survive a tab switch / remount).

Testing

  • npx tsc --noEmit — clean.
  • npm test181 passed, including 7 new tests in statementGlyphs.test.ts (one explicitly pins the relative-vs-absolute line regression; others cover accumulate/dedup).
  • Not yet manually verified in the running Tauri app — worth a smoke test: run two blocks, type above them, then cut one.

🤖 Generated with Claude Code

…e, and follow edits

The per-statement gutter glyphs (green check / red cross) were placed from line
numbers frozen at run time and rebuilt on every change. That broke three ways:

- A multi-statement *selection* was re-split and its statements numbered relative
  to the selection (1, 2, 3…) instead of the document, so glyphs landed on the
  wrong block.
- statementResults was reset to [] every run, so running one block wiped the
  others — never one mark per block.
- Glyphs were re-pinned to the frozen line on every rebuild, fighting Monaco's
  sticky tracking, so they didn't follow edits and didn't clear on cut.

Fix:
- New pure helpers mapSelectionStatementsToDocumentLines + mergeGlyphResults
  (src/utils/statementGlyphs.ts, unit-tested).
- MainContent: selection statements map back to document-absolute lines; glyphs
  accumulate (merge + dedup by line) instead of being wiped each run.
- QueryEditor: glyphs are id-keyed sticky Monaco decorations — reconcileGlyphs
  only creates new / removes gone glyphs (survivors keep their live positions),
  and a throttled pruneGlyphs on content change drops glyphs whose anchor line
  was edited/cut and keeps survivors' line numbers fresh in tab state.

Verified with tsc --noEmit (clean) and npm test (181 passed, incl. 7 new).

Fixes #223

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
queryden Ready Ready Preview, Comment Jun 9, 2026 4:22am

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@NicolaasGrobler, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 47 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9c46cf1a-eeb5-4481-985c-6f21b6953d7a

📥 Commits

Reviewing files that changed from the base of the PR and between 15795ea and 44e9638.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • src/components/editor/QueryEditor.tsx
  • src/components/layout/MainContent.tsx
  • src/utils/statementGlyphs.test.ts
  • src/utils/statementGlyphs.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/editor-run-status-glyphs

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.

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.

Editor: run-status gutter checkmarks land on the wrong block, don't accumulate, and don't follow edits

1 participant