Skip to content

Split DeskWorkspace into hooks and components #152

Description

@cursor

Spec: Fowler-style refactoring review (cloud agent, 2026-08-05). Refactor only — no behavior change.

Blocked by: #148

What to change

components/desk-workspace.tsx is 1,846 lines; the DeskWorkspace body alone is ~1,100 and owns routing, data loading, a keyboard state machine, swipe gestures, filtering, search, day grouping, trash undo, scroll restoration, and the render for both phone and desk surfaces (Large Class / Divergent Change).

Split along the change axes:

  1. useThreadViews — the generation-guarded loader (load, loadGeneration, the changeable-thread refresh logic, ~782–865) plus the artifacts/projects loading.
  2. useDeskKeyboard — the j/k/r/n/x/#/g queue machine with its five refs, stepOffRow, fileFocused, and the keydown effect (~1087–1316).
  3. useSwipeNavigation — the touch handlers and openAdjacentThread (~1108–1342).
  4. useScrollRestore — the phone list-scroll save/restore effects (~1483–1498).
  5. Extract componentsDayCards (~1401–1478) and the stacks list render (~1659–1717).
  6. ThreadRow takes 16 props, several of them flag arguments serving four different call sites — introduce a props object or split the row into desk/phone variants; also extract the twice-written latestMentions(view) mapping (in toFacetThread and the candidates memo).

Out of scope: lib/desk/facets.ts internals; visual or interaction changes; ThreadChat (own ticket).

Acceptance criteria

  • desk-workspace.tsx is a composition shell; each extracted hook/component has one responsibility and lives in its own file
  • Keyboard filing behavior under fast bursts is unchanged (the ref-based queue semantics are preserved)
  • The shared hooks from the blocking ticket are consumed, not re-implemented
  • mise run lint and mise run test pass (desk keyboard, filing, trash/undo, and facet specs unchanged)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions