Skip to content

Agent Mode: match chat composer sizing - #632

Merged
AnthonyRonning merged 1 commit into
masterfrom
codex-review-maple-issue-631-maple
Jul 15, 2026
Merged

AnthonyRonning merged 1 commit into
masterfrom
codex-review-maple-issue-631-maple

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • auto-size the existing Agent composer on both new-chat and detail screens
  • add Chat-style expand/collapse only to the Agent new-chat screen
  • persist the Agent expansion preference independently under agentFullscreen
  • keep expanded layout, controls, and height handling contained to AgentMode

Implementation

This intentionally stays Agent-only and in one existing file. It continues to reuse ChatComposerSurface and CHAT_COMPOSER_TEXTAREA_CLASS; it does not refactor or modify UnifiedChat.

Validation

  • bun run typecheck
  • bun test — 105 passed
  • bun run lint — 0 errors (12 existing warnings)
  • bun run build
  • bun run format:check
  • Maple pre-commit hook

Closes #631


Open in Devin Review

Summary by CodeRabbit

  • New Features
    • Added a fullscreen mode for the Agent composer.
    • Fullscreen state is remembered between sessions.
    • Added a control to expand or restore the composer.
    • Adjusted empty-state content and layout for expanded mode.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Agent Mode now supports a persisted fullscreen composer on empty timelines. Expansion state flows through AgentMode, EmptyAgentState, and AgentComposer, changing layout, textarea sizing, messaging, and toggle controls.

Changes

Agent fullscreen composer

Layer / File(s) Summary
Persisted fullscreen state
frontend/src/components/AgentMode.tsx
Agent fullscreen state is initialized from and written to localStorage using the agentFullscreen key.
Empty-state expansion wiring
frontend/src/components/AgentMode.tsx
The empty timeline layout passes expansion state and its toggle handler to EmptyAgentState, which changes sizing and hides selected messaging while expanded.
Composer expansion controls
frontend/src/components/AgentMode.tsx
AgentComposer accepts expansion props, adjusts textarea and surface sizing, and renders Expand or Shrink controls when applicable.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentMode
  participant localStorage
  participant EmptyAgentState
  participant AgentComposer
  AgentMode->>localStorage: Read agentFullscreen
  AgentMode->>EmptyAgentState: Pass expansion state and toggle handler
  EmptyAgentState->>AgentComposer: Pass composer expansion props
  AgentComposer->>AgentMode: Invoke expansion toggle
  AgentMode->>localStorage: Persist updated state
Loading

Possibly related PRs

  • OpenSecretCloud/Maple#607 — Introduced the Agent Mode implementation extended here with persisted fullscreen composer behavior.

Suggested reviewers: marksftw

Poem

I stretched the prompt beneath the moon,
Then shrank it back by afternoon.
A tiny key remembers the way,
Expand, collapse, and work away.
— A rabbit, happily typing 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main Agent composer sizing change.
Linked Issues check ✅ Passed The changes appear to cover Agent auto-sizing, new-chat expand/collapse, and independent fullscreen persistence as requested in #631.
Out of Scope Changes check ✅ Passed The summary shows Agent-only composer and empty-state updates, with no unrelated feature changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex-review-maple-issue-631-maple

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: f817909
Status: ✅  Deploy successful!
Preview URL: https://2674f1bd.maple-ca8.pages.dev
Branch Preview URL: https://codex-review-maple-issue-631.maple-ca8.pages.dev

View logs

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/src/components/AgentMode.tsx (1)

2320-2341: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the shared button primitive and wrap the long class declarations.

Use the existing Button component for this control; Lines 2323 and 2341 also exceed the 100-character limit.

As per coding guidelines, use existing shadcn/ui components from src/components/ui/ instead of creating custom UI components, and enforce a 100-character line limit for TypeScript/React code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/AgentMode.tsx` around lines 2320 - 2341, The
fullscreen toggle in the AgentMode composer should use the shared Button
component instead of a native button, preserving its existing behavior, styling,
accessibility label, and icon content. Also reformat the long className
declarations around the toggle and Textarea so every TypeScript/React line stays
within the 100-character limit.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/AgentMode.tsx`:
- Around line 2299-2310: Update the textarea sizing effect in AgentMode to
recalculate when the textarea’s dimensions change, not only when input or
isExpanded changes. Observe textareaRef.current with a ResizeObserver, rerun the
existing height measurement on resize, and clean up the observer when the effect
dependencies change or the component unmounts.

---

Nitpick comments:
In `@frontend/src/components/AgentMode.tsx`:
- Around line 2320-2341: The fullscreen toggle in the AgentMode composer should
use the shared Button component instead of a native button, preserving its
existing behavior, styling, accessibility label, and icon content. Also reformat
the long className declarations around the toggle and Textarea so every
TypeScript/React line stays within the 100-character limit.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49b99aa2-4b3d-414a-b34b-c64f06f49aee

📥 Commits

Reviewing files that changed from the base of the PR and between 201d520 and f817909.

📒 Files selected for processing (1)
  • frontend/src/components/AgentMode.tsx

Comment on lines +2299 to +2310
useLayoutEffect(() => {
const textarea = textareaRef.current;
if (!textarea) return;

if (isExpanded) {
textarea.style.height = "";
return;
}

textarea.style.height = "auto";
textarea.style.height = `${Math.min(textarea.scrollHeight, 200)}px`;
}, [input, isExpanded]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the component structure first, then inspect the relevant slices.
ast-grep outline frontend/src/components/AgentMode.tsx --view expanded || true

echo
echo "---- around textarea sizing ----"
sed -n '2260,2335p' frontend/src/components/AgentMode.tsx

echo
echo "---- search for sidebar/fullscreen/resize-related state ----"
rg -n "isExpanded|fullscreen|sidebar|resize|width|scrollHeight|useLayoutEffect|textareaRef" frontend/src/components/AgentMode.tsx

Repository: OpenSecretCloud/Maple

Length of output: 8163


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- AgentMode render around AgentComposer usage ----"
sed -n '1750,1825p' frontend/src/components/AgentMode.tsx

echo
echo "---- composer/input state and sidebar layout around parent ----"
sed -n '1400,1515p' frontend/src/components/AgentMode.tsx

echo
echo "---- ChatComposerSurface definition ----"
rg -n "function ChatComposerSurface|const ChatComposerSurface|export function ChatComposerSurface" frontend/src/components -g '*.tsx' -g '*.ts'

Repository: OpenSecretCloud/Maple

Length of output: 7676


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- ChatComposerSurface implementation ----"
sed -n '110,190p' frontend/src/components/chat/ChatTurn.tsx

echo
echo "---- AgentMode root/layout around sidebar state ----"
sed -n '1420,1475p' frontend/src/components/AgentMode.tsx

echo
echo "---- any resize observers or measurements in AgentMode ----"
rg -n "ResizeObserver|resize|measure|scrollHeight|clientWidth|offsetWidth|getBoundingClientRect" frontend/src/components/AgentMode.tsx frontend/src/components/chat/ChatTurn.tsx

Repository: OpenSecretCloud/Maple

Length of output: 4158


Recalculate textarea height on resize.
Width changes from sidebar toggles or window/orientation changes can rewrap the same input, but this effect only reruns on input/isExpanded, so the textarea can keep a stale height until the user types again. Observe the element size and rerun the measurement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/AgentMode.tsx` around lines 2299 - 2310, Update the
textarea sizing effect in AgentMode to recalculate when the textarea’s
dimensions change, not only when input or isExpanded changes. Observe
textareaRef.current with a ResizeObserver, rerun the existing height measurement
on resize, and clean up the observer when the effect dependencies change or the
component unmounts.

@marksftw

Copy link
Copy Markdown
Collaborator

Tested. Works as expected.

@AnthonyRonning
AnthonyRonning merged commit 0c7a757 into master Jul 15, 2026
18 checks passed
@AnthonyRonning
AnthonyRonning deleted the codex-review-maple-issue-631-maple branch July 15, 2026 05:40
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.

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

2 participants