Skip to content

Viewer Coordination: Focus, Scroll, and Cursor Management #301

Closed

Description

@malibio

Problem Statement

With multiple viewers (tabs/panes) active, we need to coordinate:

  • Which viewer receives keyboard shortcuts and focus
  • Independent scroll positions per viewer
  • Cursor position preservation during external updates
  • Visual feedback for active vs inactive viewers

Current State

What Exists:

  • ✅ Multiple ReactiveNodeService instances
  • ✅ SharedNodeStore for data coordination

What's Missing:

  • ❌ Active viewer tracking for keyboard shortcuts
  • ❌ Scroll position management per viewer
  • ❌ Cursor preservation during real-time updates
  • ❌ Visual indicators for active/inactive state

Proposed Solution

Implement viewer coordination system:

  1. Track active viewer ID globally
  2. Route keyboard shortcuts to active viewer only
  3. Store scroll position per viewer instance
  4. Implement semantic cursor anchoring for updates
  5. Add visual indicators for viewer focus state

Key Concerns

Focus Management:

  • Only one viewer should handle keyboard shortcuts at a time
  • Clicking into a viewer should activate it
  • Tab switching should update active viewer

Scroll Position:

  • Each viewer maintains independent scroll state
  • Scroll position preserved when switching tabs
  • Restore scroll on tab reactivation

Cursor Preservation:

  • During external updates, maintain cursor position semantically
  • Use content-based anchoring (not just character offset)
  • Handle insertions/deletions around cursor gracefully

Main Components Affected

Modified Files:

  • /packages/desktop-app/src/lib/services/reactive-node-service.svelte.ts - Add viewer activation
  • /packages/desktop-app/src/lib/components/base-node-viewer.svelte - Track focus state
  • /packages/desktop-app/src/lib/stores/viewer-focus.ts - Global focus tracking (new)

Acceptance Criteria

  • Keyboard shortcuts routed to active viewer only
  • Visual indicator shows which viewer is active
  • Scroll position independent per viewer
  • Cursor position preserved during external updates
  • Clicking into viewer activates it
  • Tab switch updates active viewer automatically

Estimated Effort

6-8 hours

  • Focus management: 2 hours
  • Scroll position tracking: 2 hours
  • Cursor anchoring: 2-3 hours
  • Visual indicators: 1 hour
  • Testing: 1-2 hours

Dependencies

Priority

Medium-High - Important for multi-viewer UX but not blocking basic functionality

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions