Skip to content

core(fix): Keep hook output out of pane and option reads - #196

Merged
tony merged 7 commits into
mcp-client-guidefrom
qualified-read-hooks
Dec 6, 2026
Merged

tony merged 7 commits into
mcp-client-guidefrom
qualified-read-hooks

Conversation

@tony

@tony tony commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #183.

What changed, and why

A configured read hook can write to the same tmux client as an option lookup or pane capture. The shared server probe now qualifies the applicable hook before callers accept those bytes. Option and pane reads report :unqualified_hook for ambiguous output. The supported silent synchronization forms keep working.

Checks run

Settings and pane-wait integration tests ran against pristine tmux 3.3 and upstream 3.8, including a real printing hook, a silent synchronization hook and a pane that never produced the expected text.

  • Settings and pane reads on tmux 3.3 passed in 6.20 s.
  • Settings and pane reads on tmux 3.8 passed in 3.90 s.

Review evidence

The daemon probe owns one-shot read qualification. Option lookups and pane captures call it on the client that reads the value. The public callers retain their own return and error contracts.

With the topic tests and the runtime code from 15ee04c78, the focused check failed. The configured hook text was returned as option or pane data. An indexed option also reported an empty value as evidence. The table gives the running time of each complete command on Linux.

Regression Reverted Corrected on 861bfdbdd
Configured option Fail, 3.85 s Pass, 4.00 s
Indexed option Fail, 1.07 s Pass, 1.05 s
Pane capture and wait Fail, 1.26 s Pass, 2.33 s
Hook changed between reads Fail, 1.01 s Pass, 0.96 s
Native frame refusal Fail, 1.03 s Pass, 1.03 s
Failed capture with noisy hook Fail, 1.07 s Pass, 0.94 s

On fdec3da3, the follow-up tests failed because a clean capture error lost stdout and a padded option read raised ArgumentError. The original error now retains empty or qualified stdout up to the caller’s byte limit. A noisy hook cannot supply diagnostic screen bytes. A 32 KiB overflow returns :invalid_command with :no_write. Bypassing only the second hook check made an indexed lookup accept a fabricated empty value. The corrected 32-case suite passed on tmux 3.3 in 7.09 s and 3.8 in 6.98 s.

An independent reviewer recorded NO FINDINGS on 7c024e447.

Merge stack

This PR follows #195 in the tested merge order. The comparison shows this PR’s own changes. Stack #206 · Changes in this PR

All six required Linux jobs passed on 861bfdbdd. GitHub records the stack merge at 15b285de9. CI run · Merged commit

Tool use

Codex extracted this change from #169 and ran the checks above on the topic branch. A separate Codex reviewer checked the component boundaries and the two corrected test fixtures.

tony added 7 commits December 5, 2026 19:05
why: A printing after-show-options hook shared stdout with the native
read. A missing option looked configured, and a stored string could
acquire extra lines.

what:
- Check the applicable hook in the ordinary client's command queue.
- Admit native wait-for synchronization and report unqualified hooks.
- Preserve multiline, indexed, inherited and empty-server reads.
why: A hook could print a receipt the pane never showed. Both capture
modes returned those bytes as screen data, so a caller waiting for an
application could proceed too early.

what:
- Use the shared read-hook check in preflight and same-client capture.
- Keep identity, screen byte limits and timeout evidence independent.
- Exercise a printing hook and a silent native synchronization hook.
why: Capture now applies its own byte limit. The ordinary command
runner still received an option list that it never read.

what:
- Pass the command and deadline from all three one-shot callers.
why: The option reader resolves a tmux target along with the native
flags. Its helper name still described only the flags.

what:
- Call the local, effective and inherited scope resolver read_scope.
why: A missing pane lost its native error evidence. A silent hook can
also fail after tmux has already written the requested screen.

what:
- Preserve empty and qualified stdout up to the caller’s byte limit.
- Keep unverified bytes out of same-client and noisy-hook errors.
- Compare capture and wait failures with the native command result.
why: A descriptor can fit a plain option read but exceed the native
frame limit after the hook check is added. The encoder exception
escaped the public option API.

what:
- Prepare settings commands through the bounded Server interface.
- Check the tagged failure on a descriptor whose plain read succeeds.
- Change the hook between indexed reads and verify the second response.
@tony
tony changed the base branch from main to mcp-client-guide December 6, 2026 01:07
@tony
tony force-pushed the qualified-read-hooks branch from 7c024e4 to 861bfdb Compare December 6, 2026 01:08
@tony
tony added this pull request to stack #206 December 6, 2026 01:08
@tony
tony merged commit 15b285d into main Dec 6, 2026
6 of 10 checks passed
tony added a commit that referenced this pull request Dec 6, 2026
why: A tmux hook could add output to a pane or option read. A large
MCP reply could hide an operation outcome or advance a cursor before
the client received the page.

what:
- Fit the Program listener to the server socket path, wake waiters on
  exit, and retry pane removal after a lost reply (#191, #192, #193).
- Keep MCP operation outcomes readable and size pages before advancing
  their cursors. Show the STDIO client reading a result (#194, #195).
- Keep hook output out of pane captures and option reads. Use
  `Pane.wait_for_text/4` in the notebook (#196, #197).
- Check root exit separately from trace delivery in cold-start tests
  (#198).
- Document checkout dependencies, inherited sockets and capability
  APIs (#199, #200, #201).
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.

Pane and option reads can return text printed by a tmux hook

1 participant