Skip to content

Type retained-history inputs and reject unknown requested agents - #1147

Merged
trissim merged 4 commits into
mainfrom
next/toad-types-04
Oct 23, 2026
Merged

trissim merged 4 commits into
mainfrom
next/toad-types-04

Conversation

@trissim

@trissim trissim commented Oct 23, 2026 •

Copy link
Copy Markdown

An explicit unknown -a / --agent now fails at get_agent_binding, naming the requested value and listing known short names and identities. Empty launch_agent still returns NoAgent. This PR also types retained-history parameters and fixes the import-order lint regression from #1143.

Four separate commits:

  • 0e4d384: fail loud for an unknown requested agent.
  • 3f6ea07: retained-history annotations from autotyping 24.9.0 --aggressive followed by Pyrefly 1.4.0 infer, corrected against the existing owner types.
  • 677a649: move CommandTarget above goal_presentation in conversation.py; no noqa or ignore change.
  • 8bb520c: update the existing startup-binding test to expect BadParameter for an unknown agent.

Counts are pinned to base 433f04f and head 8bb520c. The seven touched production files are cli.py and widgets/{committed_presentation,conversation,history_anchor,transcript_fragments,transcript_history,transcript_lines}. In tests/textual/test_agent_binding.py, the existing startup-binding test removes the unknown-agent/NoAgent row and asserts pytest.raises(click.BadParameter, match="no-such-startup-agent") around the same lookup. No new test function or fixture.

AST count Base Head
Unannotated parameters, seven-file batch 168 127
Unannotated parameters, whole src/toad 2,041 2,000
Explicit Any, whole src/toad 10 10

The AST count includes positional-only, positional, keyword-only and both variadics, excluding self/cls. No previously annotated parameter became bare. Corrected inferred bool callbacks to Callable[[], bool], layout size integers to Textual Size, and the sibling-generator union to Iterable[Widget].

The new ratchet finding was conversation.py:1:1, I001: CommandTarget had been inserted after the later-sorting goal_presentation import. Ran the ratchet's exact Ruff command on full revision trees with the head's pyproject.toml:

python -m ruff check --no-cache --output-format concise src/toad/widgets/conversation.py
Revision LintFindings on conversation.py
661fc63 9
e0cade1 10
677a649 9

All seven touched modules import under python -I with this source and Core 06f123fbd first on sys.path, and compileall passes for each. Full-production Pyrefly reports 1,262 errors on both the pinned main snapshot and this head: zero new diagnostics, not a passing checker. Checks run nice -n 19; Pyrefly uses one thread.

Interpreter proofs with the real packaged catalog:

  • The actual Click run command invoked with ['-a', 'nosuch'] raises BadParameter: "Unknown agent 'nosuch'. Known agents: ...", including all 21 accepted catalog entries.
  • get_agent_binding('') returns NoAgent.

Stops retained in the missing counts:

  • widgets/transcript_lines.py:235,284 versus line_blocks.py:253: prepared_rows overrides return PreparedLines, while the parent promises an arbitrary callback result RowsT. That generic contract needs correction before annotating those override parameters.
  • widgets/transcript_lines.py:636: hold receives TranscriptPageView, LineHistory and Contents. Their shared native rendering-input capability is not declared; rejected the inferred empty-only tuple instead of adding a sibling union.
  • widgets/transcript_fragments.py:302: capture_part rewrites a native text field, while the fragment factory family also handles incoming wire events through an override. NativeTextTranscript owns the writable field; the factory/input relationship needs a declared contract.
  • frame_presentation.py:197: typing the frame owner exposes Textual's optional _driver where flushing requires a live driver. Kept that file out of this batch; no object replacement or guard added.

Assumed:

  • Nonempty unknown agent names are invalid CLI arguments; empty input means no selected agent.
  • Existing declarations define callback and layout inputs; uninferred contracts remain counted.
  • Existing checker failures remain failures. This PR does not claim the production package is fully typed.

Apply autotyping/Pyrefly inference and correct inferred booleans to callbacks and numeric size guesses to Textual Size. Use Iterable[Widget] for visible native history items. Leave unsupported contracts unchanged and counted; no existing parameter annotation is erased.
@trissim
trissim force-pushed the next/toad-types-04 branch from ddfa349 to 677a649 Compare October 23, 2026 11:28
@trissim
trissim marked this pull request as ready for review October 23, 2026 11:30
Copilot AI balanced review requested due to automatic review settings October 23, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@trissim
trissim merged commit aeef59e into main Oct 23, 2026
2 of 3 checks passed
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