Commit graph

118 commits

Author SHA1 Message Date
Naiyuan Qing
669cbc791b fix(desktop): resolve eslint exhaustive-deps warnings in useLocalChat
Use chatRef to hold stable reference to useChat return value, avoiding
stale closure issues and satisfying react-hooks/exhaustive-deps rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:56:54 +08:00
Naiyuan Qing
9bcb0993b1 Merge remote-tracking branch 'origin/main' into exec-approvals
# Conflicts:
#	apps/desktop/src/hooks/use-local-chat.ts
2026-02-05 17:54:19 +08:00
Naiyuan Qing
bece8f0545 refactor(web): adapt chat page for extracted shared hooks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:51:12 +08:00
Naiyuan Qing
607adeb667 feat(desktop): implement local chat with direct IPC and mode switching
Add LocalChat component using useLocalChat hook that communicates with
the Hub via IPC (no Gateway required). Fix streamId extraction to use
event.message.id matching Hub behavior. Fix history to return raw
AgentMessageItem[] instead of flattened strings. Add exec approval
forwarding over IPC. Use conditional rendering for LocalChat to prevent
event leaking from remote sessions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:50:55 +08:00
Naiyuan Qing
22bd392cb0 refactor(desktop): reuse shared ChatView, DevicePairing, and hooks in chat page
Replace Zustand-based message/connection stores with local state hooks.
useLocalChat now returns UseChatReturn shape with internal agentId discovery,
tool execution events, and error handling. Remote mode uses shared
useGatewayConnection + useChat + DevicePairing from packages.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:43:39 +08:00
LinYushen
6ebd610ffe
Merge pull request #94 from multica-ai/compaction-feedback
feat: add compaction feedback events
2026-02-05 15:41:38 +08:00
yushen
0421efb824 fix(desktop): add compaction event types to LocalChatEvent
Widen the LocalChatEvent.event.type union to include compaction_start
and compaction_end, fixing TS2367 comparison errors in use-local-chat.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:35:51 +08:00
Naiyuan Qing
53c350ea33 refactor(ui,hooks): extract shared ChatView and DevicePairing to packages
- Extract ChatView from web chat-page into packages/ui as a prop-driven
  component (accepts UseChatReturn shape, no transport dependency)
- Move DevicePairing from apps/web to packages/ui with locally defined
  ConnectionIdentity type (no @multica/hooks dependency)
- Create @multica/hooks package with useGatewayConnection and useChat
  (moved from apps/web/hooks)
- Add isLoadingHistory state to useChat with skeleton loading in ChatView
- Add MulticaIcon (pure CSS asterisk via clip-path, adapts to theme)
- Slim web chat-page.tsx from 188 to 65 lines (just wires hooks to UI)

Desktop can now reuse ChatView and DevicePairing directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:28:44 +08:00
yushen
8f9dcbf7e5 fix(agent): address compaction feedback review findings
- Wrap maybeCompact() in try/catch to ensure compaction_end always fires
- Widen multicaListeners type to match subscribeAll() callback signature
- Import CompactionEndEvent from SDK instead of inline type casts
- Add doc comment explaining reason field type difference (agent vs SDK)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 15:27:08 +08:00
Jiang Bohan
6bfe836559 feat(tools): add keyword-based memory_search tool
Implements a simple memory_search tool for searching memory files:
- Searches memory.md and memory/*.md files by keyword
- Returns matching lines with context (2 lines before/after)
- Supports case-sensitive/insensitive search
- Respects maxResults limit

Tool is only available when a profile is active (has profileDir).
System prompt includes memory usage guidance when tool is present.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:57:40 +08:00
yushen
1316d329ee feat(hub): propagate compaction events to all frontend transports
Forward compaction_start/compaction_end events through Hub (Gateway path)
and Desktop IPC (local path) to the Zustand messages store. Adds
CompactionEvent types to the SDK, compacting/lastCompaction state to
useMessagesStore, and event routing in both connection-store and
use-local-chat.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:55:00 +08:00
Naiyuan Qing
be35dd4f7c
Merge pull request #93 from multica-ai/NevilleQingNY/fix-web-pwa-icons
fix(web): replace PWA icons with full-bleed versions to fix iOS white border
2026-02-05 14:49:20 +08:00
Naiyuan Qing
f5c6f05295 fix(web): replace PWA icons with full-bleed versions to fix iOS white border
The original icon PNGs had pre-baked rounded corners and transparent
backgrounds. When iOS applies its own superellipse mask on Add to Home
Screen, the transparent corners were filled with white, creating a
visible white border around the icon.

Changes:
- Regenerate all icon PNGs as full-bleed (no rounded corners, opaque
  background filling entire canvas) from the existing logo SVG
- Add dedicated apple-touch-icon.png at 180x180 (iOS standard size)
- Add favicon.ico for universal browser fallback
- Replace oversized app/icon.png (540x540) with 192x192 full-bleed
- Update layout.tsx to reference apple-touch-icon.png
- Add explicit purpose: "any" to 192x192 manifest entry

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:46:30 +08:00
Naiyuan Qing
7cb9788bed feat(web): add ChatPage with DevicePairing and ChatView
New page architecture: ChatPage composes useGatewayConnection + DevicePairing
(QR scan/paste with connection status) + ChatView (messages, error banner,
input). Decoupled from Zustand stores, fully props-driven.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:43:59 +08:00
Naiyuan Qing
178d71524f feat(web): add useGatewayConnection and useChat hooks
Replace Zustand global stores with hook-local state for the web app.
useGatewayConnection handles client lifecycle, identity persistence,
reconnection, and keyed reset. useChat handles message history, streaming
events, tool execution, Hub error action, and exec approval requests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:43:53 +08:00
Jiang Bohan
1e1fa410c3 refactor(tools): remove KV memory tools in favor of file-based memory
Memory is now managed through profile files (memory.md, memory/*.md) using
standard read/edit tools, following OpenClaw's file-first approach.

Changes:
- Remove memory/ folder with KV-based memory tools
- Remove group:memory from tool groups
- Update system prompt to remove memory tool references
- Update README docs to reflect file-based memory approach

Agents use workspace.md instructions to manage memory via file operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:41:23 +08:00
Naiyuan Qing
22c957ee76 chore(web): enable experimental HTTPS and fix scanner active states
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:44:29 +08:00
Naiyuan Qing
21efbf943a chore(web): update PWA logo assets
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 09:23:41 +08:00
Jiang Bohan
fc6c3e30b3 chore(desktop): remove coming soon label from remote agent button
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 04:01:30 +08:00
Jiang Bohan
71cc8aee40 fix(desktop): add sessions_spawn to tool groups
The sessions_spawn tool was not showing in the desktop tools UI because
TOOL_GROUPS and ALL_KNOWN_TOOLS were missing the subagent group.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 03:41:45 +08:00
Naiyuan Qing
bef2e901cb
Merge pull request #83 from multica-ai/feat/issue-82-render-tool-call-styles
feat: tool call rendering and error handling
2026-02-04 18:54:30 +08:00
Naiyuan Qing
c412e44f10 fix(desktop): update use-local-chat to use ContentBlock[] instead of string
Message.content changed from string to ContentBlock[] — update desktop's
local chat hook to match: extractContentFromAgentEvent returns ContentBlock[],
and history messages are normalized from string to ContentBlock[].

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:50:44 +08:00
Jiang Bohan
e4ce3349f8 docs(desktop): update TODO list in README
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:25:26 +08:00
Jiang Bohan
197b77e043 feat(desktop): add provider selection UI
- Add useProvider hook for provider state management
- Add ApiKeyDialog for configuring API key providers
- Add OAuthDialog for importing OAuth credentials from CLI tools
- Update home page with provider dropdown selector
- Support switching providers mid-conversation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:25:20 +08:00
Jiang Bohan
48245be52d feat(desktop): add provider IPC handlers
- Add provider.ts with handlers for list, current, set, saveApiKey, importOAuth
- Import OAuth credentials from CLI tools (Claude Code, Codex)
- Register provider handlers in IPC index
- Expose provider API in preload.ts with TypeScript types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 18:25:13 +08:00
Jiang Bohan
2cf13511b7 fix(desktop): fix lint errors and relax unused-vars rule
- Remove unused AgentEvent import from hub.ts
- Change @typescript-eslint/no-unused-vars to warn instead of error

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:57:41 +08:00
Jiang Bohan
a098a78942 fix(agent): add getMessages method and fix TypeScript errors
- Add getMessages() to Agent and AsyncAgent for retrieving session history
- Fix type annotations in hub.ts for AgentMessage handling
- Remove duplicate type export in preload.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:51:07 +08:00
Jiang Bohan
fbe55ab11e docs(desktop): add data flow architecture for Local/Remote modes
Document the dual-mode chat architecture showing how IPC and Gateway
paths share the same UI components, Store, and Agent layer.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:46:41 +08:00
Jiang Bohan
26df74738f feat(desktop): add dual-mode chat page (Local/Remote)
Chat page now supports two modes:
- Local: Direct IPC to agent in same Electron process
- Remote: WebSocket via Gateway to external Hub

Both modes reuse the same UI components and useMessagesStore.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:46:37 +08:00
Jiang Bohan
4a986b1d9a feat(desktop): add local chat IPC handlers
Add IPC handlers for direct local agent communication:
- localChat:subscribe - Subscribe to agent events
- localChat:unsubscribe - Unsubscribe from events
- localChat:send - Send message to local agent
- localChat:getHistory - Get message history

This enables chat without Gateway connection.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:46:33 +08:00
Jiang Bohan
4086fa6985 feat(agent): add subscribe method for multiple event consumers
Add AsyncAgent.subscribe() that allows multiple subscribers to receive
the same agent events, enabling local IPC chat to coexist with other
event consumers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:46:28 +08:00
Naiyuan Qing
096b284cef
Merge pull request #80 from multica-ai/feat/web-qr-scanner
feat(ui): add QR code scanner to ConnectPrompt
2026-02-04 15:44:02 +08:00
Naiyuan Qing
39f2683b35 chore(web): gitignore self-signed HTTPS certificates
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:41:17 +08:00
Jiang Bohan
cea3336256 docs(desktop): update TODO list with core improvements
Remove completed items (device authorization, tools testing, token verification).
Add new priorities:
- Memory tool and memory.md unification
- Profile loading optimization (truncation)
- Agent self-iteration capability
- Local IPC direct communication mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:59:52 +08:00
Bohan Jiang
5760b86e80
Merge pull request #79 from multica-ai/feat/agent-style-setting
feat(desktop): add agent communication style setting
2026-02-04 14:48:29 +08:00
Jiang Bohan
5d102c0241 feat(desktop): add style selector to agent settings dialog
- Add IPC handlers for profile:getStyle and profile:setStyle
- Add style dropdown with 6 preset options in agent settings UI
- Display style descriptions to help users choose

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:42:29 +08:00
yushen
db69e0d08d fix(desktop): remove unsupported asChild prop from AlertDialogDescription
Radix UI version in this project doesn't support asChild on
AlertDialogDescription. Use inline spans with block display instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:12:14 +08:00
yushen
240f25b2be fix(desktop): remove unused setupDeviceConfirmation import
The import was redundant since it's already re-exported directly.
Fixes eslint no-unused-vars error in CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:07:46 +08:00
yushen
c3ded8da41 merge: resolve conflicts with origin/main
Merge remote main branch, keeping both device verification (ws-auth-handshake)
and agent settings/profile features from main.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:04:47 +08:00
yushen
c604085065 fix(desktop): address review issues in device verification flow
- Add 60s timeout to pending device confirms to prevent Promise leaks
  when client disconnects before user responds
- Add offDeviceConfirmRequest to preload and clean up IPC listener on
  component unmount to prevent duplicate listener accumulation
- Extract duplicated parseUserAgent into shared lib/parse-user-agent.ts
- Clean up expired tokens in DeviceStore.registerToken to prevent
  memory accumulation from unscanned QR codes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:54:09 +08:00
yushen
fcbe96645c feat(desktop): add verified device list and rich confirm dialog
Add DeviceList component on home page showing verified devices with
parsed User-Agent info (browser, OS) and relative time. Add useDevices
hook with listDevices/revokeDevice IPC. Update DeviceConfirmDialog to
show human-readable device info (e.g. "Chrome on macOS") instead of
raw device ID.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:43:54 +08:00
yushen
ff827f05e4 feat(desktop): add device confirmation dialog and token registration IPC
Add DeviceConfirmDialog component that shows an AlertDialog when a new
device requests connection, letting the user Allow or Reject. Wire up
Electron IPC for token registration and device confirmation flow between
main process and renderer. Register QR code tokens with Hub on generate
and refresh.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:27:41 +08:00
Jiang Bohan
1dc7539018 refactor(desktop): remove Profile ID display from home page
User-facing UI should not show internal profile IDs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
a4f8cbd978 feat(desktop): improve profile IPC and error handling
- Add reloadSystemPrompt call after profile updates
- Add error handling and logging for Hub initialization
- Clean up debug logs from agent IPC handlers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
82f0ccbe85 docs(desktop): clean up README
Remove completed implementation details, keep only TODO items.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
bdc2006e0e feat(desktop): add agent settings dialog
Add UI for editing agent name and user preferences:
- AgentSettingsDialog component with name input and user.md textarea
- Agent Settings section on Home page with Edit button
- Auto-reload agent info when settings are saved

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Jiang Bohan
a157c6546d feat(desktop): add profile IPC handlers
Add IPC handlers for profile management:
- profile:get - Get profile name and user content
- profile:updateName - Update agent display name
- profile:updateUser - Update user.md content

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:26:40 +08:00
Naiyuan Qing
986b08be48 chore(web): replace old icons with company logo
- Add logo.svg as the new brand logo
- Generate logo-192x192.png and logo-512x512.png from SVG for PWA
- Update app-header, manifest, and layout to reference new logo files
- Remove old icon.png, icon-192x192.png, icon-512x512.png

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:20:02 +08:00
Naiyuan Qing
972c887b43 refactor(apps): simplify layout components to pure navigation shells
- desktop layout.tsx: remove connection logic, keep header + tabs + outlet
- web app-header.tsx: remove connection logic, keep logo + theme toggle

Connection lifecycle is now owned by the shared Chat component.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 10:12:57 +08:00
Jiayuan Zhang
eee6cf1341 fix(desktop): refresh qr every 30s 2026-02-03 21:21:54 +08:00