mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
fe65741a32
* 💄 style(todo-progress): use colorFillSecondary so left/right borders are visible against QueueTray The colorBorderSecondary stroke nearly vanished against the dark elevated bg, so the TODO card looked open on the sides when stacked under QueueTray. Match QueueTray's outer border token (colorFillSecondary) for a consistent visible seam; inner dividers keep colorBorderSecondary as a softer secondary level. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(hetero-agent): extract producer pipeline into shared package LOBE-8516 phase 0. Move the JSONL framing + adapter conversion + toStreamEvent chain out of the renderer into a new `@lobechat/heterogeneous-agents/spawn` entry, then have desktop main run it before broadcasting. Renderer now consumes ready-made `AgentStreamEvent`s on `heteroAgentEvent`, dropping ~50 lines of in-renderer adapter wiring. This unifies the wire shape across desktop main, the upcoming `lh hetero exec` CLI, and the server `heteroIngest` handler — every consumer gets the same stamped `AgentStreamEvent` with no per-consumer adapter step. The desktop CC flow is unchanged behavior-wise: same adapter, same persistence ordering, same step-boundary semantics; only the seam between main and renderer moved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ♻️ refactor(hetero-agent): pull codex tracker into shared spawn, drop desktop's gateway-client dep Two cleanups on top of the phase 0 refactor: 1. Move `CodexFileChangeTracker` (+ its test) out of `apps/desktop/src/main/modules/heterogeneousAgent/` into `packages/heterogeneous-agents/src/spawn/`. `AgentStreamPipeline` now auto-instantiates it when `agentType === 'codex'`, so the desktop controller (and the future `lh hetero exec` CLI) stays agent-agnostic — no more "if codex { wire tracker via transformPayload }" branching at the call site. The public `transformPayload` hook is removed since it had no other consumer. 2. Re-export `AgentStreamEvent` / `AgentStreamEventType` from `@lobechat/heterogeneous-agents/spawn` and drop `@lobechat/agent-gateway-client` from `apps/desktop/package.json`. The gateway-client package is a browser-side WebSocket client; producer-side callers (desktop main, sandbox CLI) shouldn't carry it as a direct dep — they only need the type, which now flows through the producer-side entry. Type predicate on Codex payloads tightened to a non-`Required<>` shape so the moved file passes the root tsconfig's `strict: true` (apps/desktop's tsconfig was lax). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🧑💻 chore(local-testing): harden electron-dev.sh process management Lifecycle improvements for the local-testing helper so smoke runs against the desktop dev session are reliable: - `find_project_pids` now also catches user-started `bun run dev` Electron sessions (matches by project electron path, not just `--remote-debugging-port`), the launcher subshell saved to PIDFILE, and any process bound to the CDP port. Vite match tightened to `electron-vite[/.].*\bdev\b` so unrelated Vite invocations aren't swept up. - `do_stop` expands seed PIDs into their descendant trees (DFS via `pgrep -P`), SIGTERMs the whole tree, waits 5s, then SIGKILLs survivors. Belt-and-suspenders sweep for stragglers + anything still bound to the CDP port. Closes the long-standing "Helper processes survive the kill" gotcha. - `do_start` detects existing project Electron/vite before tearing it down so the user sees what's being killed; waits for port + user-data-dir locks to release before relaunching to avoid the "user data directory in use" race. - `wait_for_cdp` uses an explicit deadline + early bail-out if the launcher PID dies, instead of the previous fixed-step loop. `wait_for_renderer` no longer pre-sleeps 10s. `setsid` use is intentional; it puts the launched Electron in its own session so the whole tree shares a PGID we can signal in one shot. Note: `setsid` is GNU coreutils — on macOS without `brew install util-linux` the script will fail at the launch step. Documented as a known limitation; no fallback added. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(hetero-agent): gate session-complete on stdout fully drained Node may emit `proc.on('exit')` BEFORE child stdio fully closes (documented in child_process: "stdio streams might still be open"). Phase 0 of LOBE-8516 moved adapter ownership to main, so renderer no longer flushes its own adapter on session-complete — meaning trailing events synthesized by `pipeline.flush()` (e.g. Codex's `tool_end` for unfinished tool calls) would race against, and lose to, the `heteroAgentSessionComplete` broadcast, leaving renderer-side persistence to finalize on incomplete state. Fix: in `proc.on('exit')`, await `streamFinished(stdout)` (covers `'end'`, `'close'`, and `'error'`) BEFORE awaiting the broadcast queue. The first await ensures the `stdout.on('end')` handler has had a chance to schedule `pipeline.flush()` onto the queue; the second drains it. Only then do we broadcast complete / error. Regression test repros the documented Node race by emitting `exit` before `stdout.end()` and asserts every `heteroAgentEvent` (including the synthesized `tool_end` from `pipeline.flush()`) lands before `heteroAgentSessionComplete`. Bisected: test fails without the gate, passes with it. Also: add `packages/heterogeneous-agents` to `apps/desktop/pnpm-workspace.yaml` to mirror the new workspace dep added in the phase 0 refactor. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 🐛 fix(hetero-agent): drop builtin-tool-claude-code dep, inline the 3 CC wire shapes the adapter needs Phase 0 added `@lobechat/heterogeneous-agents` as a runtime dep of the desktop main process. That transitively pulled in `@lobechat/builtin-tool-claude-code` (declared in the shared package's deps), which the desktop pnpm workspace doesn't list — CI install on the desktop project fails: ERR_PNPM_WORKSPACE_PKG_NOT_FOUND In ../../packages/heterogeneous-agents: "@lobechat/builtin-tool-claude-code@workspace:*" is in the dependencies but no package named "@lobechat/builtin-tool-claude-code" is present in the workspace The dep is also a layer-violation: `heterogeneous-agents` is the producer side (CLI stream → AgentStreamEvent), `builtin-tool-claude-code` is the UI tool definition (renderers / inspectors / agent template). Producer shouldn't depend on UI-tool packages, even if today the import is just types/constants — the dep cascade still drags `shared-tool-ui` etc. into every workspace that wants the adapter. Fix: inline the three things the adapter actually uses (`'TodoWrite'` tool name string, `TodoWriteArgs` interface, `ClaudeCodeTodoItem` interface). They reflect upstream Claude Code's wire schema — if `claude` ever renames `TodoWrite`, the adapter and the downstream renderers must both update regardless of whether they share a constant. Renderer-side packages (`builtin-tools/codex/TodoListRender`, etc.) keep importing the canonical `ClaudeCodeApiName` from `@lobechat/builtin-tool-claude-code`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>