Skip to content

feat: scroll-lock, session restore, and visual pane differentiation#29

Merged
baahaus merged 3 commits into
baahaus:mainfrom
k3rnelpan11c:fix-scroll-lock-and-selection
Apr 8, 2026
Merged

feat: scroll-lock, session restore, and visual pane differentiation#29
baahaus merged 3 commits into
baahaus:mainfrom
k3rnelpan11c:fix-scroll-lock-and-selection

Conversation

@k3rnelpan11c

@k3rnelpan11c k3rnelpan11c commented Apr 7, 2026

Copy link
Copy Markdown

Summary

Three major improvements to the Flock terminal experience:

1. Scroll-lock & selection preservation

  • Scrolling up during Claude output stays in position (no snap to bottom)
  • Text selection persists while new output streams in
  • Switching tabs no longer resets scroll position

2. Session restore (complete rewrite)

  • Exact session ID capture per pane via ~/.claude/sessions/<PID>.json at shutdown
  • Correct working directory via proc_pidinfo (works even when Claude is the active process)
  • Resume with exact UUID: claude --resume <session-uuid>
  • Auto-accept trust prompt on session restore
  • Skip permission prompts: --dangerously-skip-permissions on all launches

3. Visual pane differentiation

  • Blue border (1.5px) for Claude panes, default for shell panes
  • Red border (2px) when Claude is actively outputting (>150 bytes/sec)
  • Returns to blue ~1.2s after output stops
  • Keyboard echo suppressed from activity detection (no false positives when typing)

Technical details

Files changed:

  • FlockTerminalView.swift — scroll-lock tracking, keyboard echo timestamp
  • TerminalPane.swift — session ID capture via libproc, CWD detection, trust auto-accept, frame guard
  • PaneManager.swift — session capture at shutdown, CWD fallback chain (OSC 7 → proc_pidinfo → contextDirectory)
  • FlockPane.swift — blue/red border logic, isAgentActive didSet, focus animation guards
  • ClaudeOutputParser.swift — trust prompt detection with text buffering
  • SessionRestore.swift — cleanup of unused method

Depends on: migueldeicaza/SwiftTerm#530 (exposes Terminal.userScrolling flag)

Test plan

  • Scroll up during streaming output → stays in position
  • Select text during streaming → selection persists
  • Switch tabs during streaming → no scroll reset
  • Quit and relaunch with "Restore Last Session" → correct paths and conversations resumed
  • Multiple Claude panes in same directory → each resumes its own conversation
  • Trust prompt auto-accepted on restore
  • Claude panes have blue border, shell panes have default
  • Border turns red during Claude output, blue when idle
  • Typing in prompt does NOT trigger red border

🤖 Generated with Claude Code

Lucas and others added 2 commits April 7, 2026 13:46
Track user scroll state in FlockTerminalView and set
terminal.userScrolling to prevent auto-scroll-to-bottom and selection
clearing while the user is reading history or has text selected.

- Override scrollWheel to detect when user scrolls away from bottom
- Set userScrolling flag before data feed to preserve scroll position
- Protect active selections from being cleared by incoming output
- Release scroll lock when user sends input (typing returns to bottom)

Depends on k3rnelpan11c/SwiftTerm@flock-scroll-lock (PR migueldeicaza/SwiftTerm#530)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ty improvements

Session restore:
- Capture exact Claude session ID per pane via ~/.claude/sessions/<PID>.json
- Get working directory from proc_pidinfo (works even when Claude is active)
- Resume with exact session ID: claude --resume <uuid>
- Auto-accept workspace trust prompt on restore
- Skip permission prompts with --dangerously-skip-permissions

Visual differentiation:
- Blue border (1.5px) for Claude panes, default border for shell panes
- Red border (2px) when Claude is actively outputting
- Returns to blue ~1.2s after output stops
- Keyboard echo suppressed from activity detection (0.3s window)

Scroll/layout fixes:
- Prevent scroll position reset when switching tabs (guard frame assignment)
- Improved scroll-lock and selection preservation from prior commit

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@k3rnelpan11c k3rnelpan11c changed the title feat: scroll-lock and selection preservation during output feat: scroll-lock, session restore, and visual pane differentiation Apr 7, 2026
… and UX fixes

Cost tracking:
- Per-session cost display in pane title bar (cost + tokens)
- Reads session JSONL incrementally for token/cost data
- CostStatsView overlay panel (Cmd+Shift+U) with session + daily stats + rate limits
- Auto-updates when Claude goes idle

Visual improvements:
- Blue border for Claude panes, red when actively outputting
- Keyboard echo suppression (no false red border when typing)
- Dynamic cost label sizing

UX fixes:
- Prevent scroll reset when switching tabs (frame guard)
- Activity idle timeout reduced to 1.2s for faster feedback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@baahaus baahaus merged commit 6d38c43 into baahaus:main Apr 8, 2026
@baahaus

baahaus commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Super sick! Thanks for contributing

@k3rnelpan11c

Copy link
Copy Markdown
Author

No worries at all, glad it landed well! I use Flock heavily as part of my day-to-day dev flow — I'm CTO at my company with ~100K DAU, so Claude Code is pretty central to how I work. Your tools fit right into that.

If you ever want to sync in private — I've made a few more changes since this PR but I'm not sure they're polished enough to open a PR right away. Would be worth reviewing together how useful they actually are at scale and maybe running some proper tests before merging anything. Let me know!

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.

2 participants