Problem
The web UI has grown organically with several code quality issues:
Settings.tsx is 1,104 lines — handles config loading, preset CRUD, tab navigation, auto-save, cron orchestration, and inline tab content
- No form management abstraction — manual
useState + updateField scattered per page
- Duplicated logic across pages — cron reinstall (5x), trigger job (2x), loading spinners (8x), schedule state init (2x)
- Prop drilling — 5+ handler functions drilled from Settings into AiRuntimeTab
- Inconsistent UI patterns —
window.confirm() in Board, alert() in ProviderEnvEditor, raw <textarea> bypassing the design system
- Direct DOM manipulation —
classList.add/remove + setTimeout in Settings for scroll highlighting
- Dead/redundant code —
types.ts re-exports with aliases, unused function parameters, meaningless .bind() call in useApi
- Test suite is shallow — Settings tests don't render components (just check arrays), 10/13 Scheduling tests are skipped, no unit tests for hooks/utilities
Full PRD: docs/prds/web-refactor-plan.md
Phase 1: Extract Shared Hooks & Utilities
Phase 2: Break Up Settings.tsx (1,104 → ~250 lines)
Phase 3: Fix Inconsistencies & Dead Code
Phase 4: Testing Infrastructure & Coverage
Current state: vitest + RTL + Playwright installed, but tests are shallow or skipped.
Execution Order
Phase 1 (hooks) → Phase 2 (Settings breakup) → Phase 3 (cleanup) → Phase 4 (tests)
Phases 1-3 sequential (each builds on previous). Phase 4 can partially overlap with Phase 3.
Success Criteria
- No file in
web/ exceeds 400 lines
- Zero duplicated logic patterns (cron reinstall, trigger job, loading state)
- All hooks have unit tests with
renderHook
- Settings.tsx is an orchestrator only (~200-300 lines)
- No
window.confirm(), alert(), or direct DOM manipulation
- All skipped tests updated or removed
BUILT_IN_PRESET_IDS defined in exactly one place
Problem
The web UI has grown organically with several code quality issues:
Settings.tsxis 1,104 lines — handles config loading, preset CRUD, tab navigation, auto-save, cron orchestration, and inline tab contentuseState+updateFieldscattered per pagewindow.confirm()in Board,alert()in ProviderEnvEditor, raw<textarea>bypassing the design systemclassList.add/remove+setTimeoutin Settings for scroll highlightingtypes.tsre-exports with aliases, unused function parameters, meaningless.bind()call inuseApiFull PRD:
docs/prds/web-refactor-plan.mdPhase 1: Extract Shared Hooks & Utilities
useCronReinstall— consolidate 5 identical cron-reinstall-with-toast blocks (Settings.tsxlines 470-494, 529-549;Scheduling.tsxlines 188-209, 340-364)useTriggerJob— consolidate duplicate job trigger logic inDashboard.tsx:121-133andScheduling.tsx:221-247useConfigForm— generic config→form state +updateField+ dirty tracking (used by Settings & Scheduling)usePresetManagement— encapsulate all preset CRUD, eliminate 5-prop drilling into AiRuntimeTabPhase 2: Break Up Settings.tsx (1,104 → ~250 lines)
SchedulesTab.tsx,IntegrationsTab.tsx,AdvancedTab.tsxBUILT_IN_PRESET_IDS+ preset data toweb/constants/presets.ts(currently copy-pasted in 2 files)getPresetOptionsunused_customPresetsparameterclassList.add/remove+setTimeout) with React state + ref patternsPhase 3: Fix Inconsistencies & Dead Code
window.confirm()(Board.tsx:144) with confirmation modalalert()(ProviderEnvEditor.tsx:56) withaddToast()closeBoardIssue(api.ts:391-401) to useapiFetchinstead of reimplementing error handling<LoadingState>component (eliminate 8 identical spinner blocks)<Textarea>UI component (eliminate raw<textarea>with duplicated Tailwind classes)types.ts— remove dead types (PRD,PullRequest,ActionLog,Notification,Project), remove alias re-exportsIScheduleConfigFormfromScheduleConfig.tsxtotypes.tsuseApimeaningless.bind()call (api.ts:575)IAgentInfoout of function body inScheduling.tsx:463-476,useMemothe agents arrayPhase 4: Testing Infrastructure & Coverage
Current state: vitest + RTL + Playwright installed, but tests are shallow or skipped.
Scheduling.test.tsx(marked "SKIPPED: UX revamp")renderHookunit tests for all new hooks (useCronReinstall,useTriggerJob,useConfigForm,usePresetManagement)cron.tsutilities (497 lines, minimal coverage)data-testidattributes to key UI elements for stable Playwright selectorsvitest runtoyarn verifyExecution Order
Phases 1-3 sequential (each builds on previous). Phase 4 can partially overlap with Phase 3.
Success Criteria
web/exceeds 400 linesrenderHookwindow.confirm(),alert(), or direct DOM manipulationBUILT_IN_PRESET_IDSdefined in exactly one place