Skip to content

[Quality audit] Reduce frontend, store, and shared-lib duplication #160

@johannesjo

Description

@johannesjo

Derived from the local audit report CODE_QUALITY_FINDINGS.md created on 2026-05-30.

Scope

This issue groups renderer, store, and shared-library simplification opportunities.

Findings

  • Finding 6: shortcut matching is duplicated and semantically inconsistent.
    • Evidence: src/lib/shortcuts.ts, src/lib/keybindings/match.ts, src/lib/keybindings/resolve.ts.
    • Fix direction: store app shortcuts as KeyBinding-shaped records and share modifier normalization/matching.
  • Finding 20: prompt detection is duplicated between main and renderer.
    • Evidence: electron/mcp/prompt-detect.ts, src/store/taskStatus.ts.
    • Fix direction: move shared prompt detection to an importable pure helper.
  • Finding 21: diff review duplicates ReviewProvider state and flow.
    • Evidence: src/components/ReviewProvider.tsx, src/components/ScrollingDiffView.tsx.
    • Fix direction: route diff selection through a shared provider/hook path.
  • Finding 22: ScrollingDiffView has two hidden-context implementations.
    • Evidence: GapView and TrailingGap duplicate content fetching, context construction, highlighting, rendering, and expansion.
    • Fix direction: extract a shared context-line loader/expander.
  • Finding 23: SettingsDialog theme grids are duplicated.
    • Fix direction: extract ThemeGrid(slot), PresetThemeCard, and CustomThemeCard.
  • Finding 24: SettingsDialog repeats checkbox/card setting rows.
    • Fix direction: extract SettingsCheckboxRow and a small SettingsSection wrapper.
  • Finding 25: Sidebar repeats task row chrome.
    • Fix direction: extract TaskRowShell, DirectBranchBadge, and shared attention/focus style helpers.
  • Finding 26: NewTaskDialog carries reusable option UI inline.
    • Fix direction: extract CheckboxOption, InlineBanner, DockerTaskOptions, and CoordinatorTaskOptions.
  • Finding 27: task/agent record construction is duplicated in store.
    • Fix direction: extract createAgentRecord(...) and base task builders.
  • Finding 28: task deletion and active-neighbor selection are duplicated.
    • Fix direction: extract pure draft cleanup primitives and neighbor-selection helpers while preserving lifecycle differences.
  • Finding 29: base64 terminal decoding is duplicated.
    • Fix direction: move decoder to a shared utility used by desktop and remote terminal views.
  • Finding 31: keybinding override resolution is duplicated.
    • Fix direction: extract resolveOneBinding; keep exports focused on inclusion of unbound rows.
  • Finding 32: light terminal theme palette is copied twice.
    • Fix direction: extract LIGHT_TERMINAL_THEME.
  • Finding 33: custom theme parsing/validation repeats primitives.
    • Fix direction: extract isHexTerminalBackground, collectAllowedVars, and formatVarLines while preserving current validation behavior unless intentionally changed.
  • Finding 34: Electron window wrapper retains no-op compatibility methods.
    • Fix direction: remove no-op methods and call-site awaits/catches if no supported platform behavior remains.

Acceptance checks

  • affected component tests
  • store tests
  • keybinding and custom-theme tests
  • npm run typecheck
  • focused browser/UI smoke checks for touched flows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions