Skip to content

Fix: notebook form has no silent number clamp, and optional parameters can be left unset (F8 F9) - #46

Merged
guijacquemet merged 2 commits into
mainfrom
claude/fix-notebook-form
Oct 8, 2026
Merged

guijacquemet merged 2 commits into
mainfrom
claude/fix-notebook-form

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

Fixes the notebook-form theme of the round-trip findings; the skipped matrix cases now run as normal tests and F8/F9 are removed from tests/roundtrip_known_failures.py.

Before -> after (notebook.py)

  • F8, numbers: a box with no Min/Max silently clamped integers and floats at +-109 (and the person was never told). Now integers with no bounds, or only one, use an unbounded IntText, floats an unbounded FloatText; a box with both bounds stays BoundedIntText/BoundedFloatText; a single bound is checked at run time by the shared validation. The explicit limit is MAX_FORM_INTEGER = 2**53 - 1 (the largest integer a JSON number carries exactly: the form exchanges JSON numbers with the page); an integer beyond it is refused at run() with invalid_parameter, the message giving the value and the limit and saying to use a smaller number or the CLI or a snippet; the limit is also in the control's tooltip. Decided by you (one limit in every form): 253-1 is the reference for every host; the other hosts move to it in the host alignment work.
  • F9, optional parameters: the control always held a value, so the tool received 0, "", False or the first option. Now each nullable integer, float, string, choice or boolean gets a "set" checkbox beside the control (form.set_toggles); unchecked (the start state, control greyed out) means the parameter is omitted and the tool receives None; ticking it sends the control's value including 0, "" and False. Required parameters and path boxes are unchanged.

Tests: new tests/test_notebook_unset_and_range.py (6 tests). Test support: roundtrip_harness.run_notebook ticks the "set" box for any optional parameter a case sets; roundtrip_cases.py gets an oracle constant MAX_FORM_INTEGER and the notebook transport now carries integers up to +-(253-1) and every float in FLOAT_OK (before: ints up to 231, floats below 1e9). Docs: PROTOCOL.md ("set" box and the number-limit rule), REGRESSION_LEDGER.md (replace "this PR" with this number). notebook_magic.py needed no change.

Host follow-ups (not in this PR): Napari: Qt spin boxes limited to +-(231-1) / +-1e15 when the schema gives no bound; Fiji: refuses ints outside int32 only on the macro path, the dialog path needs the same message and limit; QuPath: the integer spinner accepts only +-LcConst.INT_LIMIT and casts to int. Each must show the 253-1 limit and refuse beyond it with the same message. The hosts' "set" boxes for nullable parameters already match the notebook.

Verified by the author on Linux, Python 3.11: black, ruff, mypy; the full suite before the last merge (404 tests, only the two environmental sandbox failures); after merging main, lint plus the notebook, known-failures and ledger tests. Not run separately: the sabotage test and coverage floor (CI runs both), Windows, macOS.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y2SN8SuEakTdiWy3F2WUqN


Generated by Claude Code

@guijacquemet
guijacquemet merged commit a17a0c2 into main Oct 8, 2026
14 checks passed
@guijacquemet
guijacquemet deleted the claude/fix-notebook-form branch October 14, 2026 16:09
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.

2 participants