Skip to content

refactor(tui): SessionList and PreviewPanel components are god objects with 54 and 34 methods #42

@jongio

Description

@jongio

Problem

SessionList in internal/tui/components/sessionlist.go has 54 methods and PreviewPanel in internal/tui/components/preview.go has 34 methods. Both exceed a reasonable threshold for single-responsibility structs and qualify as god objects.

SessionList (54 methods) mixes concerns

Concern Example Methods
Cursor/scroll MoveUp, MoveDown, MoveTo, ScrollOffset, ScrollBy
Selection Selected, SelectAll, DeselectAll, SelectByID, SelectRange, ToggleSelected
State management SetSessions, SetGroups, SetPivotField, SetSize
Tree mode CollapseAll, ExpandAll, ToggleFolder, CollapseFolder, ExpandFolder
Filters SetHiddenSessions, SetFavoritedSessions, SetAISessions, SetAttentionStatuses, SetWorkStatuses, SetPlanStatuses
Rendering View, renderSessionRow, renderFolderRow, attentionDot, planDot, workStatusDot

PreviewPanel (34 methods) mixes concerns

Concern Example Methods
Detail display SetDetail, Content, HasPlanContent, PlanViewMode
Scrolling ScrollUp, ScrollDown, PageUp, PageDown, ScrollOffset
Plan mode SetPlanContent, ShowPlanView, ExitPlanView, TogglePlanView
Text selection StartSelection, UpdateSelection, FinalizeSelection, SelectedText, HasSelection
Rendering View, renderContent, renderPlanContent, updateTotalLines
Status SetAttentionStatus, SetWorkStatus, SetConversationSort

Suggested approach

Extract cohesive method groups into focused helper types:

  • SessionList: extract a SessionListRenderer (rendering methods) and SelectionManager (selection logic), keep SessionList as the coordinator.
  • PreviewPanel: extract a PreviewRenderer (View, renderContent, renderPlanContent) and TextSelectionHandler (StartSelection, UpdateSelection, FinalizeSelection, SelectedText).

This makes each type easier to test and reason about in isolation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions