Skip to content

feat(agent): make the pane fit any terminal and feel friendlier - #411

Merged
fcoury merged 9 commits into
mainfrom
feat/agent-pane-polish
Oct 18, 2026
Merged

fcoury merged 9 commits into
mainfrom
feat/agent-pane-polish

Conversation

@fcoury

@fcoury fcoury commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

A real-Codex walkthrough of pair mode in tmux at 180×50, 120×40, 100×30, 80×24 and 60×18 turned up a layout problem that makes the Agent pane unusable on small terminals, plus a handful of rough edges that made the pane feel unfinished. This PR fixes the layout and polishes the rest.

Why

Narrow terminals squeezed the editor to nothing. The Agent pane is created at 62 columns and kept about 64 at every terminal size. At 80 columns the editor got 12 columns, at 60 it got 5, and every source line wrapped into an unreadable ribbon:

src   report.rs│ Agent · Codex                   [Activity] [Clear] [New] [×]
   1 use crate::p│──────────────────────────────────────────────────────────────
     arse::Entry;│ src/parse.rs parses date,description,amount lines into Entry
   2             │ records, trimming whitespace, converting amounts to integer
   3 #[derive(Deb│ cents, and reporting missing fields or invalid amounts. It

Smaller rough edges found along the way:

  • With the pane already open, Space A landed the composer in Normal mode, so the first characters typed were read as commands.
  • :qa, :qa!, :wqa and :xa reported "unknown command".
  • Narrow table columns split words in half ("administrativ / e", "src/util.r / s").
  • A queued follow-up looked exactly like a sent message.
  • A user-requested stop read "Agent stopped: interrupted". The paused-queue status ("1 queued · paused · :AgentSendQueued or :AgentDiscardQueued") was cut off in a narrow pane.
  • The agent called open_file on its own and switched the user's buffer.
  • With push-only language servers (rust-glancer), the agent's diagnostics refresh always waited out its deadline and came back as a bare timeout, so answers ended with "validation is unconfirmed".

What changed

Responsive pane layout (src/plugin/panel.rs, src/editor.rs). Side panes with a composer (conversation panes) now size themselves:

  • At the plugin's declared width, the pane takes at most 45% of the terminal and never less than 32 columns.
  • A width the user picked by dragging or resizing is kept as long as the editor keeps 40 columns. A conversation pane never docks narrower than 32 columns, and resizes are held between 32 columns for the pane and 40 for the editor.
  • Several conversation panes dock in z-order while each still gets 32 columns and the editor keeps 40; one that does not fit becomes compact instead of overlapping the editor.
  • Compact mode: when the terminal can't fit a 32-column pane next to a 40-column editor (below 73 columns, or less with a file tree open), the pane stops docking. It reserves no columns and covers the screen only while it has focus, using the existing pane-zoom presentation without setting the user's zoom. When focus returns to the editor, the editor gets the full width. Esc from the pane's transcript returns to the editor in compact mode; docked panes keep their current Esc behaviour.
  • The core sends panel:event:<id> with action: "view" and text: "hidden" or "visible" when a compact pane leaves or rejoins the screen. The Agent pane uses it to print Agent finished · Space A to view for turns that finish while the pane is covered.
  • One allocation (side_panel_widths) drives the editor's reservation, the pane placements, and text layout, so they always agree.
Terminal Before: pane / editor After: pane / editor
180 62 / 117 62 / 117
120 62 / 57 54 / 65
100 62 / 37 45 / 54
80 62 / 17 36 / 43
60 54 / 5 compact: full screen while focused, else 0 / 60

Polish:

  • FocusTextPanelComposer (what Space A uses) always lands in Insert mode. Switching between composer and transcript with Tab still keeps the composer's own mode.
  • New commands: :qa/:qall/:quitall (with !), :x/:xit/:exit (writes only if modified, to a given filename if one is passed), and :wqa/:wqall/:xa/:xall (write all, then quit; with ! the writes overwrite files changed on disk). A quit now waits for every pending format-on-save, and a failed save cancels it with a message. :e still means :edit.
  • Markdown table columns never get narrower than their longest word. A grid that can't fit without splitting words falls back to the existing key/value records layout.
  • New queued text-panel block kind, recorded in the pending 0.21.0 API entry along with the view event: a dimmed You · queued prompt card that doesn't take the "current prompt" accent or turn actions. The Agent pane uses it for follow-ups held behind a running turn or a paused queue. Only the first message, sent while a thread starts, looks sent.
  • The Agent pane, in plugins/agent.hk:
    • Status row: each turn gets one working verb ("Thinking…", "Pondering…", "Mulling it over…", …) instead of "Waiting for agent…". The verb stays fixed for the turn, so the status row doesn't flicker. A paused queue reads "1 held · :AgentSendQueued to send".
    • Stop messages: a requested stop reads "Stopped at your request." in the transcript. Other stop reasons are still shown verbatim.
    • Notices: queue, discard and cancel notices are reworded.
    • Empty pane: it says what the agent can do and lists the most useful keys.
  • The floating "Agent prompt" dialog shows three first-time tips, word-wrapped. Tips that don't fit are dropped whole.
  • Agent instructions (src/codex/mod.rs) and the open_file/select_text tool descriptions (src/agent_tools.rs) say these tools move the user's view, so they are only for explicit requests, and that read_file is for reading code. The instructions also say once that builds and tests can't run in pair mode, so the agent names the command to run in one sentence instead of hedging. Non-follow mode still switches buffers for open_file, because a user who asks to open something expects to see it.
  • Agent diagnostics (src/editor/agent_lsp.rs):
    • Already reported: red now keeps the protocol version of publishDiagnostics. With a push-only server, a refresh returns immediately, with refresh_status: "already_reported", only when the report names the document version that server holds for the current text; otherwise it waits as before. A report naming an older version is labelled stale.
    • Timeouts: a refresh that times out now returns the last known diagnostics, labelled by freshness, with ok: false, status: "timeout" and a note that this is not a clean result.
  • Docs: docs/PLUGIN_API.md (the queued kind, responsive and compact panes, the view event), docs/AGENT_WORKFLOW.md and docs/GETTING_STARTED.md (the new quit commands).

How to Test

  1. Narrow terminal. Open Red at 80×24 in a Rust project, press Space A and ask "In two sentences, what does this file do?".
    • Expected: the pane is about 36 columns and the editor about 43, with source lines readable.
    • Resize to 60 columns. Expected: the pane fills the screen while focused.
    • Press Esc until you are back in the editor (Insert → Normal → transcript → editor). Expected: the editor uses all 60 columns.
    • Ask a longer question, then Esc back to the editor while it runs. Expected: Agent finished · Space A to view appears when the turn ends, and Space A brings the pane back in Insert mode.
  2. User width. At 180 columns, drag the pane divider to make the pane wider, then shrink the terminal to 100. Expected: the pane keeps your width as long as the editor keeps 40 columns.
  3. Space A. With the pane open, press Esc in the composer (Normal mode), go to the editor with Ctrl-w h, then press Space A. Expected: the footer shows INSERT.
  4. Queue and stop. Ask for a 600-word essay, then send "reply only QUEUED" while it streams. Expected: the second message shows as a dimmed You · queued card.
    • Press Ctrl-c. Expected: "Stopped at your request." and 1 held · :AgentSendQueued to send.
  5. Quit commands. Edit a buffer without saving and run :qa. Expected: Red refuses and lists the unsaved buffer. :qa! quits; :xa writes and quits.
  6. Tables. In an 80-column terminal, ask the agent for a three-column markdown table of functions, files and purposes. Expected: no word is split across lines; if the grid can't fit, it renders as key/value records.

I ran flows 1, 3, 4 and 5 against a real Codex app-server in tmux on this build, and the same tour on the previous build for comparison. All the before/after rows above come from those captures.

Targeted tests:

  • cargo test --lib conversation_panes_size_responsively_and_go_compact_when_cramped
  • cargo test --lib a_cramped_conversation_pane_covers_the_editor_only_while_focused
  • cargo test --lib escape_from_a_compact_transcript_returns_to_the_editor
  • cargo test --lib refocusing_a_composer_lands_in_insert_mode_but_region_toggles_keep_its_mode
  • cargo test --lib quit_all_and_exit_commands_follow_vim
  • cargo test --lib narrow_table_columns_wrap_between_words
  • cargo test --lib welcome_tips_wrap_between_words_and_drop_what_does_not_fit
  • cargo test --lib bundled_agent_announces_turns_that_finish_while_a_compact_pane_is_covered
  • cargo test --lib bundled_agent_names_a_requested_stop_and_gives_each_turn_one_working_verb
  • cargo test --test lsp_lazy agent_lsp_push_only

The conversation pane kept ~64 columns at any size, leaving the editor 12
columns at 80 wide and 5 at 60. Conversation panes now take at most 45%
of the terminal at their declared width (never under 32), a user-chosen
width still leaves the editor 40 columns, and a terminal too narrow for
both turns the pane into a compact overlay that covers the editor only
while focused. Plugins learn when a compact pane is out of view, so the
Agent pane still announces finished turns.

Polish found in a real-Codex walkthrough:
- Space A focuses the composer in Insert mode, like the first open.
- :qa, :qa!, :quitall, :x, :exit, :wqa and :xa work.
- Table columns keep whole words; grids that cannot fit fall back to
  key/value records instead of splitting words mid-way.
- Queued follow-ups render as dimmed "You · queued" cards.
- Each turn gets one working verb, stops read "Stopped at your
  request.", and notices and the empty states are friendlier.
- The prompt dialog shows first-time tips.
- Agent instructions keep open_file/select_text for explicit requests
  and say once that builds and tests cannot run in pair mode.
- Push-only diagnostics refreshes answer at once when the text was
  already reported, and a timeout returns the last known reports.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T02:42:50.394283Z d6f5242 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9526594683

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugin/panel.rs Resolved
Comment thread src/plugin/panel.rs Resolved
Comment thread src/plugin/panel.rs Resolved
Comment thread src/editor/agent_lsp.rs Resolved
Comment thread src/editor.rs Resolved
- Record the queued block kind and the panel view event in the pending
  0.21.0 API manifest and docs.
- Never dock a conversation pane below 32 columns, and clamp resizes to it.
- Allocate conversation pane widths jointly, so a second pane that does not
  fit becomes compact instead of overlapping the editor; reservation,
  placement, and text layout share one allocation.
- Only skip a push-only diagnostics wait when the report names the
  document version the server holds for the current text.
- Defer :wqa and :xa (and any quit) until every pending format-on-save
  finishes, and cancel it with a message when one fails.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15167fc981

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/agent.hk Resolved
Comment thread src/editor/agent_lsp.rs Resolved
Comment thread src/editor.rs Resolved
…zoomed compact panes in view

- Only the first message sent while a thread starts looks sent; later ones
  render as queued cards.
- Diagnostics whose protocol version is older than the server's current
  document version are labelled stale.
- An explicitly zoomed compact pane counts as visible, so the plugin is not
  told it was hidden.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f6dec292b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor.rs Resolved
Comment thread src/editor/agent_lsp.rs Resolved
Comment thread src/plugin/panel.rs Resolved
…ver, skip queued cards in turn actions

- A diagnostics report's protocol version is recorded with the report
  itself, after it is accepted, so a rejected late notification can no
  longer relabel an earlier one.
- Each report remembers its server, and freshness compares its version
  with that attachment's own document version.
- With the transcript cursor on a queued card, turn actions refer to the
  sent prompt above it.
The rejected-report test looked its stamp up by a hard-coded Unix URI,
which Windows normalizes differently.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6229977b4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor/agent_lsp.rs Resolved
Comment thread src/plugin/panel.rs Resolved
…queued cards in every format

- A push-only refresh only trusts a report from the same server instance;
  a restarted server reuses the key and version numbers.
- Queued cards are dimmed for markdown and code blocks too.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e20393843

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/agent.hk Resolved
Clear rebuilt the unsent messages as sent cards; it now shares the
queued classification with the normal render.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 250a76049c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor.rs Resolved
The bang was ignored, so both refused to overwrite files changed on
disk. A new ForceSaveAll writes every modified buffer with the forced
save, as Vim's :wqall! does; a failed write still keeps Red open.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95b20f3f51

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor.rs Resolved
Like :wq, ':x file' now saves a modified buffer to that file (forced with
'!') before quitting, instead of ignoring the name.
@fcoury

fcoury commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d6f5242f0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcoury
fcoury merged commit 138995c into main Oct 18, 2026
19 checks passed
@fcoury
fcoury deleted the feat/agent-pane-polish branch October 18, 2026 03: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.

1 participant