An action that fails says so, and the canvas stops lying about it (#1423) #1424

Merged
jaylouisw merged 1 commit from fix/ui-says-what-failed into main 2026-11-11 04:57:34 +00:00
Owner

Closes #1423.

web/app.js reports nearly every failure - api() records the call so it reaches a bug report and rethrows, and the caller shows the reason - except the drag:

PFCanvas.on.move = async function (id, x, y) {
  topo.layout[id] = { x, y };
  try { await api('POST', '.../layout', ...) } catch (e) {}   // the drag was a save, and the save was lost
};

Drag a device while the position is refused (now a real possibility: #1421 bounds a position to the canvas's world) or the server is gone, and the box stays where it was dropped — the canvas shows a lab that is not the lab on disk — the next reload puts it back with no explanation, and a device that had no position gets an invented one. The only trace was in a bug report nobody had opened.

Fixed

  • the position goes back to what the server has, and the reason is shown in the toast and the status bar, in the server's own words;
  • a failed first drag leaves no position behind;
  • the palette's "someone asked for this" markers are no longer emptied when the forge is slow (openRequests = []) — that is not "the palette is unchanged", it is losing what it had.

The class, pinned

test/ui-action-failures.test.js scans web/*.js with a small brace-matched scan (a regex cannot answer "what is inside this catch block") and requires every catch whose try block calls api() to reach the user — toast, setStatus, setLinkHint, recordError, writing into the page, or a rethrow — or to carry /* silent-ok: <reason> */. console.error alone does not count: the person who clicked does not read the console, which was the finding of #20.

Six deliberate escapes carry markers with their reasons: the bug report's own version field, the two link-validation fall-throughs, and the enrichment path.

Evidence — 13 checks

  • success: the box is where it was dropped, one POST /layout went out, nothing complained about;
  • failure: the box is back at {100,100}, the toast says Position not saved and repeats the server's message, the status bar agrees, and a first drag that fails leaves no layout entry;
  • reverting the drag fix fails 6 of them, quoting the old defect: {"x":700,"y":500} still on the canvas after a failed save, no toast element, {"d1":{"x":50,"y":60}} invented;
  • planting a new catch (e) {} around an api() call fails the static check by line number (app.js:2974 -> {}).

test/requests-panel.test.js pinned the old source text; it now pins the intent (a failed call does not blank the request list) — the assertion was even named "leaves the palette alone" while the code emptied it.

Suite: 212 suites, 8,078 assertions, 0 failed; syntax 280 files OK. Docs: docs/ARCHITECTURE.md, "An action that fails says so".

Closes #1423. `web/app.js` reports nearly every failure - `api()` records the call so it reaches a bug report and rethrows, and the caller shows the reason - except the drag: ```js PFCanvas.on.move = async function (id, x, y) { topo.layout[id] = { x, y }; try { await api('POST', '.../layout', ...) } catch (e) {} // the drag was a save, and the save was lost }; ``` Drag a device while the position is refused (now a real possibility: #1421 bounds a position to the canvas's world) or the server is gone, and the box stays where it was dropped — **the canvas shows a lab that is not the lab on disk** — the next reload puts it back with no explanation, and a device that had no position gets an invented one. The only trace was in a bug report nobody had opened. ### Fixed - the position goes back to what the server has, and the reason is shown in the toast and the status bar, in the server's own words; - a failed first drag leaves no position behind; - the palette's "someone asked for this" markers are no longer **emptied** when the forge is slow (`openRequests = []`) — that is not "the palette is unchanged", it is losing what it had. ### The class, pinned `test/ui-action-failures.test.js` scans `web/*.js` with a small brace-matched scan (a regex cannot answer "what is inside this catch block") and requires every `catch` whose try block calls `api()` to reach the user — `toast`, `setStatus`, `setLinkHint`, `recordError`, writing into the page, or a rethrow — **or** to carry `/* silent-ok: <reason> */`. `console.error` alone does not count: the person who clicked does not read the console, which was the finding of #20. Six deliberate escapes carry markers with their reasons: the bug report's own version field, the two link-validation fall-throughs, and the enrichment path. ### Evidence — 13 checks - success: the box is where it was dropped, one `POST /layout` went out, nothing complained about; - failure: the box is back at `{100,100}`, the toast says *Position not saved* and repeats the server's message, the status bar agrees, and a first drag that fails leaves no `layout` entry; - **reverting the drag fix fails 6 of them**, quoting the old defect: `{"x":700,"y":500}` still on the canvas after a failed save, `no toast element`, `{"d1":{"x":50,"y":60}}` invented; - **planting a new `catch (e) {}` around an `api()` call** fails the static check by line number (`app.js:2974 -> {}`). `test/requests-panel.test.js` pinned the old source text; it now pins the intent (`a failed call does not blank the request list`) — the assertion was even *named* "leaves the palette alone" while the code emptied it. Suite: **212 suites, 8,078 assertions, 0 failed**; syntax 280 files OK. Docs: `docs/ARCHITECTURE.md`, "An action that fails says so".
An action that fails says so, and the canvas stops lying about it (#1423)
All checks were successful
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 17s
CI / Test (Node 20) (pull_request) Successful in 2m45s
CI / Test (Node 18) (pull_request) Successful in 2m53s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 47s
CI / Test (Node 22) (pull_request) Successful in 2m45s
47f595bb51
web/app.js reports nearly every failure: api() records the call so it reaches a bug report and rethrows, and the caller shows the reason in a toast, a hint or the status bar. One did not:

  PFCanvas.on.move = async function (id, x, y) {
    topo.layout[id] = { x, y };
    try { await api('POST', '.../layout', ...) } catch (e) {}
  };

Drag a device while the server refuses the position - or is simply not there - and the box stays where it was dropped: the canvas is showing a lab that is not the lab on disk, and the next reload, or another tab's next broadcast, moves it back with no explanation. The error reached the bug report and nobody else.

Fixed: the position goes back and the reason is shown, in the server's own words, in the toast and the status bar.

And the class is pinned. test/ui-action-failures.test.js scans web/*.js with a small brace-matched scan (a regex cannot say what is inside a catch block) and requires every catch whose try block calls api() to reach the user - toast, setStatus, setLinkHint, recordError, writing into the page, or a rethrow - or to carry a /* silent-ok: <reason> */ marker, which is a sentence a reviewer has to read. console.error alone does not count: the person who clicked does not read the console, which was the finding of #20.

The sweep found one more silence of the same shape and fixed it: the palette's 'someone already asked for this' markers were emptied when the forge was slow (openRequests = []), which is not leaving the palette alone - it is losing what it had.

Six deliberate escapes now carry markers, each with its reason: the bug report's own version field, the two link-validation fall-throughs, and the enrichment path.

Evidence: 13 checks. With the drag fix reverted, 6 of them fail - including the old defect exactly ({"x":700,"y":500} still on the canvas after a failed save, no toast, an invented position left behind). Planting a new 'catch (e) {}' around an api() call fails the static check by line number. Suite: 212 suites, 8,078 assertions, 0 failed; syntax 280 files OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-11 04:57:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1424
No description provided.