Skip to content

Agent Mode: Match Chat Mode input auto-sizing and add new-chat expand/collapse #631

Description

@marksftw

Summary

Bring Agent Mode's prompt input sizing behavior into parity with Chat Mode:

  1. Automatically grow and shrink the Agent composer as its content changes on both the new-chat screen and existing chat detail screens.
  2. Add Chat Mode's large Expand/Collapse behavior to the Agent Mode new-chat screen only.
  3. Persist the Agent expansion preference independently from Chat Mode.

Chat Mode is the behavioral reference. This should be implemented as an Agent-focused change; avoid modifying Chat Mode unless it is genuinely unavoidable.

Current behavior

Agent Mode uses the same AgentComposer on both surfaces:

  • the empty/new-chat state
  • the fixed composer beneath an existing agent timeline

The composer already reuses ChatComposerSurface and CHAT_COMPOSER_TEXTAREA_CLASS, including the normal minimum and maximum height styles. However, its textarea remains at its initial height as text wraps or new lines are added.

The relevant difference is behavioral:

  • Chat Mode holds a textarea ref and recalculates its inline height from scrollHeight whenever the input changes.
  • AgentComposer renders a one-row textarea but has no equivalent auto-sizing behavior.
  • A CSS max-height constrains growth but does not cause a textarea to grow by itself.

Chat Mode also has a large composer toggle on its new-chat screen. Agent Mode has no equivalent.

Desired behavior

Automatic sizing on both Agent Mode screens

The Agent textarea should behave like the normal Chat Mode textarea:

  • Start at the existing compact height.
  • Grow as entered or pasted text wraps onto additional lines.
  • Shrink again when lines are removed or the input is cleared.
  • Stop growing at the same normal maximum height used by Chat Mode.
    • Normal layouts: 200px.
    • landscape-short: preserve the effective 100px cap from the shared styling.
  • Once capped, keep the composer stable and allow the textarea itself to scroll vertically.
  • Avoid page or timeline layout overflow while resizing.

This behavior must apply to:

  • Agent Mode's new-chat/empty-session composer.
  • The composer on an existing agent chat detail screen, including a previously loaded session.

Large Expand/Collapse mode on Agent new chat

Add the same large composer affordance used by Chat Mode to the Agent Mode new-chat screen.

When expanded:

  • Use the same overall sizing behavior as Chat Mode (approximately 70vh, capped at 800px).
  • Let the textarea fill the available vertical space.
  • Keep the Agent-specific control row—model, permission mode, project selector, and send button—anchored at the bottom of the composer.
  • Use the corresponding Expand/Shrink icon treatment, transition, placement, and accessible toggle labeling from Chat Mode.
  • Hide the new-chat heading and privacy message while expanded, matching Chat Mode.
  • Apply the same wider expanded layout treatment as Chat Mode.

When collapsed, return to normal auto-sizing behavior.

The manual Expand/Collapse control should appear only on the new-chat/empty-session screen. It should not appear on existing chat detail screens.

Persistence and session transitions

Follow Chat Mode's persistence behavior, but keep the two modes independent:

  • Store the Agent preference separately from chatFullscreen; agentFullscreen is the suggested key.
  • Reloading or returning to a new Agent chat should restore the last Agent expansion preference.
  • Chat Mode's expansion preference must not change Agent Mode, and vice versa.
  • Sending the first prompt from an expanded new-chat screen should transition to the normal compact detail composer.
  • The saved expanded preference should remain intact, so the next new/empty Agent session opens expanded.

Technical direction

Prefer the smallest Agent-only implementation:

  • Add the auto-sizing ref/effect once inside AgentComposer, since that component already serves both new-chat and detail surfaces.
  • Add Agent-specific expanded state and persistence at the level that survives the new-chat-to-detail transition.
  • Pass explicit expansion/toggle props only where the new-chat composer needs them.
  • Continue reusing the existing shared ChatComposerSurface and textarea styling.
  • Adjust EmptyAgentState layout as needed so the expanded composer can match Chat Mode's height, width, and hidden heading/privacy behavior.

Do not turn this into a universal Chat/Agent composer rewrite. The action rows, locking rules, attachments, and send behavior differ substantially between the modes. A small shared primitive is acceptable if it is clearly low-risk, but extracting or rewriting Chat Mode is not required and should be avoided if the Agent implementation can remain self-contained.

Preserve existing behavior

This change must not alter:

  • Desktop Enter-to-send and Shift+Enter-for-newline behavior.
  • Existing compact-layout/mobile keyboard behavior.
  • Agent model, permission mode, and project selection behavior.
  • Send, cancel, initialization, loading, and disabled states.
  • Timeline scrolling or session switching behavior.
  • Chat Mode's current appearance, auto-sizing, expansion behavior, or persisted preference.

Acceptance criteria

  • A one-line Agent prompt retains the current compact composer height.
  • Typing or pasting multiline content grows the new-chat Agent textarea line by line.
  • Typing or pasting multiline content grows the existing-chat Agent textarea line by line.
  • Deleting content shrinks both Agent composer variants back toward their compact height.
  • Normal growth caps at the same effective heights as Chat Mode and then scrolls internally.
  • Starting, clearing, cancelling, or switching sessions does not leave a stale inline height.
  • Agent new chat has a working Expand/Collapse toggle matching Chat Mode's large composer behavior.
  • Expanded Agent new chat keeps all Agent controls usable and pinned to the bottom.
  • The heading and privacy message are hidden while expanded and restored when collapsed.
  • Existing Agent chat detail screens do not show the manual Expand/Collapse control.
  • Sending from expanded new chat transitions to the compact detail composer.
  • The Agent expanded preference survives reloads/new sessions under its own persisted key.
  • Agent and Chat expansion preferences do not affect each other.
  • Keyboard submission and newline behavior remain unchanged.
  • Compact and landscape-short layouts remain usable without viewport overflow.
  • Chat Mode has no visual or behavioral regression.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions