- saasStore.ts: replace require('./chat/conversationStore') with await import()
to fix ReferenceError in Vite ESM environment (P1)
- main.rs: fix health check pool usage formula from max_connections - num_idle
to pool.size() - num_idle, preventing false "degraded" status (P1)
- error.rs: show detailed error messages in ZCLAW_SAAS_DEV=true mode
- Update bug tracker with BUG-003 through BUG-007
PostgreSQL SUM() on bigint returns NUMERIC, causing sqlx decode errors
when Rust expects i64/Option<i64>. Root cause: key_pool.rs
select_best_key() token_count SUM was missing ::bigint, causing
DATABASE_ERROR on every relay request.
Fixed in 4 files:
- relay/key_pool.rs: SUM(token_count) — root cause of relay failure
- relay/service.rs: SUM(remaining_rpm) in sort_candidates_by_quota
- account/handlers.rs: SUM(input/output_tokens) in dashboard stats
- workers/aggregate_usage.rs: SUM(input/output_tokens) in aggregation
Addresses findings from deep code audit:
H-1: Pass abortController.signal to saasClient.chatCompletion() so
user-cancelled streams actually abort the HTTP connection (was only
stopping the read loop, leaving server-side SSE connection open).
H-2: ModelSelector now shows only when (!isTauriRuntime() || isLoggedIn).
Prevents decorative model list in Tauri local kernel mode where model
selection has no effect (violates CLAUDE.md §5.2).
M-1: Normalize CRLF to LF before SSE event boundary parsing (\n\n).
Prevents buffer overflow when behind nginx/CDN with CRLF line endings.
M-2: SQL window_minute comparison uses to_char(NOW()-interval, format)
instead of (NOW()-interval)::TEXT, matching the stored format exactly.
M-3: sort_candidates_by_quota uses same sliding 60s window as select_best_key.
LOW: Fix misleading invalidate_cache doc comment.
P1: onError callback now sets content to error message instead of empty string.
Previously API errors (404/429) produced empty assistant messages with only
a visual error badge — now the error text is persisted in message content.
P3: Retry button now re-sends the preceding user message via sendToGateway
instead of copying to input. Works for both virtualized and non-virtualized
message lists. Removed unused setInput prop from MessageBubble.
Also hides model selector in Tauri runtime (SaaS token pool routes models).
Root cause: conversationStore hardcoded 'glm-4-flash' as default model,
which may not exist in SaaS admin config, causing 404 on all chat requests.
- conversationStore: default currentModel to empty string (runtime-resolved)
- saasStore: after fetching available models, auto-switch currentModel
to first available if the stored model is not in the list
- SaaS relay getModel() already had fallback to first available model
Model selector was cosmetic-only in desktop mode: chatStream never passes
model param to backend. Hiding prevents user confusion and 404 errors when
selecting models not in SaaS token pool.
Also adds E2E test report covering 168 messages, 4 bugs found (P0 fixed).
Adapt ChatArea for compact/butler mode:
- Add onOpenDetail prop for expanding to full view
- Remove inline export dialog (moved to detail view)
- Replace SquarePen with ClipboardList icon
Add SimpleSidebar component for butler simple mode:
- Two tabs: 对话 / 行业资讯
- Quick suggestion buttons
- Minimal navigation
RightPanel refactoring for dual-mode support:
- Detect simple vs professional mode
- Conditional rendering based on butler mode state
- Add comprehensive pre-release test report (code-level audit)
- Update TRUTH.md: SaaS endpoints 130→140, middleware 12→13
- Update CLAUDE.md stabilization table with correct numbers
- Mark all blocking bugs as resolved in test report
- Add ?mode=rwc to pain.db SQLite URL so it creates the file on first run
- Move useUIModeStore hook before conditional returns in App.tsx to fix
React "Rendered more hooks than during the previous render" error
- Call init_pain_storage() in Tauri .setup() so pain persistence activates on boot
- Integrate useColdStart hook into FirstConversationPrompt for auto-greeting
- Add UI mode toggle section to Settings/General (already had imports)
- Add "简洁" mode switch-back button to TopBar in professional layout
- Update SemanticSkillRouter @reserved annotation to reflect active status
New ButlerRouterMiddleware (priority 80) intercepts user messages,
classifies intent using keyword-based domain detection, and injects
routing context into the system prompt. Supports healthcare, data
report, policy compliance, and meeting coordination domains.
- New: butler_router.rs — keyword classifier + MiddlewareContext injection
- Registered in Kernel::create_middleware_chain() at priority 80
- 9 tests passing (classification + middleware integration)
PainAggregator and SolutionGenerator were in-memory only, losing all
data on restart. Add PainStorage module with SQLite backend (4 tables),
dual-write strategy (hot cache + durable), and startup cache warming.
- New: pain_storage.rs — SQLite CRUD for pain_points, pain_evidence,
proposals, proposal_steps with schema initialization
- Modified: pain_aggregator.rs — global PAIN_STORAGE singleton,
init_pain_storage() for startup, dual-write in merge_or_create/update
- Modified: solution_generator.rs — same dual-write pattern via
global PAIN_STORAGE
- 20 tests passing (10 storage + 10 aggregator)
The TopBar had a gradient badge with 'Z' letter followed by the title
'ZCLAW', creating visual 'ZZCLAW'. Replaced badge with a solid gradient
square as a brand indicator without the duplicate letter.
The framer-motion AnimatePresence with mode="wait" caused the sidebar
content to get stuck on the conversations list when switching to the
agents tab. The React state updated correctly but the DOM did not
re-render. Replaced with simple conditional rendering which is more
reliable and removes the framer-motion dependency from this component.
All core and extended test scenarios passed for the high school math
teacher persona using DeepSeek-V3 and Kimi models. Key findings:
- Math problem solving, quiz generation, memory flywheel all working
- Model switching (deepseek→kimi) verified mid-conversation
- Safety boundary correctly rejects sensitive requests
- 1 P2 bug: sidebar AnimatePresence tab switching fails
P1: identity.rs get_identity() returns empty soul/instructions for agents
without explicit identity files. This prevents the default ZCLAW personality
from overriding agent_config.system_prompt. New get_identity_or_default()
method added for the DEFAULT agent.
P2: messaging.rs now uses agent_config.model.model when available, falling
back to global Kernel config. This allows per-agent model selection.
P2: agentStore.ts loadClones retries up to 3 times (300ms interval) when
getClient() returns null, handling the coordinator initialization race.
P2: agent_create Tauri command auto-populates identity files (soul +
instructions) from creation parameters, ensuring build_system_prompt()
has content for new agents.
Also fixes conversationStore upsertActiveConversation to persist generated
conversation IDs, preventing duplicate entries on new conversations.
Tool execution (ShellExec, WebFetch, etc.) had no timeout, causing the
entire streaming response to hang indefinitely when a tool fails or stalls.
Now wraps execute_tool calls in tokio::time::timeout(30s) with a graceful
error message on timeout.
- nextStep() was allowing currentStep to reach steps.length (6), past
the last step index (5), showing "步骤 7/6:" with empty content area
- On the last step, nextStep now triggers handleSubmit() directly
instead of navigating to a phantom step 6
- Footer button condition changed: "完成" shows on last step instead
of after it, keeping error/success messages visible
- Added error logging in catch block (was silently swallowing errors)
Root cause: Each LLM delta (text/thinking) triggered a synchronous
setState via updateMessages → chatStore.setState. With Kimi thinking
model emitting many deltas per frame, this caused a React render storm
that hit the maximum update depth limit.
Fix (two-layer approach):
1. streamStore: Buffer text/thinking deltas locally and flush to store
via setTimeout(0), batching multiple deltas per frame
2. chatStore: Microtask batching in injectChatStore.updateMessages to
coalesce rapid successive updates
Verified: 2-round conversation (4 messages) with Kimi thinking model
completes without crash. Previously crashed 100% on 2nd message.
h-full = 100% of parent height, but TopBar already occupies 56px above.
This caused ChatArea to overflow by 56px, pushing the input box below
the visible viewport. flex-1 + min-h-0 correctly fills remaining space
in the flex column layout.
The input area at the bottom of the chat panel lacked flex-shrink-0,
causing the flex column layout to compress it when message content filled
the Conversation area. This made the textarea only partially visible and
the scrollbar unable to reach the bottom of the input area.
Root cause: start_consumer() was called in new() before any register() calls,
so the consumer's cloned HashMap was always empty. Workers like log_operation
and record_usage were never found, causing "Unknown worker" errors.
- Add WorkerDispatcher::start() method to be called after all register()s
- Update main.rs to call dispatcher.start() after 7 workers registered
- key_pool.rs: cast cooldown_until to timestamptz for comparison with NOW()
- key_pool.rs: cast request_count to bigint (INT4→INT8) for sqlx decoding
- service.rs: cast cooldown_until to timestamptz in quota sort query
- scheduler.rs: cast last_seen_at to timestamptz in device cleanup
- totp.rs: use DateTime<Utc> instead of rfc3339 string for updated_at
- Add TODO to PainAggregator documenting in-memory-only data limitation
- Remove unused `use serde::Serialize` import from a2a.rs (already clean)
- ProposalsSection: trigger refresh on error instead of silent catch
- useButlerInsights: collect all errors instead of overwriting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- PersonalityConfig with 4 dimensions: tone, proactiveness, formality, humor
- Signal detection from Chinese user messages (e.g. "说简单点" → Simple tone)
- apply_personality_adjustments() returns new immutable config
- build_personality_prompt() injects personality into system prompts
- Integrated into post_conversation_hook for automatic detection
- In-memory persistence via OnceLock (VikingStorage integration TODO)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>