Skip to content

fix(tui): harden TUI surface — markup escape, audit + rate-limit, bounded context - #49

Merged
CryptoJones merged 1 commit into
mainfrom
port/tui-tasks-hardening
Jun 12, 2026
Merged

CryptoJones merged 1 commit into
mainfrom
port/tui-tasks-hardening

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Re-targeted onto v0.2.0 (supersedes #42). v0.2.0 never touched tui/app.py or assistant.py, so all of these were still live; the guard wiring is adapted to v0.2.0's reworked tasks.py/security.py.

Still-live issues fixed

Tests (113 passed, +6)

RequestGuard audit + rate-limit; guard-metered probe; aclose awaits an in-flight probe; tab-bar escaping a bracketed title; /search surfacing an error without crashing. ruff + mypy --strict clean, coverage 89.5%.

Supersedes #42.

🤖 Generated with Claude Code

…ed context

Port onto v0.2.0 (v0.2.0 never touched tui/app.py or assistant.py, so these were
all still live). Adapts to v0.2.0's reworked tasks.py/security.py.

- Escape untrusted page titles before the tab bar renders them (a title with
  Rich-markup metacharacters could raise MarkupError or inject styling).
- New security.RequestGuard pairs the rate limiter with the audit log; the TUI
  commands/assist path and the background task probes now go through it, so the
  TUI surface is finally audited and background watches are metered (they were
  not). The MCP server keeps its own inline guard with correlation ids.
- TaskManager.aclose() now awaits the cancelled probe handles before returning,
  so quitting the TUI doesn't race on_unmount closing the shared clients.
- Bound per-turn assistant context to the most-recent few open tabs; run
  /search's ranked-results and grounded-answer calls concurrently (with
  return_exceptions so a failure in one doesn't orphan the other); derive
  /task's valid kinds from get_args(TaskKind).
- group_tabs now absorbs a malformed/non-conforming model response (catches the
  ValueError _content raises, and guards non-dict groups / non-list indexes)
  instead of crashing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant