fix(08): add 08-02 dependency to 08-03 — shared use-chat-socket.ts file

This commit is contained in:
2026-03-25 20:38:23 -06:00
parent d9b022bd4c
commit 5b6cd348fa

View File

@@ -5,6 +5,7 @@ type: execute
wave: 2
depends_on:
- "08-01"
- "08-02"
files_modified:
- packages/portal/app/sw.ts
- packages/portal/components/install-prompt.tsx
@@ -88,6 +89,7 @@ Output: Working push notification pipeline (client subscription -> DB storage ->
@.planning/phases/08-mobile-pwa/08-CONTEXT.md
@.planning/phases/08-mobile-pwa/08-RESEARCH.md
@.planning/phases/08-mobile-pwa/08-01-SUMMARY.md
@.planning/phases/08-mobile-pwa/08-02-SUMMARY.md
<interfaces>
<!-- Key types and contracts from prior plans and existing code -->
@@ -98,7 +100,7 @@ From packages/portal/app/sw.ts (created in Plan 01):
// Push event listener to be added here
```
From packages/portal/lib/use-chat-socket.ts:
From packages/portal/lib/use-chat-socket.ts (modified in Plan 02 for mobile chat):
```typescript
export interface UseChatSocketOptions {
conversationId: string;
@@ -111,6 +113,7 @@ export interface UseChatSocketOptions {
export function useChatSocket(options: UseChatSocketOptions): { send: (text: string) => void; isConnected: boolean }
// WebSocket connects to gateway at WS_URL/ws/chat
// Uses refs for callbacks to avoid reconnection on handler changes
// NOTE: Plan 02 may have modified this file for mobile chat — read current state before editing
```
From packages/gateway/main.py:
@@ -230,6 +233,8 @@ From migrations/versions/:
packages/portal/app/(dashboard)/layout.tsx
</files>
<action>
IMPORTANT: Plan 08-02 modifies use-chat-socket.ts for mobile chat. Read the current file state before making changes — do not overwrite 08-02's modifications.
1. Update `app/sw.ts` — add push event handlers:
```typescript
// After installSerwist(...)
@@ -297,6 +302,7 @@ From migrations/versions/:
```
5. Update `lib/use-chat-socket.ts` — integrate offline queue:
- Read the file first to see 08-02's changes, then add offline queue integration on top
- Import enqueueMessage and drainQueue from message-queue
- In the `send` function: if WebSocket is not connected (isConnected is false), call `enqueueMessage(conversationId, text)` instead of sending via WebSocket
- On reconnection (when WebSocket opens): call `drainQueue((convId, text) => ws.send(...))` to send queued messages