Skip to content

Conversation

@TimelordUK
Copy link
Owner

Summary

  • Implemented Phase 1 of buffer state refactor to eliminate state duplication
  • Fixed ViewportManager sync issues when switching between buffers
  • Added visual tab bar for buffer navigation
  • Added configurable start_mode (command vs results)

Key Changes

Buffer State Refactor

  • Created ViewState struct in Buffer as single source of truth
  • Implemented proxy pattern for state access (NavigationProxy, SelectionProxy)
  • Eliminated duplicate state between ViewportManager, NavigationState, and Buffer

Viewport & Buffer Switching

  • Fixed critical bug where ViewportManager showed wrong buffer's data
  • Added proper save/restore of viewport state when switching buffers
  • Fixed Ctrl-6 quick switch to work in Results mode

UI Improvements

  • Added tab bar showing all open buffers with Alt+1-9 shortcuts
  • Tab bar always visible for consistent layout
  • Simplified status line to avoid redundancy (removed duplicate filenames)
  • Status line shows table name, tab bar shows filenames

Configuration

  • Added start_mode config option to choose initial mode when loading files
  • Options: "command" (focus on SQL) or "results" (focus on data)
  • Default: "results" for immediate data viewing

Testing

  • Added comprehensive tests for buffer state preservation
  • All existing tests pass
  • Manual testing with multiple CSV files confirms proper buffer switching

Next Steps

With this improved architecture, we can now revisit the pin columns feature which was previously problematic due to state duplication issues.

🤖 Generated with Claude Code

TimelordUK and others added 7 commits August 29, 2025 19:05
- Created ViewState struct in Buffer to consolidate all view-related state
- Implemented proxy pattern (NavigationProxy, SelectionProxy) for state access
- Buffer now owns all its view state (crosshair, scroll, selection, viewport locks)
- State automatically preserved when switching buffers
- Fixed Ctrl-6 buffer switching to work in Results mode
- Updated help text to clarify buffer switching works in both modes
- Moved documentation files to docs/ folder for better organization
- Added comprehensive tests for buffer state preservation

This eliminates state duplication between ViewportManager, NavigationState,
SelectionState, and Buffer. Each buffer's view state now travels with it,
fixing synchronization bugs when switching buffers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added TabBarWidget that displays all open buffers as tabs
- Shows Alt+N keyboard shortcuts (1:name, 2:name, etc)
- Highlights the currently selected buffer
- Auto-hides when only one buffer is open (no wasted space)
- Integrates seamlessly with existing layout
- Inspired by neovim/vim tab plugins for familiar UX

The tab bar provides visual feedback for buffer state and makes it
easy to see which buffers are open and quickly switch between them
using Alt+1-9 shortcuts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add ViewportManager sync when switching between buffers
- Ensure viewport properly updates DataView on buffer switch
- Add visual tab bar showing all open buffers (like neovim)
- Fix tab bar to always show for consistent layout (even with 1 buffer)
- Simplify status line to avoid redundancy (remove duplicate filenames)
- Fix Ctrl-6 quick switch to work in Results mode
- Add tests for buffer state preservation

The ViewportManager now correctly updates when switching buffers,
showing the proper data for each buffer. Tab bar provides visual
feedback for open buffers with Alt+N shortcuts.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
- Add 'start_mode' option to BehaviorConfig (command or results)
- Default to 'results' mode for immediate data viewing
- Apply configured mode when loading CSV/JSON files
- Update config file generation with new option and documentation

Users can now configure whether to start in command mode (focus on
SQL input) or results mode (focus on data). This addresses the common
preference of wanting to immediately see data when loading files.

Config option:
  [behavior]
  start_mode = "results"  # or "command"

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix test_viewport_buffer_sync.rs to use correct DataTable API
- DataTable::new() now requires a name parameter
- Use add_column() and DataRow::new() for proper table construction
- Replace headers() with column_names() method calls
- Add comprehensive pin columns feature analysis document

All tests now pass successfully. Pin columns feature is ~70% ready
with the main remaining work in viewport/rendering layer.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix get_selected_row() to use table_state.selected() for backward compatibility
- This maintains the old API behavior where None means no selection
- Update test_direct_buffer_viewstate_access to properly sync state
- All tests now pass successfully

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@TimelordUK TimelordUK merged commit e2dd7d8 into main Aug 29, 2025
2 checks passed
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