Skip to content

fix(ui): include source line numbers in rendering errors - #44

Merged
asaficontact merged 4 commits into
safiware:mainfrom
cracthatrock:codex/render-error-line-numbers
Oct 6, 2026
Merged

asaficontact merged 4 commits into
safiware:mainfrom
cracthatrock:codex/render-error-line-numbers

Conversation

@cracthatrock

Copy link
Copy Markdown
Contributor

Rendering errors currently omit the source line carried by the engine. The UI now uses the same positive numeric line check as the server, so a typo on line 2 appears as line 2: node "b": "rigth" is not a direction in both the canvas card and editor status. Errors with a missing or zero line retain their existing text.

Fixes #32.

Validation: the new real-engine regression test failed before the fix; all 24 UI tests, UI lint, and the UI production build pass. Browser verification used the real UI with mocked local API fixture data and confirmed the error in both locations. Full server/Electron end-to-end tests were not run for this UI-only change.

Canvas and editor showing the source line number

Signed-off-by: cracthatrock <336640790+cracthatrock@users.noreply.github.com>
@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@cracthatrock is attempting to deploy a commit to the Tawab Safi's projects Team on Vercel.

A member of the Team first needs to authorize it.

Banna added 3 commits October 6, 2026 09:51
…nd on the server

The engine's SourceError already has format() ('line N: …', what its command-line tool prints). renderSource
and the server's check() each re-derived it from a duck-typed .line; both now use the engine's error type, so
the rule lives in one place. renderSource also returns the line on its own (Rendered.line) for the editor.

Tests use the engine's real error type instead of a mocked compile: a statement written over several lines
names the line at fault, a line of 0 or a plain error keeps its text, and check() (refused saves, scheduled
drafts, Arch Agent's check_diagram) says the same as the editor.

Signed-off-by: Banna <banna@archdraw.dev>
Agent: Banna
The status line says 'line 14: …'; the gutter now marks line 14 in the danger color with a rule beside it, in
both themes, and the mark goes when the mistake does. The browser test types a mistake while editing: the status
line and the card name its line, the gutter marks that same line, Save stays disabled, and deleting the line
clears both.

Signed-off-by: Banna <banna@archdraw.dev>
Agent: Banna
@asaficontact

Copy link
Copy Markdown
Contributor

Thank you, @cracthatrock! This fixes #32 well. Your test failed before your change and passed after it (we checked), your description was precise about what you did and did not run, and the screenshot made the review quick. Your commit stays exactly as you wrote it.

We added two commits on top so it is ready to merge. Here is what changed and why, as feedback for next time and as a picture of how we build archdraw:

1. Use what the engine already has. The engine's error type, SourceError (engine/src/errors.ts), already has a format() method that prints line N: …. It is what the engine's command-line tool uses. Our issue told you to copy the server's line check, and that hint was our mistake. Copying it left the same rule in two places, both re-deriving it from a duck-typed .line. Both renderSource and the server's check() now use e instanceof SourceError && e.line > 0 ? e.format() : …, so there is one definition, and it is the engine's own.

2. Keep data as data. renderSource now returns the line on its own (Rendered.line) beside the message. Once the line is only text inside a string, nothing else can use it. With the number available, the editor marks the failing line in its gutter. That was the optional extra in the issue, and it helps most in long diagrams.

3. Test what the user sees, with the real types.

  • The unit tests now throw the engine's real SourceError instead of mocking compile, so they cannot drift from the engine.
  • A new case covers a statement written over several lines, where the engine names the line at fault rather than the line the statement starts on.
  • A new server test checks that check() says the same thing. It is what refused saves and Arch Agent's check_diagram report.
  • The browser test (app/e2e/app.e2e.ts) now types a mistake into the editor and checks four things:
    • the status line and the card name the line;
    • the gutter marks that same line;
    • Save stays disabled;
    • deleting the mistake clears both.
  • We confirmed the browser step fails when the gutter is not wired up. A unit test alone would not catch a change to how the error is displayed.

4. Up to date with main. We merged main so the branch carries today's fixes.

We ran the full local suite (scripts/ci-local.sh: types, unit tests, the browser and tour tests, the Linux package, the desktop launch and the desktop tests), and it passed.

How we approach changes in archdraw, for next time:

  • Before writing new code, look for what the codebase already has, especially in engine/.
  • A change a user can see comes with a test that fails without it. Where the change shows up on screen, test it there.
  • Run scripts/ci-local.sh before pushing. CI on pull requests from forks waits for a maintainer, so running it locally gets you the answer sooner.

Thanks again. Good first issues like this are why we file them, and you're welcome to take another.

— Banna, one of Tawab's agents

@asaficontact
asaficontact merged commit 8356c5c into safiware:main Oct 6, 2026
3 of 4 checks passed
@asaficontact asaficontact mentioned this pull request Oct 6, 2026
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.

Show the line number when a diagram fails to render in the app

2 participants