Commit Graph

390 Commits

Author SHA1 Message Date
xintaofei
692b700c0d fix(file-tree): invalidate both cached target and ancestor, skip collapsed refetches
When a deep directory was renamed or deleted externally and both the
directory itself and a parent directory were cached, only the self entry
was cleared — leaving the parent's children list holding a ghost reference
to the old child. Walk up to the nearest cached ancestor in addition to
the direct hit so both stale entries are dropped together.

Also gate the follow-up getFileTree refetch on the directory still being
expanded. Collapsed branches only need their cache cleared; they will
re-hydrate naturally on the next expansion, which avoids unnecessary IPC
traffic during FS event bursts.
2026-04-20 23:20:08 +08:00
xintaofei
baf3b6e89f fix(file-tree): keep aux-panel tree in sync with filesystem changes
Deep directories (beyond the workspace snapshot's depth limit) relied on
a lazy-loaded override cache that was never invalidated, so agent-created
files, in-app deletes / renames / rollbacks, and external changes inside
expanded deep folders stayed invisible until the folder was reopened.

Propagate watcher `changed_paths` through the delta envelope and fire a
Meta event whenever FS activity doesn't alter the tree/git snapshots, so
the frontend can surgically invalidate affected cache entries and
re-fetch. Manual refresh (Reload from disk) clears the cache and
re-hydrates still-expanded deep dirs through the same path. Replayed
deltas after reconnect are forwarded to the same listeners.

Also split the combined workspace-state effect into tree / git / status
slices so unrelated state transitions (e.g. the 'resyncing' flip during
a refresh) no longer rebuild the entire node tree and cause a flash.
2026-04-20 22:57:24 +08:00
xintaofei
ce289e64c5 feat(terminal): add word/line cursor shortcuts for shell line-editing
Intercept keyboard events via xterm's custom key handler and emit
readline/zle escape sequences so bindings work regardless of terminfo:

- Alt/Option + Left/Right: word-wise cursor move
- Alt/Option + Backspace: delete previous word
- macOS Cmd + Left/Right: jump to line start/end
- macOS Cmd + Backspace: clear to line start

Uses `e.code` to stay correct on dead-key layouts, skips IME
composition, and excludes AltGr (ctrl+alt) on Windows/Linux.
2026-04-19 09:27:28 +08:00
xintaofei
0fa2a0895f feat(appearance): apply UI zoom level to terminal and Monaco editors
Extend the existing appearance zoom setting so it also scales xterm.js
terminals and Monaco editors (diff viewer, three-pane merge editor, file
workspace editor), which previously rendered at a hard-coded 13px
regardless of zoom.

- Terminals read zoom at init and update term.options.fontSize live on
  zoom change, refitting after a double rAF so xterm's renderer has
  recomputed cell metrics. Font size is rounded to an integer to avoid
  subpixel blur in the canvas renderer.
- Monaco editors derive fontSize from zoomLevel; three-pane merge
  editor memoizes its options object to avoid redundant updateOptions
  calls on unrelated re-renders.
2026-04-19 09:07:51 +08:00
xintaofei
eeeee2141c fix(settings): move content padding inside scroll areas to keep inner borders visible
The settings shell wrapped children in an outer section with p-3/p-4 padding.
With OverlayScrollbars replacing native scroll, the overlay scrollbar sat at
the viewport's right edge and covered the right border of inner cards.

Drop the outer padding (and the now-redundant overflow-auto) from the shell
and apply p-3 md:p-4 inside each settings page instead, so the scrollbar
aligns with the column edge while inner sections stay within the padded area.
2026-04-19 08:45:57 +08:00
xintaofei
b2ca2c2eb1 refactor(git-error): drop locale-specific not-a-repo patterns
Child processes now have LANG/LC_ALL pinned to C.UTF-8 on every
platform, so git stderr is always English when it leaks past the
typed not_a_git_repository preflight. The 8 non-English regex
fallbacks were dead code; keep only the English pattern as a
belt-and-suspenders fallback for un-preflighted commands.
2026-04-19 06:53:20 +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
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
0048126d53 feat(settings): render update release notes as markdown 2026-04-18 18:51:09 +08:00
xintaofei
07ef376438 refactor(message): shrink agent card max height and localize running indicator with spinner 2026-04-18 18:43:04 +08:00
xintaofei
75c2dd4cc5 fix(settings): use randomUUID helper with getRandomValues fallback for non-secure contexts 2026-04-18 18:25:28 +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
6e477661f8 feat(status-bar): compact large token counts with K/M units in usage popover 2026-04-18 11:57: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
32b4c88582 feat(conversation): add copy text context menu action with preserved selection 2026-04-17 23:20:01 +08:00
xintaofei
5bb4c1cb1e feat(chat-channel): annotate Weixin channel badge with iLink reconnect hint tooltip 2026-04-17 21:52:43 +08:00
xintaofei
aedf94c4a0 fix(ui): suppress streaming Agent partial content to avoid duplicate prompt display 2026-04-17 14:40:12 +08:00
xintaofei
7a92f3eef7 fix(acp): clear Claude API retry banner when streaming content resumes 2026-04-17 14:27:39 +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
73a910bb62 fix(ui): clean streaming Agent result output by unwrapping JSON and stripping task_id prefix
Refactor cleanAgentOutput to a sequential non-recursive pipeline: unwrap
JSON containers first, then strip task_id session lines, then extract
<task_result> content. Also apply cleaning to in-progress agent output
during streaming, not just completed results.
2026-04-17 09:12:54 +08:00
xintaofei
4f41a217c4 feat(settings): add xhigh reasoning effort level and update Claude Code model placeholders to claude-opus-4.7 2026-04-17 08:31:38 +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
4189aa04de feat(ui): render streaming Agent tool calls as Agent cards with nested child grouping
Support Agent card rendering during live streaming responses for Claude
Code, Codex CLI, and OpenCode. Previously Agent cards only rendered for
loaded/historical messages parsed from the DB.

- Fix tool name inference: subagent_type in input now returns "agent"
  instead of "task"; add spawn_agent/wait_agent/close_agent aliases
- Group sub-agent tool calls inside parent Agent cards during streaming
  using position-based heuristic (ACP SDK lacks parent_id tracking)
- Clean raw Agent output (JSON content blocks, XML task_result wrappers)
- Emit agent_stats with nested tool calls so AgentToolCallPart renders
  child execution inline, matching the loaded message appearance
2026-04-17 01:28:13 +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
e36ba36222 fix(ui): render Agent prompt as markdown and add max height to expanded card body 2026-04-16 21:57:58 +08:00
xintaofei
4c36da8ece fix(ui): prevent duplicate error display in Agent subagent card 2026-04-16 21:48:55 +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
ffdc0019fc fix(ui): replace Codex icon to remove opaque white background
The upstream Codex.Color icon from @lobehub/icons renders an SVG with a
white background rectangle, which appears as a white square on dark
backgrounds. Replace it with a custom CodexColorIcon that renders only
the logo path with its original gradient fill, and adjust the viewBox to
better fit the content area.
2026-04-16 18:03:51 +08:00
xintaofei
4abc198f44 Merge remote-tracking branch 'origin/main' 2026-04-16 09:40:31 +08:00
xintaofei
04eff14c0d fix(settings): remove ineffective max reasoning effort level for Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 09:39:47 +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
7524613439 fix(ui): sharpen dialog rendering with flex centering and stronger ring
Replace translate-based centering with a grid place-items-center wrapper
to eliminate half-pixel subpixel blur on non-retina displays. Strengthen
the content border by switching from ring-foreground/5 to ring-border
and adding shadow-2xl for a clearer visual boundary.
2026-04-15 20:53:04 +08:00
xintaofei
2cec462594 feat(chat): stream partial tool output during live agent response
Live tool calls that produce output while running (e.g. streaming bash
stdout from Codex) now render their partial output in real time instead
of appearing blank until the tool completes. The tool card keeps its
running visual state — spinner and 24KB tail truncation — while chunks
arrive, and transitions to the completed state once the final status
lands. A WeakMap keyed on the ACP reducer's chunks-array identity
memoizes the joined output so repeated renders don't re-run O(n) string
concatenation.
2026-04-15 19:16:50 +08:00
xintaofei
2da2378ae3 feat(settings): add reasoning effort level for Claude Code
Add an Effort Level dropdown under the Claude Code model inputs with
options Low / Medium / High / Max (Opus only). The selection writes an
"effortLevel" key at the root of the Claude Code config JSON, and is
removed when the default is chosen. Manual edits to the native JSON
textarea stay in sync with the dropdown.
2026-04-15 16:38:39 +08:00
xintaofei
503b149d03 feat(settings): use overlay scrollbars for sub-page scroll areas 2026-04-15 15:54:22 +08:00
xintaofei
b46db2f1a1 feat(settings): add Enable Fast toggle for Codex service tier 2026-04-15 15:29:17 +08:00
xintaofei
a6f80088d0 feat(skills): support folder-scoped skills in agent sessions
- Thread workspace path through useAgentSkills so Codex $-autocomplete
  surfaces folder-local skills in addition to global ones; cache keyed
  by agent + workspace and invalidated per key on focus.
- Add Global/Folder scope tabs and a folder picker (sourced from the
  folder table via loadFolderHistory) to the Skills settings page.
  CRUD for skills now operates against the selected scope and folder.
- Default the settings right panel to a placeholder hint; the new-skill
  form only appears after clicking "New Skill" or selecting an existing
  skill. Search input is hidden in folder scope.
- Disable "New Skill" when folder scope has no folder chosen; show a
  pick-folder hint in the path preview for that state.
- Add scope/noSelectionHint/pickFolderHint strings across 10 locales.
2026-04-15 14:56:53 +08:00
xintaofei
3148966371 fix(folder): prevent branch submenu from being clipped in scroll area 2026-04-15 13:18:10 +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
66549ce2f7 feat(folder): add Add to session actions in changes menus
Add the Add to session context action for tracked and untracked nodes in the Changes panel, including root, directory, and file entries.

Reorder Changes context actions so Add to session is placed below View diff, and Rollback is placed below Add to VCS.

Update attachToCurrentSession translations to the Add to session wording across all supported locales.
2026-04-15 09:54:07 +08:00
xintaofei
98fc75e585 fix(folder): add sidebar blank-space conversation actions 2026-04-14 23:09:28 +08:00
xintaofei
570b142e44 fix(folder): align file workspace tab bar height 2026-04-14 22:44:27 +08:00
xintaofei
0557eab154 refactor(folder): remove workspace debug logging from aux panels 2026-04-14 22:39:57 +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
90e8bb645a fix(folder): prevent stale file watch subscriptions in aux tabs
Ensure async watch setup is safely discarded after effect cleanup.

Use idempotent watcher release logic to avoid duplicate subscriptions and unbalanced stop calls.
2026-04-14 16:43:35 +08:00
xintaofei
9f1540129b fix(folder): keep mobile sidebars closed on initial load
Prevent left and right sidebars from auto-opening on small screens during folder page initialization, regardless of persisted open state.

Gate mobile sidebar sheets behind restored panel state to avoid initial sidebar pop-in.
2026-04-14 15:52:52 +08:00
xintaofei
7808a5f0d0 feat(acp): notify when permission approval is requested
Send a system notification when an agent triggers a permission request while the app window is not visible.
2026-04-14 15:31:12 +08:00
xintaofei
f9c0887346 perf(chat): reduce input rerender overhead in conversation shell
Memoize ChatInput to minimize unnecessary updates in the chat input area during frequent parent renders.

Compute localized Claude API retry banner text lazily and only when retry state is present.
2026-04-14 15:12:14 +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