Commit Graph

235 Commits

Author SHA1 Message Date
xintaofei
94ebfaabdc fix(process): apply C.UTF-8 locale across platforms for child processes
Previously LANG/LC_ALL were only set on Windows, so git stderr was
localized on macOS/Linux and substring checks for English messages
(e.g. 'unknown revision or path not in the working tree') silently
failed — empty-repo/missing-branch cases surfaced as red error
banners in the Git log panel instead of rendering as empty lists.
2026-04-19 06:49:24 +08:00
xintaofei
95a0c527c4 fix(git): restore non-repo fallback and refine repo preflight errors
Reintroduce a local not-a-git-repo fallback state in the git log panel so non-repo errors still render the dedicated empty state when workspace state streaming is degraded.

Improve git repository preflight classification by distinguishing missing paths, permission issues, and non-directory targets before checking .git presence.

Add not_a_git_repository to the frontend AppErrorCode union for explicit typed handling.
2026-04-18 23:49:42 +08:00
xintaofei
b17328b0fc perf(workspace-state): tighten watch debounce to 1s and max batch window to 3s 2026-04-18 23:15:05 +08:00
xintaofei
cc79d62b27 fix(git): surface non-git-repo as a typed error and align all panels via workspace state
Consolidate `.git` presence detection into a shared `git_repo` module used by both the workspace state watcher and the command preflight helper, replacing duplicated local definitions.

Introduce `AppErrorCode::NotAGitRepository` (HTTP 422) and preflight eleven frontend-callable git commands (log, status, list-branches, diff, diff-with-branch, show-diff, show-file, push-info, list-remotes, list-all-branches, commit-branches) so non-git folders short-circuit with a structured error instead of leaking locale-dependent git stderr.

Frontend `isNotAGitRepoError` checks the error code first and falls back to a multi-language regex list centralized in `src/i18n/git-error-patterns.ts`, covering the nine languages git actually translates into.

Wire the git log panel to `workspaceState.isGitRepo` rather than a local cached flag, so running `git init` or deleting `.git` externally propagates through the watcher and refreshes the panel automatically.
2026-04-18 23:07:13 +08:00
xintaofei
cf9573c0ce fix(web-auth): url-decode token query param for websocket auth 2026-04-18 20:18:58 +08:00
xintaofei
ff9fbad50a fix(chat-channel): use session agent in responding indicator and localize command messages
- Replace hardcoded "Claude Code" in agent_responding with each session's actual AgentType label; store agent_type on ActiveSession and populate it in both task-start and resume paths
- Remove silent ClaudeCode fallback in resolve_agent_type; /task now prompts the user to pick an agent when none is selected and the folder has no default
- Move session command strings out of session_commands.rs into i18n.rs with full 10-language coverage (en/zh-CN/zh-TW/ja/ko/es/de/fr/pt/ar)
- Fix French accent and wrap Latin agent name with Arabic bidi isolates (FSI/PDI) for consistent rendering across Telegram/Lark/WeiXin clients
- Release the bridge lock before the get_lang DB lookup in the content_delta flush path to avoid cross-session contention
- Log unknown agent_type fallback in conversation_service::parse_agent_type for observability
2026-04-18 20:05:56 +08:00
xintaofei
ff48810603 fix(workspace-state): keep git-presence flag and branch poll in sync with runtime state
Reconcile the cached is_git_repo flag against the filesystem on every watch flush so `git init` or deletion of .git is reflected immediately: sync the stored flag, drop stale git_snapshot data when the repo goes away, emit a meta delta when presence flips without any data change, and mark the event as requires_resync so the frontend re-fetches the snapshot to pick up the new flag.

Replace the title-bar branch polling interval with a self-adjusting setTimeout chain that backs off to 60s when get_git_branch returns null or throws and drops back to 10s once a branch is detected, so branches created externally recover within one slow tick without hammering the backend on non-git folders.
2026-04-18 17:44:45 +08:00
xintaofei
7ef8d84d44 fix(workspace-state): stop resync loop on non-git folders and allow retry for degraded watcher
Gate git refresh on .git presence so file churn in non-git workspaces no longer produces endless resync_hint events, and silently log tree/git refresh errors during watch flushing instead of flagging requires_resync, which turned transient failures into self-reinforcing loops.

Degrade gracefully when the filesystem watcher fails to attach (e.g. permission denied, inotify quota): keep the initial snapshot, surface a degraded flag, and expose a store-level restart that the banner uses to retry attachment after the root cause is fixed.

Propagate is_git_repo through the snapshot so the git log and changes tabs render a dedicated "Not a Git repository" empty state instead of raw git stderr with a useless retry button.

Stop polling get_git_branch from the title bar once it returns null and re-arm on visibility change.

Add translations for the new banner, empty-state, and retry keys across all ten locales.
2026-04-18 17:18:11 +08:00
xintaofei
0e60216345 chore(acp): bump claude-agent-acp to 0.29.2, opencode to 1.4.11, gemini-cli to 0.38.2, openclaw to 2026.4.15 and cline to 2.15.0 2026-04-18 11:08:52 +08:00
xintaofei
fd10494128 feat(web-service): allow custom access token with persisted port and localized start errors
- Persist user-supplied access token and last-used port in app_metadata, falling back to defaults when unset
- Atomically guard concurrent starts via compare_exchange with RAII rollback of the running flag
- Wrap token and port persistence in a single SeaORM transaction to prevent partial writes
- Classify bind errors (port in use, permission denied, address unavailable, invalid address) into stable i18n keys
- Localize start-failure messages across all 10 supported languages
2026-04-18 10:18:34 +08:00
xintaofei
e86682dc66 chore(acp): bump claude-agent-acp to 0.29.1 and opencode to 1.4.8 2026-04-17 22:36:12 +08:00
xintaofei
9abb85b8ee fix(chat-channel): detect Weixin auth failure via errcode during connect verification 2026-04-17 21:09:31 +08:00
xintaofei
3e30ab7d60 fix(parser): harden Agent subagent state machine, file matching, query performance and streaming child grouping
- Codex: decouple active_agent_count decrement from close_agent target
  parsing and reset counter on turn_context to prevent main assistant
  messages from being swallowed when close_agent events are malformed
- Codex: use exact filename match with separator-aware fallback and
  sorted candidates for deterministic subagent session file resolution
- Codex/OpenCode: truncate subagent tool call previews to 500 chars
- OpenCode: batch-load all subagent tool calls in a single SQL query
  instead of per-task N+1 queries to avoid slow detail page loads
- Streaming: restrict positional child grouping fallback to in-progress
  agents only, preventing top-level tool calls from being incorrectly
  folded into completed Agent cards
- Tests: update Claude context window assertions to match 1M default
2026-04-17 09:38:52 +08:00
xintaofei
834340e536 feat(acp): forward meta/locations fields and use parentToolUseId for precise Agent child grouping
Forward the previously-dropped `locations` and `meta` fields from ACP
SDK ToolCall/ToolCallUpdate events through to the frontend. The meta
field carries `claudeCode.parentToolUseId` which enables precise
parent-child matching for concurrent Agent tool calls during streaming.

- Forward locations/meta in Rust AcpEvent types and connection handlers
- Use parentToolUseId for exact agent→child mapping, with position-based
  fallback for agents that don't provide it (Codex, OpenCode)
- Replace `any` types with proper ToolCallMeta / unknown types
- Add runtime guards for meta field parsing (defensive against
  unexpected shapes from different agents)
- Cache inferLiveToolName results per tool_call_id to avoid redundant
  computation across Phase 1 and Phase 2
- Lazy-construct agentStats only when children exist
2026-04-17 08:24:12 +08:00
xintaofei
6763814a92 chore(acp): bump claude-agent-acp to 0.29.0 and gemini-cli to 0.38.1 2026-04-17 01:28:58 +08:00
xintaofei
488b0c2e53 feat(parser): render OpenCode task as Agent cards with nested tool calls
Transform OpenCode "task" tool calls with subagent_type into unified
Agent card display: rewrite as "Agent" tool with subagent_type, prompt,
description, and model; compute duration from time fields; query
sub-agent session parts from SQLite for nested tool call lists; extract
<task_result> content to strip preamble noise from agent output; guard
Streamdown code plugin against unsupported Shiki language identifiers
(e.g. "##", "function") in fenced code blocks from tool output.
2026-04-17 00:06:57 +08:00
xintaofei
68142651b3 feat(parser): render Codex CLI spawn_agent as Agent cards with nested tool calls
Transform Codex spawn_agent/wait_agent/close_agent into unified Agent
card display: rewrite spawn_agent as "Agent" tool with subagent_type,
prompt, and description; correlate final results from wait_agent and
close_agent outputs; parse sub-agent session JSONL files for nested
tool call lists; suppress intermediate status messages during agent
execution; clean exec_command output to show only the command and its
result.
2026-04-16 22:52:09 +08:00
xintaofei
9f82fdf350 feat(ui): add dedicated Agent subagent rendering with nested tool call display
Render Agent/Explore/Plan tool calls in a visually distinct collapsible
container with colored left border, replacing the generic tool card. Parse
subagent JSONL transcripts from {sessionId}/subagents/ to extract and
display the actual tool calls (Bash, Read, Grep, etc.) the subagent
executed, reusing the existing ToolCallPart for consistent appearance.

- Add AgentToolCallPart component with collapsible body, prompt section,
  execution stats, and nested tool call list via render prop injection
- Add AgentExecutionStats and AgentToolCall types (Rust + TypeScript)
- Parse toolUseResult.agentId to locate and read subagent JSONL files
- Validate agentId against path traversal before filesystem access
- Pass agentStats through adapter for both ID-matched and positional
  tool result pairing
- Strip agentStats in nested render to prevent recursive Agent expansion
- Add i18n keys for agent UI labels across all 10 languages
2026-04-16 21:32:25 +08:00
xintaofei
17f4ee88e8 fix(process): use semver-aware sorting for Node.js version selection
Replace lexicographic sort with numeric (major, minor, patch) sort
across all 7 version-directory sort sites in find_node_bin_dir.

Lexicographic sort incorrectly orders v20.9 > v20.11 (because '9' > '1')
which could select an older Node.js version and cause agent preflight
failures for version-gated agents like OpenClaw (requires >=22.12.0).
2026-04-16 12:48:21 +08:00
xintaofei
045411b8d0 fix(process): harden Node.js path discovery for production readiness
- Fix thread safety: replace #[tokio::main] in codeg_server with manual
  runtime construction so set_var runs before any worker threads exist
- Fix nvm alias branch: sort matched candidates (read_dir order is
  undefined) and skip non-numeric aliases like lts/* that cannot be
  resolved without full nvm evaluation
- Fix HOME missing: accept Option<&Path> for home so env-var-only
  discovery (NVM_HOME, VOLTA_HOME, FNM_DIR, etc.) still works in
  Docker / systemd environments without HOME set
- Refactor resolve_dir to accept an env var chain, eliminating all
  inline Option chains for fnm, nvm-windows, mise, and scoop
2026-04-16 11:27:35 +08:00
xintaofei
9adff116ee feat(process): comprehensive cross-platform Node.js path discovery
Expand find_node_bin_dir to support 9 version managers / installation
methods across macOS, Linux, and Windows:

- nvm (Unix): fix alias duplicate candidates, skip symbolic aliases
  like lts/* that cannot be resolved without full nvm evaluation
- nvm-windows: detect via %NVM_SYMLINK% and %NVM_HOME% with correct
  directory layout (node.exe directly in version dir, no bin/)
- fnm: use platform-correct defaults (%APPDATA%/fnm on Windows,
  $XDG_DATA_HOME/fnm on Unix) instead of hardcoded Unix path
- volta: validate that a concrete Node image exists before adding
  the shim directory, preventing cryptic errors when volta is
  installed but no Node version has been set
- asdf (Unix): $ASDF_DATA_DIR or ~/.asdf/installs/nodejs/
- mise/rtx (cross-platform): $MISE_DATA_DIR with XDG fallback
- n (Unix): $N_PREFIX or /usr/local/n/versions/node/
- Homebrew (macOS): /opt/homebrew and /usr/local prefixes
- Scoop (Windows): nodejs-lts and nodejs app detection

Also improve production readiness:
- Document thread-safety requirements for set_var (unsafe in ed. 2024)
- Add warning log when HOME is unset (Docker / minimal containers)
- Clarify FNM_MULTISHELL_PATH scope (server binary only, not GUI)
- Note lexicographic sort limitation for semver edge cases
2026-04-16 11:06:33 +08:00
XinTaoFei
7a6a9d1615 Merge pull request #75 from Kwensiu/fix/windows-acp-node-detection
fix(windows): improve Node and npm detection for ACP agents
2026-04-16 10:44:25 +08:00
Kwensiu
2f59d900fb fix(windows): improve fnm Node path discovery 2026-04-16 00:45:15 +08:00
xintaofei
d163e42457 feat(settings): add ChatGPT OAuth device code login for Codex CLI
Add OAuth device code flow for Codex CLI official subscription auth,
allowing users to log in with their ChatGPT account directly from the
agent settings page without using the terminal.

- Backend: two new endpoints (codex_request_device_code, codex_poll_device_code)
  that handle the OpenAI OAuth device code flow and return tokens to frontend
- Frontend: login UI with verification URL, copyable user code, polling status,
  15-minute timeout, and auto-save via existing persistEnv/persistConfig path
- Auth.json written in Codex CLI compatible format (nested tokens, account_id,
  last_refresh) so codex-acp can use OAuth tokens directly
- Show logged-in status and re-login option when tokens are present
- Remove auth.json textarea from Codex settings UI
- i18n: all 10 languages updated with new login-related keys
2026-04-16 00:29:01 +08:00
xintaofei
e9dd0db6e8 chore(acp): bump bundled agent versions in registry 2026-04-15 19:24:13 +08:00
xintaofei
f9010634ff fix(acp): stop stripping auto config option for Claude Code
Claude Code SDK now supports the "auto" permission mode, so the
filtering that hid it from the selector and silently dropped attempts
to set it is no longer needed.
2026-04-15 16:54:04 +08:00
xintaofei
f3630ba48a feat(folder): add commit reset action in git log
Add a "Reset to Here" context action for git log commit items in the folder page.

Show a reset dialog with branch, target commit, commit message, and reset mode details for soft, mixed, hard, and keep.

Disable reset when viewing a non-current branch filter and keep the action ordering under commit diff.

Add git_reset support across Rust commands, Tauri invoke registration, web handlers/routes, and frontend API/type bindings.

Add localized reset labels, mode descriptions, and toast messages across all supported languages.
2026-04-15 11:14:37 +08:00
xintaofei
b5e8fd8acb feat(folder): unify workspace state streaming for tree and git panels
Introduce a shared workspace-state backend stream with snapshot/delta APIs for file tree and git changes.

Migrate both aux panels to a common frontend workspace store with lifecycle-safe stream handling.

Apply batched watch throttling, path-aware git refresh gating, no-op delta suppression, and bounded history compaction to improve runtime stability.
2026-04-14 22:26:36 +08:00
xintaofei
f9923df1fe feat(acp): surface Claude API retry state in chat input
Enable raw Claude SDK forwarding for ACP sessions and emit only system/api_retry events to the frontend.

Show a localized single-line retry banner with loading under the conversation input, including error details and retry progress.
2026-04-14 14:59:32 +08:00
xintaofei
12981d673e chore(acp): sync Claude and Gemini ACP registry versions 2026-04-14 12:50:32 +08:00
xintaofei
ef8791906b fix(windows,linux): reduce dark mode white flash on window open
Detect system dark mode on Windows (registry AppsUseLightTheme) and
Linux (gsettings for GNOME, kreadconfig for KDE Plasma) to set native
window background color before webview renders, matching the existing
macOS behavior. Make should_use_dark_background() cross-platform and
apply background_color in all platform branches of
apply_platform_window_style.
2026-04-14 10:16:52 +08:00
xintaofei
be045eecdd fix(macos): update TRAFFIC_LIGHT_Y 2026-04-13 23:40:22 +08:00
xintaofei
b76dc63e77 perf(file-watch): increase debounce and batch window to reduce event pressure 2026-04-13 22:21:14 +08:00
xintaofei
273a8cd7ff fix(macos): detect untracked file deletion via Finder as remove event
Finder moves files to Trash (rename) instead of deleting them, which
may be reported as `Modify(Name)` rather than `Remove` by the file
watcher. This caused untracked files to lose their red color without
being removed from the tree. Fix by checking disk existence in the
event batch emitter and promoting the kind to "remove" when a changed
path no longer exists.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:11:18 +08:00
xintaofei
268b33d2ee fix(macos): update TRAFFIC_LIGHT_Y 2026-04-13 21:01:20 +08:00
xintaofei
41b28001af fix(frontend,macos): reduce dark mode white flash on window open
Detect dark/light mode before React hydrates to eliminate the visible
white-to-dark flash when opening windows in dark mode.

Frontend:
- Inline script now reads next-themes localStorage key and applies
  .dark class, colorScheme, and backgroundColor on <html> before first
  paint
- Add CSS-only fallback via prefers-color-scheme media query in an
  inline <style> tag that fires before any JS executes

macOS backend:
- Detect system dark mode via `defaults read -g AppleInterfaceStyle`
  (cached with OnceLock) and set native window background color to
  match dark theme in apply_platform_window_style
- Persist user appearance mode preference (dark/light/system) to DB
  alongside zoom level so new windows use the correct background
- Add update_appearance_mode Tauri command; frontend syncs on mount,
  on settings change, and on cross-window storage events

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:15:13 +08:00
xintaofei
e05ae76453 fix(macos): persist zoom level to DB so traffic lights use correct position on launch
Previously the welcome window (or any startup window) always used the
default CURRENT_ZOOM of 100, ignoring the user's saved zoom preference
stored in frontend localStorage. Now update_traffic_light_position also
writes the zoom value to the app_metadata DB, and setup() reads it back
before creating any window.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 10:10:09 +08:00
xintaofei
17bae372a1 fix(macos): adjust traffic-light Y baseline from 18 to 17 for better vertical alignment
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:38:37 +08:00
xintaofei
a763adaf36 feat: stream real-time progress for agent SDK install/upgrade/uninstall
Replace the spinner-only UX with live log output during agent SDK
operations, matching the existing OpenCode plugin install experience.

Backend: emit structured events (started/log/completed/failed) via
EventEmitter during npm install and binary download. npm commands now
run with piped stdio for line-by-line streaming; binary downloads
report chunked progress every 1 MB.

Frontend: subscribe to `app://agent-install` events through a new
`useAgentInstallStream` hook and render a theme-aware log terminal
below the preflight checks panel.

Also fixes the install log container in both agent settings and the
OpenCode plugins modal: auto-scroll no longer shifts the outer page,
and colours now follow the active light/dark theme.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 21:43:54 +08:00
xintaofei
25def31a23 fix(windows): force UTF-8 encoding for all spawned child processes
- Set UTF-8 environment variables (PYTHONUTF8, PYTHONIOENCODING, LANG,
  LC_ALL) on all child processes via process.rs helpers
- Configure PTY terminals per shell flavor: chcp 65001 for cmd.exe,
  [Console]::OutputEncoding for PowerShell, LANG=C.UTF-8 for Git Bash
- Use /K and -NoExit for interactive shells to avoid nested processes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:47:31 +08:00
xintaofei
843cf8df19 feat(macos): set traffic-light position via Tauri builder API and sync with zoom
Use Tauri's native `traffic_light_position()` builder method to position
macOS window controls instead of runtime objc2 calls. A global AtomicU32
tracks the current zoom level so newly created windows reflect the latest
zoom. The frontend syncs zoom changes to the backend via a new
`update_traffic_light_position` command.

- Add `traffic_light_position()` to `apply_platform_window_style` builder
- Add `CURRENT_ZOOM` atomic and `traffic_light_position()` helper
- Register `update_traffic_light_position` Tauri command
- Add `syncTrafficLightPosition` in appearance-provider to sync on zoom
  change, mount, and cross-tab storage events
- Consolidate `ensure_windows_undecorated` calls into `post_window_setup`
- Remove dead `on_window_resized` no-op and its Resized event listener

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:11:40 +08:00
xintaofei
9ab090a2b2 fix(acp): avoid false-positive comment detection on URLs in opencode.json
The naive // and /* check triggered on URLs like https://... inside
string values. Now we only reject the file as JSONC when serde_json
parsing fails AND comment-like sequences are found.
2026-04-12 12:00:47 +08:00
xintaofei
023e4c5514 fix(acp): pin @latest for all plugins and enable button when only floating versions exist
- install_missing_plugins now pins ALL @latest specs (not just newly installed)
- When nothing is missing but @latest exists, the pin-only path runs
- Modal button switches to 'Pin @latest Versions' when no missing plugins
- Added pinVersions i18n key for 10 languages
2026-04-12 11:56:55 +08:00
xintaofei
4397b0eae7 feat(acp): auto-pin @latest plugin specs to installed versions after install
After a successful plugin install, read the actual installed version from
node_modules and replace @latest in opencode.json with the pinned version.
This prevents opencode from hitting the npm registry on every startup.

Also add a preflight warning when @latest specs are detected, guiding
the user to install via the plugin manager to auto-pin.
2026-04-12 11:47:01 +08:00
xintaofei
6459e5286a fix(acp): use XDG paths for opencode config/cache instead of platform-native dirs 2026-04-12 11:31:45 +08:00
xintaofei
21800f25a1 style(acp): fix clippy warnings in opencode_plugins 2026-04-12 10:59:37 +08:00
xintaofei
996945223c feat(acp): add opencode plugin list/install/uninstall commands and routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 10:21:04 +08:00
xintaofei
8c807b62d3 feat(acp): integrate opencode plugin check into preflight
Add InstallOpencodePlugins variant to FixActionKind and wire
opencode_plugins::check_opencode_plugins into check_binary_environment
so preflight surfaces missing/installed plugin status for OpenCode agents.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 10:15:48 +08:00
xintaofei
0901758937 feat(acp): implement install_missing_plugins and uninstall_plugin
Add concurrency lock (PLUGIN_OP_LOCK), install/uninstall functions with
bun subprocess management, progress event streaming via EventEmitter, and
protected-package guard for @opencode-ai/* internals.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 10:12:34 +08:00
xintaofei
26cf618bd4 feat(acp): add resolve_bun_binary and atomic_rewrite_opencode_json helpers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 10:10:13 +08:00