Skip to content

fix(mayfly): rebuild /btw as an editor-slot BtwView - #3

Closed
GeekCmore wants to merge 1 commit into
mainfrom
mayfly-btw-view
Closed

GeekCmore wants to merge 1 commit into
mainfrom
mayfly-btw-view

Conversation

@GeekCmore

Copy link
Copy Markdown
Collaborator

Summary

The /btw side-question panel is rebuilt from a dock pane with chrome: 'surface' into a BtwView mounted into the editor slot through mayflyEditorPanels — the same shape as the /agents attach view. The view now owns its entire frame (a ╭ BTW ─ ● running ─╮ top rule, │-framed body rows, an inline follow-up prompt, and a guidance row) and its own half-screen height budget.

User-visible bugs fixed

  • Unclosed frame / overflowing text: the old shell drew only the top rule and side bars from the pane and relied on the editor's ├┤ splice row as the bottom edge; the box visually leaked and body text could overflow. The view now draws and closes the whole box itself, at every width (minimum width 5, wraps inside the frame).
  • Stuck thinking... loader: the loader now yields as soon as the first reply bytes land and disappears when the side agent returns to idle (kimi parity), instead of trailing the finished answer.
  • Esc could not close the panel (two causes):
    1. dismiss() awaited the side agent's dispose() — which stops the agent loop and awaits its exit — before unmounting, so closing during streaming hung on the drain. The view now unmounts synchronously and disposes in the background; disposal failures no longer become unhandled rejections from a key press.
    2. The view compared raw data === '\x1b'. On terminals where pi-tui negotiates the kitty keyboard protocol, the Escape key arrives as CSI-u (\x1b[27u) and the comparison never matched. Escape and the arrow keys now resolve through mayflyKeymap (ACTION_CANCEL / ACTION_MOVE_UP/DOWN), which normalizes legacy, kitty, and modifyOtherKeys encodings — the same path every other panel uses.

The fork/seed/watermark/follow-up logic is unchanged; /btw without input still dismisses, and a new question still replaces the single slot.

Verification

  • pnpm run verify:changed green; pane-btw.ts at 100% statement/branch/function/line coverage (27 specs, including kitty-encoded Esc/arrows, pending/rejecting disposal, scroll clamping, and width scans).
  • Headless PTY acceptance against the mock LLM (xterm-headless mirror, 13 assertions): loader shows while waiting and yields to the stream, every frame row is a closed │…│ at 80 and 40 columns, inline follow-up continues the same side session, and a kitty-encoded Esc dismisses the view immediately mid-stream.

Notes

  • The now-dormant splice path (chrome: 'surface' plumbing, connectedAbove, mayfly/btw-command) is left in place and unused; removing it is a separate cleanup.
  • The same raw-'\x1b' comparison still exists in attach-view.ts, canonical-panel.ts, and plan-review-panel.ts — tracked in a follow-up issue.

The dock-pane + chrome:'surface' shell drew a frame it did not fully own:
the top rule and side bars came from the pane while the bottom edge relied
on the editor's splice row, so the box leaked and body text overflowed.
Replace it with a BtwView mounted through mayflyEditorPanels (the /agents
attach shape): the view owns the whole frame (top rule, framed rows,
inline follow-up prompt, guidance) and its half-screen height budget.

- the waiting loader yields to the first reply bytes and disappears when
  the side agent settles instead of trailing the finished answer
- dismiss unmounts the view synchronously before draining the side agent,
  so Esc/q close immediately even while a running agent's dispose is
  still pending; disposal failures no longer escape as unhandled
  rejections from a key press
- Escape and the arrows resolve through mayflyKeymap, so kitty CSI-u and
  modifyOtherKeys encodings close and scroll exactly like legacy bytes
@GeekCmore

Copy link
Copy Markdown
Collaborator Author

Closing: branch has gone stale and conflicts with main. The /btw rework can be picked up from a fresh branch when revisited.

@GeekCmore GeekCmore closed this Sep 20, 2026
@GeekCmore
GeekCmore deleted the mayfly-btw-view branch September 20, 2026 08:10
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