-
Notifications
You must be signed in to change notification settings - Fork 838
Description
Description
When clicking on the Shell tab in a session that already has terminal output, the scroll position starts at the top. Users must manually scroll to the bottom to see the latest output.
Expected behavior: The shell tab should auto-scroll to the bottom (latest output) when switching to it.
Root Cause
The Shell tab in MainContent.tsx uses conditional rendering (activeTab === 'shell' && ...), which destroys and recreates the StandaloneShell component on every tab switch. This causes the terminal to reconnect and replay the buffer, but the scroll position is not at the bottom due to a timing issue between fitAddon.fit() and data arrival.
In contrast, the Chat tab already uses CSS visibility (block/hidden classes) to keep the component mounted.
Suggested Fix
Two changes:
1. src/components/main-content/view/MainContent.tsx
Change the shell tab from conditional rendering to CSS visibility (matching the pattern already used by the Chat tab):
- {activeTab === 'shell' && (
- <div className="h-full w-full overflow-hidden">
- <AnyStandaloneShell project={selectedProject} session={selectedSession} showHeader={false} />
- </div>
- )}
+ <div className={`h-full w-full overflow-hidden ${activeTab === 'shell' ? 'block' : 'hidden'}`}>
+ <AnyStandaloneShell project={selectedProject} session={selectedSession} showHeader={false} />
+ </div>2. src/components/Shell.jsx
Add scrollToBottom() after fitAddon.fit() in the ResizeObserver callback as a safety net:
const resizeObserver = new ResizeObserver(() => {
if (fitAddon.current && terminal.current) {
setTimeout(() => {
fitAddon.current.fit();
+ terminal.current.scrollToBottom();
if (ws.current && ws.current.readyState === WebSocket.OPEN) {Benefits
- Shell WebSocket connection persists across tab switches (no reconnection delay)
- Terminal state and scroll position are preserved
- Consistent with how Chat tab is already rendered
scrollToBottom()ensures correct scroll position when terminal becomes visible after being hidden