Skip to content

State machine: green arrows where the call is allowed, red crossed arrow from the actual state - #207

Open
CatarinaGamboa wants to merge 3 commits into
mainfrom
feat/206-call-arrows
Open

CatarinaGamboa wants to merge 3 commits into
mainfrom
feat/206-call-arrows

Conversation

@CatarinaGamboa

@CatarinaGamboa CatarinaGamboa commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

In focus mode every arrow of the called method was red, including those from the states where the call is allowed, and the actual state had no arrow for the call at all, since the spec has none. Only facts from the spec and the verifier's error context are drawn, as #206 asks.

What changed

  • The transitions of the called method are green (--lj-state-valid), arrow and label, with their guards. An unmet guard keeps its red text, so in A1_38 reset from open is a green arrow with [marked(this)] in red.
  • Each possible state that rejects the call gets a red crossed loop ✕ method: the attempted call. When the spec already has a transition of the method from such a state, that one is drawn as the rejected call instead. No red loop when the state of the receiver is unknown (A1_09).
  • The loop is no spec transition: never dimmed, collapsed, counted in "+N more" or listed on hover. Where the state already has a loop, the rejected call is its first line, red, like setCompressionType +8 more shares the green loop (see the deviation below).
  • Legend: → Where method() is allowed and ✕→ The call, not allowed here, each only when on the diagram; the swatches are arrows.
  • Same colouring with Show all. Dimming, collapsing, the summary line and Ways to fix are untouched.
  • Without the accepted states (no focus, no legend) the called method keeps its plain label, since nothing says where the call is allowed (Codex, round 2).
  • Classes renamed to what they mean: lj-call-allowed, lj-call-rejected (label, transition, marker).
  • Client version 0.1.4.

Deviation from #206: a separate loop for the rejected call on a state that already has a spec loop (A1_01, compressionNotExplicit has setCompressionMode) made ELK nest the second loop around the first one's label, and the rounding drew it as an ellipse across the diagram in TB. No state had two loops before, since methods between the same states share one edge, so the rejected call shares the state's loop, as the green call shares its loop with the other methods. In Show all the loop shows ✕ setCompressionType over setCompressionMode.

Screenshots (focused State Machine tab)

Task Before After
A1_01 dark
A1_09 dark (state unknown: green only)
A1_38 dark
A1_38 dark, scrolled to the stream set (green reset with the red guard)
A1_01 light
A1_38 light
A1_38 light, stream set
A1_38 Show all, LR
A1_01 Show all, LR

Not in scope: a hint's path (#156), which states are dimmed or collapsed (#170), the Verification tab.

Tests: 154 vitest tests pass (152 on main; two new: the call from a rejecting state drawn as the rejected call, and the rejected call on the state's existing loop); the legend and focus tests adapted. Lint and tsc clean.

Closes #206

🤖 Generated with Claude Code

CatarinaGamboa and others added 2 commits November 18, 2026 19:14
…row from the actual state

In focus mode every arrow of the called method was red, including those
from the states where the call is allowed, and the actual state had no
arrow for the call at all, since the spec has none. Now the transitions
of the called method are green, arrow and label, with their guards (an
unmet guard keeps its red text), and each possible state that rejects
the call gets a red self-loop "✕ method": the attempted call. When the
spec already has a transition of the method from such a state, that one
is drawn as the rejected call instead. No red loop when the state of the
receiver is unknown. The loop is never dimmed, collapsed or counted, as
it is no spec transition. The legend gains the two arrows, each only
when on the diagram. Same colouring with Show all.

Client version 0.1.4 for the study build.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ELK nests a second self-loop around the first one and its label, and the
rounding then drew it as a wide ellipse across the diagram (A1_01, top
to bottom). No state had two loops before, since the methods between the
same states share an edge, so the rejected call now shares the state's
loop too, as its first line, red; a state without a loop gets a new one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@CatarinaGamboa

Copy link
Copy Markdown
Collaborator Author

Codex review, round 1 (on ad23230, codex exec review --base origin/main)

I found no actionable regressions in the diff. Type-checking and all 153 unit tests pass.

Nothing to fix. A second round follows on the final diff.

Without them nothing says where the call is allowed, and the legend is
not shown, so a green label had no explanation. The method keeps its
plain label in that case; the possible states stay outlined.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@CatarinaGamboa

Copy link
Copy Markdown
Collaborator Author

Codex review, round 2 (on 0989cb4)

[P2] Avoid marking calls as allowed when accepted states are unknown — diagram.ts:129. When the server reports an invalid call but cannot determine its accepted states (for example, when acceptance depends on arguments), getStateErrorFocus(sm) is null. This branch still labels every transition of the called method green as allowed, leaving the diagram with no rejected-call mark despite the error summary.

Fixed in 303e507: the called method is coloured only when there is a focus (accepted states known). Without one nothing says where the call is allowed and the legend is not shown, so the method keeps its plain label; the possible states stay outlined as before. The existing test for that case now asserts no colour.

CatarinaGamboa added a commit that referenced this pull request Nov 18, 2026
@CatarinaGamboa

Copy link
Copy Markdown
Collaborator Author

Codex review, round 3 (on 303e507)

No actionable regression was identified. The relevant unit tests and TypeScript typecheck pass.

Nothing new; the loop ends here.

@CatarinaGamboa

Copy link
Copy Markdown
Collaborator Author

Clean-code review (clean-code-principles skill, own diff only)

  • client/src/webview/views/fsm/fsm.ts:176 - [core-dry] hasAllowedCall repeats the one-line predicate of diagram.ts:121 (a transition of the called method from a state in invalidStates is the rejected call). Declined: a shared helper would be an export for two call sites with different null handling (the diagram colours without a focus too); the small-PR rule wins over a five-line extraction.
  • client/src/webview/diagram.ts:304 - [core-kiss] colourCallTransitions queries once per kind instead of one query that reads the kind from the class. Declined: two kinds, the loop reads plainly.
  • client/src/webview/styles.ts:1346 - [name-meaningful] the legend arrow swatches share their rules through a local --lj-call-colour variable instead of repeating each colour three times. Kept, no finding.
  • Naming: the classes say what they mean (lj-call-allowed, lj-call-rejected, -transition, -marker); nothing green is called an error. No finding.

Nothing fixed, nothing else found.

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.

State machine: green arrows where the called method is allowed, red crossed arrow from the actual state

1 participant