fix(08): add 08-02 dependency to 08-03 — shared use-chat-socket.ts file
This commit is contained in:
@@ -5,6 +5,7 @@ type: execute
|
|||||||
wave: 2
|
wave: 2
|
||||||
depends_on:
|
depends_on:
|
||||||
- "08-01"
|
- "08-01"
|
||||||
|
- "08-02"
|
||||||
files_modified:
|
files_modified:
|
||||||
- packages/portal/app/sw.ts
|
- packages/portal/app/sw.ts
|
||||||
- packages/portal/components/install-prompt.tsx
|
- 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-CONTEXT.md
|
||||||
@.planning/phases/08-mobile-pwa/08-RESEARCH.md
|
@.planning/phases/08-mobile-pwa/08-RESEARCH.md
|
||||||
@.planning/phases/08-mobile-pwa/08-01-SUMMARY.md
|
@.planning/phases/08-mobile-pwa/08-01-SUMMARY.md
|
||||||
|
@.planning/phases/08-mobile-pwa/08-02-SUMMARY.md
|
||||||
|
|
||||||
<interfaces>
|
<interfaces>
|
||||||
<!-- Key types and contracts from prior plans and existing code -->
|
<!-- 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
|
// 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
|
```typescript
|
||||||
export interface UseChatSocketOptions {
|
export interface UseChatSocketOptions {
|
||||||
conversationId: string;
|
conversationId: string;
|
||||||
@@ -111,6 +113,7 @@ export interface UseChatSocketOptions {
|
|||||||
export function useChatSocket(options: UseChatSocketOptions): { send: (text: string) => void; isConnected: boolean }
|
export function useChatSocket(options: UseChatSocketOptions): { send: (text: string) => void; isConnected: boolean }
|
||||||
// WebSocket connects to gateway at WS_URL/ws/chat
|
// WebSocket connects to gateway at WS_URL/ws/chat
|
||||||
// Uses refs for callbacks to avoid reconnection on handler changes
|
// 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:
|
From packages/gateway/main.py:
|
||||||
@@ -230,6 +233,8 @@ From migrations/versions/:
|
|||||||
packages/portal/app/(dashboard)/layout.tsx
|
packages/portal/app/(dashboard)/layout.tsx
|
||||||
</files>
|
</files>
|
||||||
<action>
|
<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:
|
1. Update `app/sw.ts` — add push event handlers:
|
||||||
```typescript
|
```typescript
|
||||||
// After installSerwist(...)
|
// After installSerwist(...)
|
||||||
@@ -297,6 +302,7 @@ From migrations/versions/:
|
|||||||
```
|
```
|
||||||
|
|
||||||
5. Update `lib/use-chat-socket.ts` — integrate offline queue:
|
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
|
- 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
|
- 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
|
- On reconnection (when WebSocket opens): call `drainQueue((convId, text) => ws.send(...))` to send queued messages
|
||||||
|
|||||||
Reference in New Issue
Block a user