Skip to content

fix(terminal): prevent focus stealing during text selection#18

Merged
eyelock merged 1 commit into
mainfrom
fix/terminal-selection-focus
Jan 13, 2026
Merged

fix(terminal): prevent focus stealing during text selection#18
eyelock merged 1 commit into
mainfrom
fix/terminal-selection-focus

Conversation

@eyelock
Copy link
Copy Markdown
Owner

@eyelock eyelock commented Jan 13, 2026

Summary

Fixes a bug where text selection was impossible during active terminal output.

When a long-running process outputs data, the terminal view would constantly steal focus back via updateNSViewfocusTerminal(), making it impossible to select and copy text.

Changes

  • Check if terminal already has focus before calling focusTerminal()
  • Preserves text selection during active output

Test plan

  • Run a long-running command (e.g., ping localhost)
  • Try to select text while output is streaming
  • Selection should now work without being interrupted

🤖 Generated with Claude Code

When a long-running process outputs data, the terminal view would
constantly steal focus back, making it impossible to select and copy
text. This happened because updateNSView was calling focusTerminal()
on every SwiftUI view update triggered by the activity indicator.

Now we check if the terminal already has focus before attempting to
focus it, preserving text selection during active output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@eyelock eyelock merged commit aa2bba1 into main Jan 13, 2026
5 checks passed
@eyelock eyelock deleted the fix/terminal-selection-focus branch January 13, 2026 16:12
eyelock pushed a commit that referenced this pull request Jan 19, 2026
This PR reorganizes and improves the terminal card editor with better
component usage and clearer organization.

## New Components

### LargeTextInput
- Created new reusable component for multi-line text input
- Uses TextEditor (not TextField) for stable, non-jumping layout
- Fixed height prevents layout shifts during typing
- Custom placeholder implementation
- Solves form width issues - now uses full available width
- Consistent styling with PathInputField and SharedToggle

## Terminal Editor Changes

### Agent Tab → Prompts Tab
- Renamed for clearer terminology (agent prompts vs agent tab)
- Improved visual hierarchy with status indicators at top

### Status Indicators (Prompts Tab)
- Applied StatusIndicator component for MCP Server status
- Applied StatusIndicator for Agent Prompts status
- Applied StatusIndicator for Confirm External Modifications
- Fixed logic: "Terminal allows commands" now shows "Enabled/Disabled"
  instead of "Installed" (proper semantic distinction)

### Terminal Tab Reorganization
- Moved Command Generator from Agent/Prompts tab to Terminal tab
- New section: Automation (contains Init Command + Command Generator)
- Reordered sections: Terminal → Security → Automation (logical flow)
- Command Generator now conditional (only shows when agent prompts enabled)

## Component Improvements

### StatusIndicator Spacing
- Increased HStack spacing: 6 → 8
- Increased vertical padding: 4 → 8
- Reduces "squished" appearance, better visual breathing room

## Localization

- Added: common.enabled, common.disabled
- Added: editor.section.prompts
- Updated all 40 language files with translations

## Files Changed

New:
- Sources/TermQ/Views/Components/LargeTextInput.swift

Modified:
- Sources/TermQ/Views/CardEditorView.swift (tab reorganization)
- Sources/TermQ/Views/Components/StatusIndicator.swift (spacing)
- Sources/TermQ/Utilities/Strings.swift
- Sources/TermQ/Resources/*/Localizable.strings (40 files)

## Testing

- All 521 tests pass
- Manual testing verified:
  - LargeTextInput stable (no jumping during typing)
  - Full width usage in forms
  - StatusIndicator spacing improved
  - Command Generator conditional display works
  - Terminal tab section order logical
  - All status messages semantically correct

## Notes

- Global Settings > Tools tab will receive StatusIndicator in PR #7
- This maintains PR #6 focus on Terminal Details editor
- PR #7 will achieve full consistency across both views

Addresses feedback items #17, #18, #20, #21 from parent plan
Part of Settings UI Improvements series (PR #6 of 8)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
eyelock added a commit that referenced this pull request Jan 19, 2026
…74)

This PR reorganizes and improves the terminal card editor with better
component usage and clearer organization.

## New Components

### LargeTextInput
- Created new reusable component for multi-line text input
- Uses TextEditor (not TextField) for stable, non-jumping layout
- Fixed height prevents layout shifts during typing
- Custom placeholder implementation
- Solves form width issues - now uses full available width
- Consistent styling with PathInputField and SharedToggle

## Terminal Editor Changes

### Agent Tab → Prompts Tab
- Renamed for clearer terminology (agent prompts vs agent tab)
- Improved visual hierarchy with status indicators at top

### Status Indicators (Prompts Tab)
- Applied StatusIndicator component for MCP Server status
- Applied StatusIndicator for Agent Prompts status
- Applied StatusIndicator for Confirm External Modifications
- Fixed logic: "Terminal allows commands" now shows "Enabled/Disabled"
  instead of "Installed" (proper semantic distinction)

### Terminal Tab Reorganization
- Moved Command Generator from Agent/Prompts tab to Terminal tab
- New section: Automation (contains Init Command + Command Generator)
- Reordered sections: Terminal → Security → Automation (logical flow)
- Command Generator now conditional (only shows when agent prompts enabled)

## Component Improvements

### StatusIndicator Spacing
- Increased HStack spacing: 6 → 8
- Increased vertical padding: 4 → 8
- Reduces "squished" appearance, better visual breathing room

## Localization

- Added: common.enabled, common.disabled
- Added: editor.section.prompts
- Updated all 40 language files with translations

## Files Changed

New:
- Sources/TermQ/Views/Components/LargeTextInput.swift

Modified:
- Sources/TermQ/Views/CardEditorView.swift (tab reorganization)
- Sources/TermQ/Views/Components/StatusIndicator.swift (spacing)
- Sources/TermQ/Utilities/Strings.swift
- Sources/TermQ/Resources/*/Localizable.strings (40 files)

## Testing

- All 521 tests pass
- Manual testing verified:
  - LargeTextInput stable (no jumping during typing)
  - Full width usage in forms
  - StatusIndicator spacing improved
  - Command Generator conditional display works
  - Terminal tab section order logical
  - All status messages semantically correct

## Notes

- Global Settings > Tools tab will receive StatusIndicator in PR #7
- This maintains PR #6 focus on Terminal Details editor
- PR #7 will achieve full consistency across both views

Addresses feedback items #17, #18, #20, #21 from parent plan
Part of Settings UI Improvements series (PR #6 of 8)

Co-authored-by: David Collie <support@eyelock.net>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
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