Commit Graph

179 Commits

Author SHA1 Message Date
972ef9b1f7 docs(09): capture phase context 2026-03-25 22:11:53 -06:00
df6bce7289 docs: add Phase 9 — Testing & QA (E2E, Lighthouse, visual regression, a11y, cross-browser) 2026-03-25 22:09:30 -06:00
13dc55d59c fix: React #418 hydration error — suppressHydrationWarning on html tag
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:59:11 -06:00
c910230994 fix: PWA manifest auth bypass + i18n formatting error
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:45:42 -06:00
a9077e3559 docs(phase-8): complete Mobile + PWA phase execution
Fixed uuid() recursion bug, updated MOB-02 requirement text.
All 8 phases complete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 21:39:04 -06:00
66bc460a7a docs(08-mobile-pwa-04): complete mobile PWA verification plan — Phase 08 and v1.0 milestone complete 2026-03-25 21:33:45 -06:00
e4b6e8e09f docs(08-03): complete push notifications, offline queue, install prompt plan 2026-03-25 21:32:09 -06:00
81a2ce1498 feat(08-03): push subscription client, service worker handlers, install prompt, offline queue
- Service worker push/notificationclick handlers with conversation deep-link
- PushPermission component for opt-in UI in More sheet
- InstallPrompt component (second-visit, Android + iOS)
- IndexedDB message-queue for offline message persistence
- use-chat-socket.ts: drain queue on reconnect, enqueue when offline
2026-03-25 21:30:29 -06:00
7d3a393758 feat(08-03): push notification backend — DB model, migration, API router, VAPID setup
- Add PushSubscription ORM model with unique(user_id, endpoint) constraint
- Add Alembic migration 012 for push_subscriptions table
- Add push router (subscribe, unsubscribe, send) in shared/api/push.py
- Mount push router in gateway/main.py
- Add pywebpush to gateway dependencies for server-side VAPID delivery
- Wire push trigger into WebSocket handler (fires when client disconnects mid-stream)
- Add VAPID keys to .env / .env.example
- Add push/install i18n keys in en/es/pt message files
2026-03-25 21:26:51 -06:00
5c30651754 docs(08-01): complete mobile PWA foundation plan
- Add 08-01-SUMMARY.md: responsive tab bar + PWA infra with K monogram icons
- Update STATE.md: phase 8 plan 1 progress, decisions, metrics
- Update ROADMAP.md: phase 8 in progress (1/4 SUMMARY files)
- Mark requirements MOB-01, MOB-02, MOB-04 complete
- Update portal submodule pointer to acba978 (mobile nav + PWA commits)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 21:20:45 -06:00
21c91ea83f docs(08-02): complete mobile chat plan — SUMMARY, STATE, ROADMAP updated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 21:19:16 -06:00
5b6cd348fa fix(08): add 08-02 dependency to 08-03 — shared use-chat-socket.ts file 2026-03-25 20:38:23 -06:00
d9b022bd4c docs(08-mobile-pwa): create phase plan 2026-03-25 20:34:24 -06:00
467a994d9f docs(08): add research and validation strategy 2026-03-25 20:26:37 -06:00
fafbcf742b docs(08): research mobile + PWA phase 2026-03-25 20:25:29 -06:00
238e7dd888 docs(state): record phase 8 context session 2026-03-25 20:08:35 -06:00
f005f4a3b4 docs(08): capture phase context 2026-03-25 20:08:35 -06:00
210be50321 docs: add Phase 8 — Mobile Layout + PWA 2026-03-25 19:29:24 -06:00
9759019262 feat: consolidate 3 finance templates into 1 Finance & Accounting Manager
SMBs don't need separate Financial Manager, Controller, and Accountant.
Merged into one versatile role that handles invoicing, AP/AR, expenses,
budgets, reporting, and cash flow. Full en/es/pt translations.

Templates: 8 → 6 (Customer Support Rep, Sales Assistant, Marketing
Manager, Office Manager, Project Coordinator, Finance & Accounting Manager)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:10:57 -06:00
fe3c5a7198 feat: add Marketing Manager template with en/es/pt translations
New AI employee template: Marketing & Growth Manager (category: marketing).
Creative and data-driven, handles campaign strategy, content briefs,
metrics analysis, social media calendars, and lead gen coordination.
Escalates brand-sensitive decisions and high-budget approvals.

Full translations for Spanish and Portuguese with native business
terminology.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:03:59 -06:00
17f6d7cb4b fix: streaming timeout + WebSocket close guard
- Streaming httpx client uses 300s read timeout (cloud LLMs can take
  30-60s for first token). Was using 120s general timeout.
- Guard all WebSocket sends with try/except for client disconnect.
  Prevents "Cannot send once close message has been sent" crash.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:39:32 -06:00
6c1086046f fix: add LLM_POOL_URL to gateway env — was using localhost instead of llm-pool
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:35:43 -06:00
dd80e2b822 perf: bypass Celery for web chat — stream LLM directly from WebSocket
Eliminates 5-10s of overhead by calling the LLM pool's streaming
endpoint directly from the WebSocket handler instead of going through
Celery queue → worker → asyncio.run() → Redis pub-sub → WebSocket.

New flow: WebSocket → agent lookup → memory → LLM stream → WebSocket
Old flow: WebSocket → Celery → worker → DB → memory → LLM → Redis → WebSocket

Memory still saved (Redis sliding window + fire-and-forget embedding).
Slack/WhatsApp still use Celery (async webhook pattern).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:32:16 -06:00
2116059157 fix: NullPool for Celery workers + skip pgvector on first message
- Celery workers use NullPool to avoid "Future attached to a different
  loop" errors from stale pooled async connections across asyncio.run()
  calls. FastAPI keeps regular pool (single event loop, safe to reuse).
- Skip pgvector similarity search when no conversation history exists
  (first message) — saves ~3s embedding + query overhead.
- Wrap pgvector retrieval in try/except to prevent DB errors from
  blocking the LLM response.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 18:21:19 -06:00
5e4d9ce144 chore: update portal submodule ref to include streaming changes 2026-03-25 17:57:23 -06:00
61b8762bac feat(streaming): update WebSocket handler to forward streaming chunks to browser
- Pub-sub loop now handles 'chunk' and 'done' message types (not just 'response')
- 'chunk' messages are forwarded immediately via websocket.send_json
- 'done' message breaks the loop and triggers DB persistence of full response
- Sends final 'done' JSON to browser to signal stream completion
- Legacy 'response' type no longer emitted from orchestrator (now unified as 'done')
2026-03-25 17:57:08 -06:00
5fb79beb76 feat(streaming): wire streaming path through orchestrator task pipeline
- _stream_agent_response_to_redis() publishes chunk/done messages to Redis pub-sub
- _process_message() uses streaming path for web channel with no tools registered
- Non-web channels (Slack, WhatsApp) and tool-enabled agents use non-streaming run_agent()
- streaming_delivered flag prevents double-publish when streaming path is active
- _send_response() web branch changed from 'response' to 'done' message type for consistency
2026-03-25 17:57:04 -06:00
9090b54f43 feat(streaming): add run_agent_streaming() to orchestrator runner
- run_agent_streaming() calls POST /complete/stream and yields token strings
- Reads NDJSON lines from the streaming response, yields on 'chunk' events
- On 'error' or connection failure, yields the fallback response string
- Tool calls are not supported in the streaming path
- Existing run_agent() (non-streaming, tool-call loop) is unchanged
2026-03-25 17:57:00 -06:00
f3e358b418 feat(streaming): add complete_stream() generator and POST /complete/stream NDJSON endpoint to llm-pool
- complete_stream() in router.py yields token strings via acompletion(stream=True)
- POST /complete/stream returns NDJSON: chunk lines then a done line
- Streaming path does not support tool calls (plain text only)
- Non-streaming POST /complete endpoint unchanged
2026-03-25 17:56:56 -06:00
b6c8da8cca fix: increase WebSocket pub-sub timeout from 60s to 180s
LLM responses can take >60s (especially with local models). The
WebSocket listener was timing out before the response arrived,
causing agent replies to appear in logs but not in the chat UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:48:22 -06:00
ebe8a9d974 fix: login page crash — LanguageSwitcher split for pre-auth context
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:31:48 -06:00
2925aaac7d docs(phase-7): complete Multilanguage phase execution 2026-03-25 17:12:28 -06:00
b5709d9549 docs(07-04): complete multilanguage verification plan
- Human verification approved for all 6 I18N requirements
- Portal confirmed rendering correctly in EN/ES/PT
- Language switcher, persistence, and AI Employee language response verified
- Phase 7 (multilanguage) marked complete in ROADMAP.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 17:06:58 -06:00
6e9441215b docs(07-03): complete portal i18n string extraction plan 2026-03-25 17:05:08 -06:00
1018269f82 docs(07-02): complete frontend i18n infrastructure plan
- Create 07-02-SUMMARY.md with full execution details
- Update STATE.md with position, decisions, metrics
- Update ROADMAP.md progress (Phase 7: 2/4 plans complete)
- Mark requirements I18N-01, I18N-02 complete in REQUIREMENTS.md
2026-03-25 16:30:37 -06:00
1b69ea802e docs(07-01): complete backend multilanguage foundation plan 2026-03-25 16:29:03 -06:00
9654982433 feat(07-01): localized emails, locale-aware templates API, language preference endpoint
- email.py: send_invite_email() adds language param (en/es/pt), sends localized subject+body
- templates.py: list_templates()/get_template() accept ?locale= param, merge translations on response
- portal.py: PATCH /api/portal/users/me/language endpoint persists language preference
- portal.py: /api/portal/auth/verify response includes user.language field
- portal.py: AuthVerifyResponse adds language field (default 'en')
- test_portal_auth.py: fix _make_user mock to set language='en' (auto-fix Rule 1)
- test_language_preference.py: 4 integration tests for language preference endpoint
- test_templates_i18n.py: 5 integration tests for locale-aware templates (all passing)
2026-03-25 16:27:14 -06:00
7a3a4f0fdd feat(07-01): DB migration 009, ORM updates, and LANGUAGE_INSTRUCTION in system prompts
- Migration 009: adds language col (VARCHAR 10, NOT NULL, default 'en') to portal_users
- Migration 009: adds translations col (JSONB, NOT NULL, default '{}') to agent_templates
- Migration 009: backfills es+pt translations for all 7 seed templates
- PortalUser ORM: language mapped column added
- AgentTemplate ORM: translations mapped column added
- system_prompt_builder.py: LANGUAGE_INSTRUCTION constant + appended before AI_TRANSPARENCY_CLAUSE
- system-prompt-builder.ts: LANGUAGE_INSTRUCTION constant + appended before AI transparency clause
- tests: TestLanguageInstruction class with 3 tests (all pass, 20 total)
2026-03-25 16:22:53 -06:00
5cd9305d27 fix(07): revise plans based on checker feedback 2026-03-25 16:13:40 -06:00
528daeb237 docs(07): create phase 7 multilanguage plan 2026-03-25 16:07:50 -06:00
4ad975d850 docs(07): add research and validation strategy 2026-03-25 16:01:00 -06:00
3d3692f3ab docs(07): research phase multilanguage domain 2026-03-25 16:00:02 -06:00
52dcbe5977 docs(state): record phase 7 context session 2026-03-25 15:52:25 -06:00
9db830e14d docs(07): capture phase context 2026-03-25 15:52:25 -06:00
9ee0b8a405 docs: add Phase 7 — Multilanguage (English, Spanish, Portuguese) 2026-03-25 15:37:57 -06:00
ebfcb8a24c fix: template library and all API calls wait for session before fetching
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:23:47 -06:00
b3635ae34d fix: align all three New Employee cards at same height
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:13:20 -06:00
7ef727f968 fix: Recommended badge no longer clips outside Templates card
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:09:26 -06:00
35131e353b fix: eliminate 422 race condition — RBAC headers sync before queries
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:05:46 -06:00
ee1c2f70f8 fix: set RLS tenant context for chat conversation lookups
Chat API queries on web_conversations need tenant context set before
RLS policies allow the SELECT. Also fixes crypto.randomUUID fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:34:38 -06:00