rename popup chat to floating chat

This commit is contained in:
2026-03-08 22:53:31 +01:00
parent 0bd46937d3
commit 34f01234c9
8 changed files with 102 additions and 102 deletions

View File

@@ -36,18 +36,18 @@ This keeps the codebase clean and prevents confusion. When removing code, note i
**Changes**:
- `app/schemas.py` — Add to `WsFrameType` enum:
- `home_request`, `popup_request`
- `home_request`, `floating_request`
- `stream_start`, `stream_text`, `stream_block`, `stream_end`
- `popup_domain`
- `floating_domain`
- `data_request`, `data_response`, `mutation`
- Add Pydantic models:
- `WsHomeRequest(type, message, conversation_history?)`
- `WsPopupRequest(type, message, scope: {type, id?})`
- `WsFloatingRequest(type, message, scope: {type, id?})`
- `WsStreamStart(type, request_id)`
- `WsStreamText(type, request_id, chunk)`
- `WsStreamBlock(type, request_id, block_type, data)`
- `WsStreamEnd(type, request_id, mutations?)`
- `WsPopupDomain(type, request_id, domain)`
- `WsFloatingDomain(type, request_id, domain)`
- Keep all existing frame types (backward compat).
**Files touched**: `app/schemas.py`
@@ -130,7 +130,7 @@ git commit -m "step-3: add router refactor with streaming support (orchestrator.
## Step 4 — Output Formatting Layer (NEW: output_formatter.py)
**Goal**: Home and Popup responses diverge at this layer only.
**Goal**: Home and Floating responses diverge at this layer only.
### Block Types (from Electron app components)
@@ -194,14 +194,14 @@ Supported entity types (matching Electron component types):
- `table` -> buffers, validates headers/rows structure, yields `WsStreamBlock`
- `timeline` -> buffers, validates checkpoint objects, yields `WsStreamBlock`
- Invalid blocks are logged and skipped (never crash the stream)
- `PopupFormatter`:
- `FloatingFormatter`:
- Receives `agent_name` from orchestrator
- Maps agent name to domain (deterministic, by code — no LLM):
- `task_agent` -> `"tasks"`
- `checkpoint_agent` -> `"checkpoints"`
- `note_agent` -> `"notes"`
- `project_agent` -> `"projects"`
- Yields `WsPopupDomain` immediately
- Yields `WsFloatingDomain` immediately
- Then yields `WsStreamText` for all tokens (text-only, no blocks)
**Files touched**: `app/core/output_formatter.py` (new)
@@ -223,13 +223,13 @@ git commit -m "step-4: add output formatting layer (output_formatter.py)"
## Step 5 — Unified WS Handler (device_ws.py, chat.py, main.py)
**Goal**: Single multiplexed WebSocket handles device frames + Home/Popup chat.
**Goal**: Single multiplexed WebSocket handles device frames + Home/Floating chat.
**Changes**:
- `app/api/routes/device_ws.py`:
- Extend `_message_loop` dispatch to handle `home_request` and `popup_request`:
- Extend `_message_loop` dispatch to handle `home_request` and `floating_request`:
- On `home_request`: set `ws_context` executor, call `orchestrate_v3_stream`, pipe through `HomeFormatter`, send frames back on same socket.
- On `popup_request`: same, but pipe through `PopupFormatter`.
- On `floating_request`: same, but pipe through `FloatingFormatter`.
- Wrap both in try/finally to clear `ws_context`.
- Each request gets a `request_id` (UUID) for frame correlation.
- Concurrent requests from same client are supported (each runs as an async task).
@@ -246,7 +246,7 @@ git commit -m "step-4: add output formatting layer (output_formatter.py)"
1. Connects to `/api/v1/ws/device`
2. Sends `device_hello`
3. Sends `home_request` -> receives `stream_start`, `stream_text`*, `stream_end`
4. Sends `popup_request` -> receives `popup_domain`, `stream_text`*, `stream_end`
4. Sends `floating_request` -> receives `floating_domain`, `stream_text`*, `stream_end`
5. Verifies `tool_call`/`tool_result` round-trip still works during chat
```
pytest tests/test_ws_unified.py
@@ -313,7 +313,7 @@ git commit -m "step-6: add memory models and migration (models.py, alembic)"
3. Embed interaction, encrypt and upsert in `MemoryAssociative`
- `update_core(user_id, key, value)` — explicit preference update
- All read/write operations encrypt/decrypt using the user's Fernet key from `User.encryption_key`
- `app/api/routes/device_ws.py` — Update `home_request` and `popup_request` handlers:
- `app/api/routes/device_ws.py` — Update `home_request` and `floating_request` handlers:
- Before orchestrator: `enriched = await memory.enrich_context(user_id, message)`
- After response complete: `await memory.store_episode(user_id, ...)`