Files
platform/PHASE_6_CLEANUP.md
T

3.2 KiB

Phase 6: Cleanup & Polish - Execution Plan

Status: In Progress

Date: February 20, 2026


1. Old Harness References Found

Frontend Files (To Review/Update):

  • src/apps/officer-web/Screens/Dashboard/Chat/useClaude.ts
  • src/apps/officer-web/Screens/Dashboard/Chat/useOpenCode.ts
  • src/apps/officer-web/Screens/Dashboard/Chat/usePiMono.ts
  • src/apps/officer-web/Screens/Dashboard/Chat/ChatPanel.tsx
  • src/apps/officer-web/Screens/Dashboard/Chat/EmbeddableChat.tsx
  • src/apps/officer-web/Screens/Dashboard/Chat/Settings.tsx
  • src/apps/officer-web/Screens/Dashboard/Chat/OpenCodeModelPicker.tsx
  • src/apps/officer-web/Screens/Dashboard/Settings/ProfileSettings/TaskDefaults.tsx
  • src/apps/officer-web/Screens/Dashboard/Settings/ServerSettings/AIHarnessesSection.tsx
  • src/apps/officer-web/Screens/Dashboard/Settings/SystemSettings.tsx
  • src/apps/officer-web/Screens/Dashboard/OnboardingAdmin/AIHarnessesCard.tsx

Backend Files (To Review/Update):

  • src/servers/api/scrape/scrape.ts - provider type references
  • src/servers/api/upload/upload.ts - provider type references
  • src/servers/api/server-settings/opencode.ts - can be removed entirely
  • src/servers/api/server-settings/pi-mono.ts - can be removed entirely
  • src/servers/api/server-settings/server-settings.ts - remove routes
  • src/servers/api/sessions/sessions.ts - update to use only Pi sessions

Type Files:

  • src/servers/api/chat-types.ts - Already updated with deprecation notice
  • src/apps/officer-web/state/types/user-settings.ts - check for provider types

2. Logging Infrastructure

Current State:

  • No centralized logging utility
  • Using console.log directly in Pi harness files
  • Task logger exists (src/servers/api/task-logger.ts) but is specific to tasks

Action Items:

  • Create src/servers/api/pi/logger.ts with structured logging
  • Add log levels (DEBUG, INFO, WARN, ERROR)
  • Add timestamps and context
  • Replace all console.log calls in Pi harness

3. Type Cleanup

Action Items:

  • Review chat-types.ts for any unused legacy types
  • Ensure all Pi types are properly exported
  • Check for duplicate type definitions
  • Update provider type unions to only include 'pi'

4. Documentation

Edge Cases to Document:

  • Session resumption with corrupted messages.json
  • Pi process crash during streaming
  • WebSocket disconnect/reconnect behavior
  • Idle timeout edge cases (activity while timing out)
  • Concurrent session handling per user
  • CWD resolution when not provided
  • File attachment handling

Documentation Files:

  • Create src/servers/api/pi/README.md
  • Document wire protocol examples
  • Document session lifecycle
  • Document error handling patterns

5. Final Verification

Tests:

  • All TypeScript compiles without errors
  • No references to old harnesses in active code paths
  • Logging works consistently
  • Documentation is complete and accurate

Implementation Order:

  1. Create logger utility
  2. Replace console.log calls with structured logging
  3. Remove old harness server-settings files
  4. Update sessions.ts to only use Pi
  5. Document edge cases
  6. Create Pi harness README
  7. Final verification and testing