Compare commits

...
56 Commits
Author SHA1 Message Date
David Kaya dc69f8bf04 chore: bump version to 0.0.21 2026-04-01 20:57:05 +02:00
David KayaandCopilot 6f7cf60aa9 fix: render pending messages with markdown formatting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 20:12:59 +02:00
David KayaandCopilot 423d45fa1b fix: use active agent for streaming author fallback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:40:46 +02:00
David KayaandCopilot 13bcc44f1a feat: add handoff workflow checkpoint recovery
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:28:05 +02:00
David KayaandCopilot 1ceb3d5669 fix: project copilot tool results into workflows
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:17:47 +02:00
David KayaandCopilot 1dd13588a0 refactor: move handoff guidance into workflow builder
Move handoff routing and ownership rules out of per-agent system
prompts and into the Agent Framework handoff builder guidance.

This keeps AgentInstructionComposer focused on Aryx-owned system
prompt content while letting WithHandoffInstructions supply the
workflow-level handoff semantics.

- remove handoff-mode runtime guidance from AgentInstructionComposer
- expand HandoffWorkflowGuidance with the triage/specialist rules
- update tests to pin the new split of responsibilities

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:05:01 +02:00
David KayaandCopilot 235ddf7e56 refactor: pin workflow host options explicitly
Explicitly configure AIAgentHostOptions for the workflow modes that
host agents directly instead of relying on Agent Framework defaults.

- add a shared host-options factory that preserves Aryx's current
  behavior
- use custom sequential, concurrent, and round-robin group-chat
  builders so all host options are set intentionally
- add workflow-level tests asserting the configured host options

Keep EmitAgentResponseEvents disabled because Aryx still projects
streaming transcript state itself and enabling response events would
require a separate reconciliation change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:04:44 +02:00
David KayaandCopilot d7004ec2a9 fix: make handoff filtering explicit
Explicitly configure handoff workflows to use
HandoffToolCallFilteringBehavior.HandoffOnly instead of relying on
Agent Framework's current default.

This keeps normal tool-call history visible across handoffs while
still stripping handoff plumbing, and adds a regression test to pin
that behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 19:04:23 +02:00
David KayaandCopilot 0aed6240b9 feat: render workflow diagnostics in activity panel
Surface workflow-diagnostic session events (warnings and errors from
Agent Framework workflows) in the turn-event log of the Activity Panel.

- Add workflow-diagnostic case to formatTurnEventEntry with label/detail
  formatting that includes executor ID, subworkflow ID, exception type,
  and diagnostic message when present
- Add AlertTriangle icon for diagnostic events with error/warning color
- Add 5 tests covering executor-failed, workflow-warning, subworkflow-error,
  workflow-error, and missing diagnosticKind fallback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 18:54:21 +02:00
David KayaandCopilot 11b36827f5 feat: surface workflow diagnostics
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 18:50:56 +02:00
David Kaya b434dd86b4 chore: bump version to 0.0.20 2026-03-31 17:10:47 +02:00
David Kaya c2a691774a feat: add light mode screenshots 2026-03-31 17:04:35 +01:00
David KayaandCopilot 78949c5efd feat: render per-turn thinking tiles in chat pane
Replace the single aggregate thinking tile with per-turn thinking groups.
Instead of collecting all thinking messages into one flat array and
rendering a single ThinkingProcess before the last assistant message,
process session.messages in chronological order to produce interleaved
display items that naturally group consecutive thinking messages by turn.

Each turn now shows its own collapsible thinking tile placed inline
before its assistant response, with correct per-turn isActive state
and turnStartedAt from the matching run.

Also fixes a latent index-mismatch bug in getAssistantMessagePhase where
the visible-messages index was compared against the full session.messages
index, potentially hiding the Final badge when thinking messages existed.
Switched to ID-based comparison.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:53:28 +01:00
David KayaandCopilot fb3e80ec47 refactor: move git panel to tabbed bottom panel alongside terminal
Replace the narrow 256px sidebar git section with a shared tabbed
bottom panel that hosts both Terminal and Git as peer tabs. This gives
git operations full horizontal width for file paths, diff previews,
branch lists, and commit history.

- Create BottomPanel with shared resize handle, tab bar, and content
  switching (terminal stays mounted via CSS visibility when inactive)
- Simplify TerminalPanel by extracting resize/close to BottomPanel
- Add InlineGitPill toggle in composer footer next to Terminal pill
- Wire tab switching: clicking active tab closes panel, clicking
  inactive tab switches to it
- Remove GitPanel from ActivityPanel sidebar
- Update ARCHITECTURE.md to describe tabbed bottom panel layout

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:51:51 +01:00
David KayaandCopilot 5a71539705 feat: add git workflow frontend components
- RunChangeSummaryCard: post-run change review card with expandable
  file diffs, origin badges, selective discard with confirmation,
  and commit composer launch button
- CommitComposer: slide-over panel for staging files, editing AI-
  suggested commit messages, conventional commit type selection,
  and commit with optional push
- GitPanel: embedded activity panel section with branch management,
  push/pull/fetch operations, working tree inspection with inline
  diffs, and recent commit history
- Wire RunChangeSummaryCard into RunTimeline after completed runs
- Wire CommitComposer as overlay in App.tsx with state management
- Wire GitPanel into ActivityPanel for non-scratchpad sessions
- Update ARCHITECTURE.md with frontend git integration description

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:43:45 +01:00
David KayaandCopilot 906433f408 feat: add git workflow backend operations
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:43:13 +01:00
David KayaandCopilot 44d0ab07db feat: add git integration enhancements (phase 1)
Real-time git awareness:
- Auto-refresh git context on window focus and after run completion
- Periodic background polling (60s interval, configurable via settings)
- Pre-run working tree snapshot capture for project-backed runs
- Debounced refresh scheduling to coalesce rapid triggers

Backend (main process):
- GitService.captureWorkingTreeSnapshot() with per-file metadata
- Enriched parseWorkingTree() producing ProjectGitWorkingTreeFile entries
- AryxAppService: scheduleProjectGitRefresh(), periodic timer, focus hook
- preRunGitSnapshot persisted on SessionRunRecord with normalization

Frontend (renderer):
- Settings toggle for auto-refresh (General > Git section)
- RunTimeline: git baseline indicator showing branch and change summary
- Enhanced GitContextBadge tooltip with change breakdown details
- ChatPane: enriched git tooltip with staged/modified/untracked counts
- New IPC channel: setGitAutoRefreshEnabled

Tests: 8 new tests covering snapshot capture, refresh scheduling,
scratchpad skip behavior, and auto-refresh setting persistence.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:37:02 +01:00
David KayaandCopilot 49933f218b feat(website): add light mode with theme toggle
- Add [data-theme='light'] CSS variable overrides for warm parchment surface palette
- Add sun/moon theme toggle button in nav (desktop + mobile)
- Inline FOUC-prevention script in <head> reading localStorage/prefers-color-scheme
- Screenshot <img> elements swap between dark/light variants via data attributes
- Dynamic meta theme-color update and proper ARIA labels on toggle
- Adjust grain overlay, dot-grid, and gradient-text for light mode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 16:35:17 +01:00
David Kaya 63acd9e87e Merge branch 'main' of https://github.com/davidkaya/aryx 2026-03-31 14:20:19 +02:00
David KayaandCopilot ebb506a359 feat: show platform-specific Copilot CLI install instructions when CLI is missing
Replace the generic 'Install the copilot CLI' one-liner with a rich,
platform-tabbed installation guide. Auto-detects macOS/Windows/Linux and
shows the recommended install command (Homebrew, WinGet, or install script)
plus alternatives (npm). Includes copy-to-clipboard, auth step, and a
refresh button.

- Extend platform.ts with isWindows, isLinux, detectedPlatform
- Add cliInstallInstructions.ts with per-platform install data
- Add CliInstallGuide component in settings/ with platform tabs
- Integrate into CopilotStatusCard for copilot-cli-missing state
- Enhance WelcomePane with CliMissingCard showing quick-start command

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 12:34:01 +02:00
Dávid KayaandGitHub b25da56f5e chore: Add Contributor Covenant Code of Conduct
This document outlines the standards of behavior for community members, including pledges, acceptable and unacceptable behaviors, enforcement responsibilities, and consequences for violations.
2026-03-31 11:41:20 +02:00
Dávid KayaandGitHub 30ff81009a chore: Change Dependabot update interval from weekly to daily 2026-03-31 11:31:59 +02:00
David Kaya 9a261780c6 chore: bump version to 0.0.19 2026-03-31 11:09:12 +02:00
David KayaandCopilot 9b7e4dd6e9 feat: format and syntax-highlight JSON arguments in approval popup
- Add deepParseJsonStrings utility to recursively unwrap JSON-encoded
  string values inside tool-call args before display
- Apply to McpDetail, CustomToolDetail, and HookDetail renderers
- Add lightweight regex-based JSON syntax highlighting (keys, strings,
  numbers, booleans, punctuation) in CollapsibleCode when content is JSON
- Remove unused Terminal import

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 10:43:28 +02:00
David KayaandCopilot 4bc2c327f7 fix: honor MCP server auto-approvals in hook flow
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 10:11:15 +02:00
David Kaya 36126f1c74 chore: bump version to 0.0.18 2026-03-30 17:20:40 +02:00
David KayaandCopilot bec50da2b4 fix: add DPI awareness to NSIS installer
Add ManifestDPIAware true via a custom NSIS include file so the
installer renders at native resolution on high-DPI displays.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 17:19:58 +02:00
David KayaandCopilot 535adc64be fix: enable background update checks in dev builds
Remove the isPackaged guard from AutoUpdateService.start() so that
background update checks run in both packaged and dev builds.
forceDevUpdateConfig already handles dev-mode config correctly via
dev-app-update.yml — the start() gate was preventing the 10s initial
check and 4h periodic checks from ever being scheduled in dev.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 17:18:02 +02:00
David KayaandCopilot 772c84fed3 feat: add in-app update notification banner to sidebar
Subscribe to auto-update status at the App level and render a compact
UpdateBanner in the sidebar footer when an update is available,
downloading, or downloaded:

- Available/downloading: subtle banner with progress bar, dismissable
- Downloaded: prominent 'Restart to update' action with glow effect

Clicking the banner opens Settings directly on the Troubleshooting
section via a new initialSection prop on SettingsPanel.

New files:
- src/renderer/components/ui/UpdateBanner.tsx

Modified files:
- App.tsx: subscribe to onUpdateStatus, wire props
- Sidebar.tsx: accept and render UpdateBanner
- SettingsPanel.tsx: add initialSection prop + export SettingsSection type
- styles.css: add update-banner-enter slide-up animation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 17:15:38 +02:00
David KayaandCopilot 9647b5fdb5 fix: restructure sidebar project header to prevent name truncation
Restructure the ProjectGroup header from a single cramped line into a
two-row layout so the project name gets adequate space:

- Row 1: chevron + icon + project name (min-w-0 flex-1) + hover actions
- Row 2: git branch badge + running/discovery/session count badges

Additional polish:
- Branch label uses font-mono (JetBrains Mono) for developer feel
- Branch max-width increased from 80px to 140px for better readability
- Project name tooltip shows full name and path on hover
- Scratchpad keeps session count inline on the identity row

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 17:02:47 +02:00
David Kaya 5946dc75ba chore: bump package.json to 0.0.17 2026-03-30 16:33:17 +02:00
David KayaandCopilot 59d3c81f9f fix: classify unstreamed sub-agent messages as thinking
Sub-agent messages bypass the streaming path (turn-delta) entirely due to
SDK batching behavior. They arrive only at turn-complete time via
FinalizeCompletedMessages. Without classification, they appear as separate
chat bubbles cluttering the transcript.

Two-pronged fix:

Sidecar: FinalizeCompletedMessages now tags messages from
_reclassifiedMessageIds with MessageKind='thinking'. This covers messages
that WERE streamed and reclassified during the turn. Added MessageKind
property to ChatMessageDto.

Main process: finalizeTurn detects unstreamed assistant messages (not in
existing session.messages) and classifies them as thinking when a visible
response was already streamed. Emits message-reclassified events so the
renderer can update incrementally, though the primary path is the
workspace:updated broadcast which already includes the correct messageKind.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:24:30 +01:00
David KayaandCopilot deb5c96d58 feat: render thinking process UI for intermediate agent messages
Wire message-reclassified sidecar events through the main process to
the renderer, where reclassified messages are filtered out of the main
transcript and collected into a collapsible ThinkingProcess component.

Main process changes:
- Route message-reclassified via dedicated onMessageReclassified callback
- Add applyMessageReclassified handler that sets messageKind and emits
  the session event for the renderer
- Forward assistant-intent and reasoning-delta as turn-scoped events

Renderer changes:
- Split session.messages into visibleMessages and thinkingMessages
- Render ThinkingProcess above the last assistant message
- ThinkingProcess auto-expands during active turns, collapses on finish
- Update messagePhase to skip thinking-kind messages for final detection

Tests:
- 3 new sessionWorkspace tests for reclassification apply/dedup/ignore
- 2 new messagePhase tests for thinking-kind handling
- Updated runTurnPending test fixtures for new callback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:16:37 +01:00
David KayaandCopilot 56de8b7bd6 feat: add thinking protocol events
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:11:58 +01:00
David KayaandCopilot 38dd358755 docs: document bookmarks panel in README, ARCHITECTURE, and website
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:11:17 +01:00
David KayaandCopilot 770a0f3529 feat: add bookmarks panel for viewing pinned messages across sessions
Add a new BookmarksPanel accessible via Ctrl/Cmd+Shift+B or the
command palette (View Bookmarks). The panel lists all pinned messages
across all sessions globally, with:

- Click-to-navigate: switches session and scrolls to the message
- Inline unpin: remove bookmarks directly from the panel
- Keyboard navigation: arrow keys, Enter, Escape
- Empty state when no messages are pinned

New shared helper listPinnedMessages() in sessionLibrary.ts derives
pinned messages from the workspace state in the renderer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:05:08 +01:00
David KayaandCopilot e37d69bd63 fix: add macOS traffic light inset to sidebar header
Position macOS traffic light buttons (trafficLightPosition) in the
BrowserWindow and add conditional left padding to the sidebar header
so the app logo and title clear the window management controls.

- Create shared platform detection utility (src/renderer/lib/platform.ts)
- Set trafficLightPosition { x: 16, y: 22 } on macOS in createMainWindow
- Apply pl-20 (80px) left padding to the sidebar header on macOS
- Consolidate navigator.platform check from keyboardShortcuts.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:04:45 +01:00
David KayaandCopilot c01a427d8a feat(website): add OG hero preview image for link sharing
Replace the raw logo OG image with a designed 1200×630 hero card
generated at build time using satori + @resvg/resvg-js.

- Add generate-og.ts script with branded dark card design (gradient
  orbs, geometric rings, logo, title, tagline)
- Wire generation into build pipeline (runs before astro build)
- Update meta tags with absolute URLs, dimensions, and twitter:image
- Configure site URL (https://aryx.app) in astro.config.mjs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 16:01:09 +01:00
David KayaandCopilot 01b3949557 docs: add trademark disclaimer to README and website footer
GitHub and GitHub Copilot are trademarks of Microsoft Corporation.
Aryx is an independent project, not affiliated with or endorsed by
Microsoft or GitHub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 10:38:25 +02:00
David Kaya c01110979c fix: link in readme 2026-03-30 10:27:21 +02:00
David Kaya a034b333b3 chore: bump package.json to 0.0.16 2026-03-30 10:26:30 +02:00
David KayaandCopilot 41289c960b fix: enable update checks in dev mode via forceDevUpdateConfig
Add dev-app-update.yml so electron-updater can check GitHub releases
even when running with bun run dev. Remove the isPackaged guard from
checkForUpdates() so manual clicks always contact the update server.
Automatic periodic checks remain disabled in dev mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 10:24:07 +02:00
David KayaandCopilot 33b293271e fix: add up-to-date state so Check for updates gives visible feedback
When electron-updater reports no update available, the service now
transitions to 'up-to-date' instead of reverting silently to 'idle'.
The troubleshooting UI shows a green check icon, 'Up to date' label,
and 'You are running the latest version of Aryx.' description.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 10:20:05 +02:00
David KayaandCopilot cbcf239a0a fix: MCP group toggle styling and server-level approval UX
Two fixes in the auto-approval pill:

1. GroupToggle now uses brand-gradient-bg with glow shadow and matches
   ToggleSwitch sm dimensions, making MCP group toggles visually
   consistent with individual tool toggles.

2. Individual tool toggles now reflect server-level approval state.
   When a server key is approved, all tool rows show as enabled.
   Toggling a single tool OFF in a server-approved group expands the
   server key to individual tool IDs minus the excluded tool, enabling
   the 'approve all → disable one specific tool' workflow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 10:14:13 +02:00
David KayaandCopilot c702cf88e2 fix: approval pill count mismatch with duplicate MCP tool names
When multiple MCP servers expose tools with the same name, the approval
pill showed an incorrect count (e.g. 150/300) even when everything was
approved.  The numerator used a Set<string> to deduplicate by tool ID,
so shared tools were counted once, while the denominator counted each
group occurrence independently.

Extract countApprovedToolsInGroups() into shared/domain/tooling.ts and
switch to per-group counting that mirrors the totalItemCount formula.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 10:07:41 +02:00
David KayaandCopilot 8a4d23c22a feat: add Enable all / Approve all buttons to inline pills
Add bulk action buttons to the Tools and Auto-approval pill popovers:

- Tools pill: sticky header with Enable all / Disable all toggle button
  that enables or disables every MCP server and LSP profile at once
- Approval pill: Approve all / Unapprove all button in the existing
  sticky header next to the Reset button, approving or clearing all
  tool and server approval keys

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:49:20 +02:00
David KayaandCopilot 042cec6065 fix: resolve hook permissions to proper categories for approval
When the pre-tool-use hook returns 'ask', the Copilot CLI creates
PermissionRequestHook instead of categorized PermissionRequestRead/
Write/Shell. This caused 'Permission: hook' labels and broke category-
based auto-approval ('Always approve read' wouldn't cover grep/glob).

Add ResolveHookToolCategory mapping in CopilotApprovalCoordinator to
map known tool names (view/grep/glob→read, edit/create→write, etc.)
to their permission categories. Wire into GetFallbackToolName,
BuildPermissionApprovalEvent, and CreateApprovalPolicyOutput so:
- Approval banner shows 'Permission: read' instead of 'Permission: hook'
- 'Always approve' stores the category key, covering all tools in it
- Hook short-circuits when category is already auto-approved
Unknown tools (MCP, custom) keep existing 'hook' behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:41:51 +02:00
David KayaandCopilot 39fee48c0b feat: polish troubleshooting page and fix timeline icons
- Add 'Built with ❤ by Dávid Kaya' attribution footer to the
  troubleshooting settings page, matching the website footer
- Add 'Check for updates' action to troubleshooting, wired to the
  existing auto-updater IPC with live status feedback (checking,
  available, downloading, downloaded, error states)
- Fix timeline event icons: increase node circle from 15px to 18px,
  shrink icons from 14px to 10px for proper padding, and force white
  icon color on running-state gradient background to eliminate the
  purple-circle overlay clash

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 09:04:26 +02:00
David Kaya 27e784ab9b chore: bump version to 0.0.13 2026-03-30 01:10:52 +02:00
David Kaya 11a10ea53c fix: icon missing on windows 2026-03-30 01:10:33 +02:00
David KayaandCopilot 3318a14d32 docs: rewrite README and redesign website feature showcase
README:
- Full rewrite with confident, direct tone
- New structure: pitch → highlights → how-it-works → categorized feature tables
- Add 9 completed features (notifications, command palette, keyboard shortcuts,
  session search, onboarding, system tray, branching, message actions, animations)
- Update prerequisites to cross-platform (Windows, macOS, Linux)
- Drop redundant sections

Website:
- Replace flat 4x3 grid of 12 identical feature cards with 3 named categories
  (Workspace & Sessions, Agent Intelligence, Developer Tooling)
- Compact icon+title+description layout instead of heavy bordered cards
- Add 9 new completed features (22 features total, neatly organized)
- Each category has a colored accent heading with rule lines
- Hover reveals with subtle background transition

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 01:04:26 +02:00
David KayaandCopilot 3b69a9c0f7 chore: bump version to 0.0.12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 00:39:25 +02:00
David KayaandCopilot 023ea9b3e4 fix: set releaseType to release in electron-builder publish config
The release workflow creates a published GitHub release before
electron-builder runs. electron-builder defaults to releaseType=draft,
causing a type mismatch that prevents all asset uploads.

Setting releaseType to release tells electron-builder to upload assets
to the existing published release.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 00:38:34 +02:00
David KayaandCopilot bf2a454ef2 fix: auto-allow internal orchestration tools
Allow SDK-managed orchestration tools to bypass pre-tool approval prompts so Aryx matches Copilot CLI behavior for non-side-effectful meta tools.

Keep store_memory under the existing memory approval category.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 00:36:52 +02:00
Dávid KayaandGitHub a1932788ae feat: GPLv3 license 2026-03-30 00:26:14 +02:00
David KayaandCopilot c3e611dc74 fix: normalize macOS signing certificate
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-30 00:16:16 +02:00
102 changed files with 12027 additions and 965 deletions
+11
View File
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
+53 -4
View File
@@ -174,11 +174,22 @@ jobs:
exit 1
fi
SOURCE_CERT_PATH="$RUNNER_TEMP/apple-signing-source.p12"
CERT_PATH="$RUNNER_TEMP/apple-signing.p12"
PEM_PATH="$RUNNER_TEMP/apple-signing.pem"
PRECHECK_KEYCHAIN_PATH="$RUNNER_TEMP/apple-signing-preflight.keychain-db"
PRECHECK_KEYCHAIN_PASSWORD="$(uuidgen)"
API_KEY_PATH="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
CERT_PATH="$CERT_PATH" python3 - <<'PY'
cleanup_precheck_keychain() {
security delete-keychain "$PRECHECK_KEYCHAIN_PATH" >/dev/null 2>&1 || true
}
trap cleanup_precheck_keychain EXIT
CERT_PATH="$SOURCE_CERT_PATH" python3 - <<'PY'
import base64
import binascii
import os
from pathlib import Path
@@ -187,7 +198,11 @@ jobs:
if not normalized_value:
raise SystemExit("APPLE_CERT_P12_BASE64 is empty after whitespace normalization")
decoded = base64.b64decode(normalized_value, validate=True)
try:
decoded = base64.b64decode(normalized_value, validate=True)
except binascii.Error:
raise SystemExit("APPLE_CERT_P12_BASE64 is not valid base64")
if not decoded:
raise SystemExit("Decoded Apple signing certificate is empty")
@@ -195,16 +210,50 @@ jobs:
PY
printf '%s' "$APPLE_API_KEY_P8" > "$API_KEY_PATH"
if [[ ! -s "$CERT_PATH" ]]; then
if [[ ! -s "$SOURCE_CERT_PATH" ]]; then
echo "Decoded Apple signing certificate file is empty." >&2
exit 1
fi
if ! openssl pkcs12 -in "$CERT_PATH" -noout -passin env:APPLE_CERT_PASSWORD >/dev/null 2>&1; then
if ! openssl pkcs12 -in "$SOURCE_CERT_PATH" -noout -passin env:APPLE_CERT_PASSWORD >/dev/null 2>&1; then
echo "Decoded Apple signing certificate could not be opened with APPLE_CERT_PASSWORD." >&2
exit 1
fi
if ! openssl pkcs12 -in "$SOURCE_CERT_PATH" -passin env:APPLE_CERT_PASSWORD -nodes -out "$PEM_PATH" >/dev/null 2>&1; then
echo "Decoded Apple signing certificate could not be converted to PEM." >&2
exit 1
fi
if ! openssl pkcs12 -export -out "$CERT_PATH" -in "$PEM_PATH" -passout env:APPLE_CERT_PASSWORD -macalg sha1 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES >/dev/null 2>&1; then
echo "Apple signing certificate could not be re-exported into a macOS-compatible PKCS#12." >&2
exit 1
fi
if [[ ! -s "$CERT_PATH" ]]; then
echo "Normalized Apple signing certificate file is empty." >&2
exit 1
fi
if ! security create-keychain -p "$PRECHECK_KEYCHAIN_PASSWORD" "$PRECHECK_KEYCHAIN_PATH" >/dev/null 2>&1; then
echo "Unable to create the macOS signing precheck keychain." >&2
exit 1
fi
if ! security unlock-keychain -p "$PRECHECK_KEYCHAIN_PASSWORD" "$PRECHECK_KEYCHAIN_PATH" >/dev/null 2>&1; then
echo "Unable to unlock the macOS signing precheck keychain." >&2
exit 1
fi
if ! security import "$CERT_PATH" -k "$PRECHECK_KEYCHAIN_PATH" -P "$APPLE_CERT_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign >/dev/null 2>&1; then
echo "Normalized Apple signing certificate is still not importable by macOS security." >&2
exit 1
fi
rm -f "$SOURCE_CERT_PATH" "$PEM_PATH"
cleanup_precheck_keychain
trap - EXIT
write_github_env "CSC_LINK" "$CERT_PATH"
write_github_env "CSC_KEY_PASSWORD" "$APPLE_CERT_PASSWORD"
write_github_env "APPLE_API_KEY" "$API_KEY_PATH"
+17 -4
View File
@@ -55,7 +55,7 @@ flowchart LR
| --- | --- | --- | --- |
| Renderer | Screens, interaction, local view composition, theme application | Filesystem, process spawning, raw Electron access, Copilot runtime | Typed preload API and pushed events |
| Preload | Narrow bridge between browser context and Electron IPC | Business logic, persistence, orchestration | `ipcRenderer` / `ipcMain` |
| Main process | Workspace mutation, persistence, git inspection, session lifecycle, native window state, sidecar lifecycle, PTY-backed terminal lifecycle | UI rendering, LLM orchestration internals | IPC, filesystem, git CLI, stdio with sidecar, native child processes |
| Main process | Workspace mutation, persistence, git inspection/write operations, run change attribution, commit workflow orchestration, session lifecycle, native window state, sidecar lifecycle, PTY-backed terminal lifecycle | UI rendering, LLM orchestration internals | IPC, filesystem, git CLI, stdio with sidecar, native child processes |
| Sidecar | Capability discovery, pattern validation, run execution, streaming deltas and activity | UI, workspace persistence, Electron APIs | Line-delimited JSON over stdio |
| External systems | Git data, Copilot account/model access, OS window chrome | Application state and UI behavior | Controlled adapters owned by main or sidecar |
@@ -89,7 +89,7 @@ sequenceDiagram
R->>P: Invoke typed API
P->>M: IPC request
M->>M: Append user message
M->>M: Create run record and mark session running
M->>M: Capture pre-run git snapshot, create run record, and mark session running
M->>S: run-turn command
S->>C: Execute workflow
C-->>S: Partial output / tool activity / handoffs / input requests
@@ -97,7 +97,7 @@ sequenceDiagram
M-->>R: Push session events and workspace updates
C-->>S: Final messages or turn boundary
S-->>M: Completion or error
M->>M: Finalize run and persist state
M->>M: Finalize run, compute post-run git summary, refresh project git state, and persist state
M-->>R: Final workspace snapshot
```
@@ -126,6 +126,8 @@ The scratchpad is modeled inside the same workspace system instead of as a separ
Project-backed entries also persist scanned Copilot customization metadata discovered from repository files such as `.github/copilot-instructions.md`, `AGENTS.md`, `.github/agents/*.agent.md`, and `.github/prompts/*.prompt.md`. The main process owns that scan step and stores the normalized results on the project record so repo instructions and enabled custom agent profiles can participate in later run execution without turning the renderer into a filesystem crawler.
For git-backed projects, the main process also owns background git refreshes, captures a structured pre-run working-tree snapshot on each run record, and persists a post-run git change summary after project-backed turns complete. It also owns all git write operations exposed by Aryx — selective discard, staging, commit, push/pull/fetch, and branch lifecycle actions — so the renderer never shells out directly or manipulates repository state on its own.
### Patterns
Patterns describe how agents collaborate. The architecture supports:
@@ -161,6 +163,8 @@ A session is the working unit of the product. It binds together:
This is how Aryx keeps "ongoing work" first class. Sessions can survive restarts, can be organized, and can accumulate operational history over time.
Individual messages can be pinned as bookmarks. A dedicated bookmarks panel (`BookmarksPanel`) lists all pinned messages across all sessions globally, navigating to the originating session and message on selection. This data is derived renderer-side from the workspace state; there is no separate backend API.
### Runs
Each user turn becomes a **run**. A run is more than the final assistant output; it also tracks:
@@ -170,6 +174,7 @@ Each user turn becomes a **run**. A run is more than the final assistant output;
- which activity happened during the turn
- partial streaming output
- success or failure
- optional git baselines and post-run change summaries for project-backed execution
That run model is what enables the activity panel and historical timeline instead of forcing the user to infer execution from message text alone.
@@ -212,11 +217,15 @@ The protocol also carries **turn-scoped lifecycle events** alongside output delt
- **Sub-agent events**: started, completed, failed, selected, deselected — surfaced when custom agents are defined
- **Skill invocation events**: emitted when an agent-side skill is triggered
- **Message reclassification events**: let the sidecar retroactively mark a streamed assistant message as `thinking` once the SDK confirms that message requested tool work, so the UI can separate intermediate planning chatter from the final response without sacrificing live streaming
- **Assistant intent and reasoning-delta events**: optional Copilot SDK metadata that exposes short "what I'm doing" labels plus incremental reasoning text for richer thinking-process surfaces
- **Hook lifecycle events**: start and end of configured project hook commands discovered from `.github/hooks/*.json`; Aryx suppresses the SDK's built-in no-op hook chatter so the UI only sees meaningful hook activity
- **Assistant usage events**: per-LLM-call tokens, cost, AIU, and quota snapshots from the Copilot SDK's `assistant.usage` stream
- **Session compaction events**: start and complete, with token-reduction metrics when infinite sessions trigger context trimming
- **Session usage events**: current token count and context-window limit from `session.usage_info` for context-bar rendering
- **Pending-messages-modified events**: emitted when mid-turn steering changes the pending message queue
- **Workflow diagnostic events**: normalized warnings and errors from Agent Framework (`WorkflowWarningEvent`, `WorkflowErrorEvent`, `ExecutorFailedEvent`) with optional executor or subworkflow metadata for richer debugging surfaces
- **Workflow checkpoint events**: emitted at Agent Framework superstep boundaries with workflow session ID, checkpoint ID, step number, and checkpoint-store path so the main process can prepare crash-recovery state
These events flow through a single `onTurnScopedEvent` callback on the `runTurn` command, avoiding per-event-type callback proliferation. The main process maps each event to a `SessionEventRecord` and pushes it to the renderer, where lightweight state maps (activity, usage, turn-event log) consume them without touching the persisted workspace.
@@ -228,6 +237,8 @@ For project-backed sessions, the sidecar also discovers GitHub Copilot CLI hook
The `run-turn` command now also carries a project-instruction payload derived from scanned repo customization files. The main process composes that payload from repo-level instruction files and merges enabled discovered custom agent profiles into the primary pattern agent's Copilot configuration before sending the command across the stdio boundary. The sidecar then folds those project instructions into the final SDK system message alongside the agent's own instructions and runtime guidance.
For handoff workflows, the sidecar now also enables Agent Framework JSON checkpointing backed by a per-turn filesystem store under local app data. Each saved checkpoint is surfaced to the main process, which pairs the durable Agent Framework checkpoint with an in-memory rollback snapshot of `session.messages` and the active run timeline events. If the sidecar child process exits unexpectedly during the same app lifetime, Aryx restores the latest snapshot, clears pending approval/user-input/MCP-auth state for that run, and retries the `run-turn` request once with `resumeFromCheckpoint`. Checkpoint directories are deleted after the turn completes, cancels, or fails. This recovery path is intentionally scoped to same-app sidecar restarts; full app-restart workflow rehydration would require durable rollback snapshots in addition to the Agent Framework checkpoint payloads.
## Security model
Security in this system is mostly about **desktop trust boundaries**.
@@ -295,6 +306,8 @@ This lets the application treat tooling as reusable workspace capability while s
Project-backed sessions can carry repository context such as branch and dirty state, while scratchpad sessions omit git context but still support MCP, LSP, and runtime tooling. Scratchpad execution uses a per-session working directory instead of a single shared scratchpad folder, so file-based context and generated artifacts stay scoped to the active scratchpad session. Both session kinds share the same tooling selection and approval model. This keeps the architecture grounded in real codebases without forcing every conversation to be project-heavy, while still letting scratchpad sessions leverage configured tools when useful.
For git-backed projects, the renderer surfaces three specialized components. `RunChangeSummaryCard` appears inline in the run timeline after each completed run, showing the files changed during that run with per-file diff previews, origin attribution (run-created vs. pre-existing), and selective discard actions. `CommitComposer` is a slide-over panel for staging files, editing an AI-suggested commit message, selecting a conventional commit type, and committing (with optional push). `GitPanel` is embedded in the tabbed bottom panel (alongside the terminal) and provides branch management, push/pull/fetch network operations, working-tree change inspection, and recent commit history. The bottom panel uses a shared resize handle and tab bar so the terminal and git views coexist without competing for screen real estate. All git write operations flow through IPC to the main process; the renderer never runs git commands directly.
### Execution observability
The architecture treats execution as observable by design:
@@ -348,7 +361,7 @@ The build pipeline is organized around three layers:
- publishing the sidecar for the target runtime
- packaging platform artifacts with electron-builder
electron-builder bundles the packaged Electron app, copies the published sidecar into `resources/sidecar`, produces Windows NSIS installers, macOS DMG + ZIP artifacts, and Linux AppImages, and uploads the release assets plus update metadata to GitHub Releases. Tagged macOS release jobs now materialize the certificate and App Store Connect key from repository secrets into temporary files on the runner, export the standard `electron-builder` signing and notarization environment variables from those files, and package with checked-in hardened-runtime entitlements so native modules still run correctly under code signing. The main process consumes the published metadata through `electron-updater`, which checks GitHub Releases for packaged builds and can stage a restart-based update install.
electron-builder bundles the packaged Electron app, copies the published sidecar into `resources/sidecar`, produces Windows NSIS installers, macOS DMG + ZIP artifacts, and Linux AppImages, and uploads the release assets plus update metadata to GitHub Releases. Tagged macOS release jobs now materialize the certificate and App Store Connect key from repository secrets into temporary files on the runner, normalize the decoded PKCS#12 into a `security import`-compatible container, preflight that normalized certificate against a temporary keychain, export the standard `electron-builder` signing and notarization environment variables from those files, and package with checked-in hardened-runtime entitlements so native modules still run correctly under code signing. The main process consumes the published metadata through `electron-updater`, which checks GitHub Releases for packaged builds and can stage a restart-based update install.
Current Windows builds are unsigned, so the packaging config disables executable resource editing/signing and skips Windows update signature verification until a code-signing certificate is available. The packaging scripts also clear `release/` before each build so local packaging runs cannot accidentally mix stale artifacts with current ones.
+128
View File
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
noble_pinhole.0g@icloud.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+68 -112
View File
@@ -8,138 +8,94 @@
A desktop workspace for Copilot-powered work across real projects.
</p>
Aryx is built for people who want more than a generic AI chat window. It gives you a place to ask quick questions, connect real projects, run reusable agent patterns, and keep ongoing work organized in one app.
<p align="center">
<a href="https://github.com/davidkaya/aryx/releases">Download</a>&nbsp;&nbsp;·&nbsp;&nbsp;<a href="https://aryx.app">Website</a>&nbsp;&nbsp;·&nbsp;&nbsp;<a href="https://github.com/davidkaya/aryx/issues">Issues</a>
</p>
It works especially well when you want AI help that stays grounded in an actual codebase: your folders, your repository state, your current branch, and your active work.
---
## Why use Aryx?
Aryx is a desktop app that turns GitHub Copilot into a full workspace. Connect real projects, orchestrate multi-agent workflows, and keep persistent sessions organized — instead of starting from scratch in a blank chat window every time. It runs on Windows, macOS, and Linux.
- **Start fast** with a scratchpad conversation for quick questions and ad-hoc work.
- **Work against real projects** by attaching local folders and letting Aryx stay aware of repository context.
- **Go beyond one assistant** with orchestration patterns such as single-agent, sequential, concurrent, handoff, and group-chat flows.
- **See what is happening** with live activity for each agent while a run is in progress, including sub-agent delegations, hook lifecycle, skill invocations, and context compaction.
- **Stay organized** with persistent sessions you can rename, pin, archive, delete, and return to later.
- **Steer while agents work** by sending follow-up messages mid-turn — the agent receives your input immediately.
- **Attach images** to any message for visual context the model can reason about.
- **Tune how you work** by choosing models and reusing saved patterns that fit different tasks.
## Highlights
## What you can do in the app
- **Multi-agent orchestration** — single, sequential, concurrent, handoff, and group-chat patterns with a visual graph editor.
- **Project-grounded** — attach local folders and repos so every conversation has real codebase context.
- **Live execution visibility** — watch agents think, delegate, call tools, and consume context in real time.
- **Persistent workspace** — sessions survive restarts. Search, pin, archive, branch, and return to past work.
- **Extensible tooling** — MCP servers, LSP profiles, project hooks, and fine-grained tool approval controls.
- **Keyboard-first** — command palette, rich shortcuts, mid-turn steering, and a built-in terminal.
### Ask quick questions in a scratchpad
## How it works
If you just want to think through an idea, draft something, or ask for help without connecting a project, start a scratchpad session and begin chatting.
Each scratchpad session keeps its own isolated working directory, so files created in one scratchpad do not leak into another.
1. **Launch Aryx** — the app checks your Copilot CLI connection and shows status on the home screen.
2. **Connect a project** or open a scratchpad for quick questions without any setup.
3. **Pick a pattern** — choose a single-agent chat or a saved multi-agent orchestration workflow.
4. **Work** — ask questions, steer agents mid-turn, watch live activity, and keep the session for later.
### Connect a real project
## Features
Add a local folder when you want help that is grounded in your work. Aryx is designed to feel strongest when it is attached to a real project instead of acting like a general-purpose chatbot.
### Workspace & sessions
### Choose how agents collaborate
| Feature | Description |
|---------|-------------|
| Scratchpad sessions | Quick questions with isolated working directories — no project setup needed |
| Persistent sessions | Rename, pin, archive, duplicate, and return to sessions across restarts |
| Session branching | Fork a session at any user message to explore a different direction |
| Session search | Full-text search across all session messages, not just titles |
| Message actions | Copy, pin, edit-and-resend, and regenerate individual messages |
| Bookmarks | Browse all pinned messages across sessions in one panel (`Ctrl+Shift+B`) |
| System tray | Minimize to tray, quick-launch scratchpads, and see running session count |
| Desktop notifications | Native OS alerts when runs complete, fail, or need approval |
| Onboarding | First-launch walkthrough, interactive tooltips, and a "try it" quickstart |
Aryx supports several ways of working:
### Agent intelligence
- **Single** for direct one-agent help
- **Sequential** for pipeline-style work where each agent sees the full conversation and appends its contribution
- **Concurrent** for parallel exploration where the final turn aggregates multiple independent responses
- **Handoff** for agent-to-agent delegation, with the next user turn continuing when a specialist needs more input
- **Group chat** for round-robin collaborative refinement across multiple agent turns
| Feature | Description |
|---------|-------------|
| Orchestration patterns | Single, sequential, concurrent, handoff, and group-chat agent flows |
| Visual pattern editor | Drag nodes, draw connections, and inspect each step in a graph view |
| Mid-turn steering | Send follow-up messages while an agent is running — input is injected immediately |
| Plan review & questions | Agents propose plans and ask clarifying questions before acting |
| Run timeline | Structured history of tool calls, delegations, hooks, and context usage |
| Copilot customization | Auto-discovers instructions, agent profiles, and prompt files from your repo |
| Model & effort tuning | Choose models, adjust reasoning effort, and set interaction modes per session |
### Add global MCPs and LSPs
### Developer tooling
You can define MCP servers and LSP profiles once in **Settings**, then enable the ones you want for each project-backed session from the right-side **Activity** panel.
| Feature | Description |
|---------|-------------|
| Real project context | Attach folders and repos — see branch, dirty state, and ahead/behind status |
| MCP servers | Define servers globally, enable per session, auto-discover from project configs |
| LSP profiles | Language server integration for code intelligence in agent workflows |
| Tool approval | Fine-grained approval policies with pattern-level defaults and per-session overrides |
| Project hooks | Auto-discovers `.github/hooks/*.json` and runs lifecycle hooks in the sidecar |
| Image input | Attach screenshots, diagrams, or photos for visual reasoning |
| Integrated terminal | Full PTY-backed terminal inside the workspace (`Ctrl+\``) |
| Command palette | `Ctrl+K` fuzzy search across actions, sessions, and settings |
| Keyboard shortcuts | Comprehensive keybindings with a cheat sheet via `Ctrl+/` |
This keeps machine-wide tooling reusable while still letting each session decide which external tools the agent can use.
## Prerequisites
Patterns now require tool-call approval by default. They can also store default auto-approval for known MCP and LSP tools, and each session can override those auto-approval defaults from the Activity panel before a run starts.
Project-backed sessions also honor GitHub Copilot CLI-style hook files from `.github/hooks/*.json`. Aryx discovers them automatically in the connected repository and runs the supported lifecycle hooks inside the sidecar, with `preToolUse` deny decisions applied before Aryx's own approval policy.
### Watch runs as they happen
You can follow agent activity while a session is running, which makes longer or more complex workflows easier to trust and understand. The activity panel shows sub-agent delegations, skill invocations, hook lifecycle events, and context compaction in real time. A context-usage bar below the composer shows how much of the model's context window the current session occupies.
### Steer agents mid-turn
While an agent is working, you can type a follow-up message that is delivered immediately into the current turn. This lets you redirect, refine, or add context without waiting for the turn to finish. The composer shows an amber "steering" indicator when a message will be injected into an active run.
### Attach images
You can attach images (JPEG, PNG, GIF, WebP) to any message using the clip button, drag-and-drop, or paste from clipboard. Image attachments are sent as base64-encoded blobs so the model can reason about visual content alongside your text.
### Keep important work around
Sessions are persistent, so you can return to ongoing work instead of starting from scratch every time. You can also rename, pin, archive, delete, and duplicate sessions as your workspace grows.
## Before you start
To use Aryx comfortably, make sure you have:
- a **Windows machine**
- **GitHub Copilot CLI** installed and available as `copilot`
- an active **GitHub Copilot sign-in**
- a local folder or git repository ready to connect if you want project-aware help
- any MCP servers or language servers you want to use installed and reachable from your machine
- An active **GitHub Copilot** sign-in
- Windows, macOS, or Linux
Aryx includes connection status in the app so you can quickly tell whether Copilot is ready before you start a session.
Aryx shows your Copilot connection status in the app so you know if authentication is ready before starting a session.
## Getting started
## Development
1. **Open Aryx**
Launch the app and head to settings if you want to confirm your Copilot connection first.
```sh
bun run test # typecheck + unit tests
bun run sidecar:test # backend tests
bun run build # full build (electron + sidecar)
2. **Check that Copilot is ready**
Make sure the app shows that Copilot is installed and authenticated.
bun run package # package for current platform → release/
bun run installer # create installable artifact
bun run publish-release # publish to GitHub Releases
```
3. **Choose how you want to begin**
Start a scratchpad session for quick work, or add a project if you want the conversation grounded in a local codebase.
Tagged releases use GitHub Actions to build and publish Windows (NSIS), macOS (DMG, signed + notarized), and Linux (AppImage) artifacts. The app uses `electron-updater` for in-app updates.
4. **Pick a pattern**
Use a simple single-agent setup to begin, or choose a saved multi-agent pattern when you want a more structured workflow.
## Trademarks
5. **Configure optional tooling**
If you want MCP or LSP support, add the global definitions in settings and then enable the ones you want for the current session from the Activity panel. Aryx also surfaces Copilot CLI runtime tools for approval management: tool calls require approval by default, and you can set pattern-level auto-approval defaults and override them per session.
6. **Start working**
Ask a question, describe a task, or explore a project. As the run progresses, you can watch the participating agents and keep the session for later.
## When Aryx feels most useful
Aryx shines when you want to:
- move from quick chat to deeper multi-step work without leaving the app
- keep AI conversations tied to actual projects instead of isolated prompts
- compare different ways of approaching the same task
- reuse patterns for recurring workflows
- maintain a history of meaningful sessions instead of disposable chats
## Build and release automation
For local validation, run:
- `bun run test`
- `bun run sidecar:test`
- `bun run build`
To package the current platform into `release/`, run:
- `bun run package`
To create the installable artifacts for the current platform, run:
- `bun run installer`
To publish packaged artifacts and update metadata to GitHub Releases, run:
- `bun run publish-release`
GitHub Actions runs validation on pushes and pull requests, and tagged releases now use `electron-builder` to publish Windows (NSIS), macOS (DMG + ZIP for updater metadata), and Linux (AppImage) artifacts directly to GitHub Releases. Packaged builds use `electron-updater` against those releases for in-app updates.
Tagged macOS release jobs now prepare signing assets from the GitHub secrets `APPLE_CERT_P12_BASE64`, `APPLE_CERT_PASSWORD`, `APPLE_API_KEY_P8`, `APPLE_API_KEY_ID`, `APPLE_API_ISSUER`, and `APPLE_TEAM_ID`, then export the standard `electron-builder` environment variables (`CSC_LINK`, `CSC_KEY_PASSWORD`, `APPLE_API_KEY`, `APPLE_API_KEY_ID`, `APPLE_API_ISSUER`, `APPLE_TEAM_ID`) before packaging. That same release path signs and notarizes the macOS artifacts as part of publication.
Windows builds are currently packaged without Authenticode signing, so Aryx disables `electron-updater`'s Windows signature verification until a signing certificate is configured. macOS auto-update metadata still requires a ZIP artifact alongside the DMG build.
## Current focus
Aryx is focused on local, project-based work with your GitHub Copilot account. It already covers the essentials for working with projects, sessions, and reusable orchestration patterns, and it is growing toward a fuller AI workstation experience over time.
If you want an AI app that feels closer to a control room for real work than a blank chat box, Aryx is built for that.
GitHub and GitHub Copilot are trademarks of Microsoft Corporation. Aryx is an independent project, not affiliated with or endorsed by Microsoft or GitHub.
+1
View File
@@ -0,0 +1 @@
ManifestDPIAware true
+4
View File
@@ -0,0 +1,4 @@
provider: github
owner: davidkaya
repo: aryx
releaseType: release
+6 -4
View File
@@ -1,7 +1,7 @@
{
"name": "aryx",
"version": "0.0.8",
"description": "Electron orchestrator for Copilot-powered agent workflows across multiple projects.",
"version": "0.0.21",
"description": "Orchestrator for Copilot-powered agent workflows across multiple projects.",
"private": true,
"main": "dist-electron/main/index.js",
"scripts": {
@@ -110,7 +110,8 @@
"publish": {
"provider": "github",
"owner": "davidkaya",
"repo": "aryx"
"repo": "aryx",
"releaseType": "release"
},
"win": {
"target": [
@@ -118,13 +119,14 @@
],
"icon": "assets/icons/windows/icon.ico",
"artifactName": "Aryx-windows-${arch}.${ext}",
"signAndEditExecutable": false,
"signAndEditExecutable": true,
"verifyUpdateCodeSignature": false
},
"nsis": {
"oneClick": false,
"perMachine": false,
"allowToChangeInstallationDirectory": true,
"include": "assets/installer.nsh",
"installerIcon": "assets/icons/windows/icon.ico",
"uninstallerIcon": "assets/icons/windows/icon.ico"
},
@@ -85,6 +85,7 @@ public sealed class ChatMessageDto
public string AuthorName { get; init; } = string.Empty;
public string Content { get; init; } = string.Empty;
public string CreatedAt { get; init; } = string.Empty;
public string? MessageKind { get; set; }
public IReadOnlyList<ChatMessageAttachmentDto> Attachments { get; init; } = [];
}
@@ -187,6 +188,7 @@ public sealed class RunTurnCommandDto : SidecarCommandEnvelope
public PatternDefinitionDto Pattern { get; init; } = new();
public IReadOnlyList<ChatMessageDto> Messages { get; init; } = [];
public RunTurnToolingConfigDto? Tooling { get; init; }
public WorkflowCheckpointResumeDto? ResumeFromCheckpoint { get; init; }
}
public sealed class CancelTurnCommandDto : SidecarCommandEnvelope
@@ -331,6 +333,13 @@ public sealed class TurnCompleteEventDto : SidecarEventDto
public bool Cancelled { get; init; }
}
public sealed class MessageReclassifiedEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
public string MessageId { get; init; } = string.Empty;
public string NewKind { get; init; } = string.Empty;
}
public sealed class AgentActivityEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
@@ -376,6 +385,23 @@ public sealed class SkillInvokedEventDto : SidecarEventDto
public string? Description { get; init; }
}
public sealed class AssistantIntentEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
public string? AgentId { get; init; }
public string? AgentName { get; init; }
public string Intent { get; init; } = string.Empty;
}
public sealed class ReasoningDeltaEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
public string? AgentId { get; init; }
public string? AgentName { get; init; }
public string ReasoningId { get; init; } = string.Empty;
public string ContentDelta { get; init; } = string.Empty;
}
public sealed class HookLifecycleEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
@@ -463,6 +489,28 @@ public sealed class PendingMessagesModifiedEventDto : SidecarEventDto
public string? AgentName { get; init; }
}
public sealed class WorkflowCheckpointSavedEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
public string WorkflowSessionId { get; init; } = string.Empty;
public string CheckpointId { get; init; } = string.Empty;
public string StorePath { get; init; } = string.Empty;
public int StepNumber { get; init; }
}
public sealed class WorkflowDiagnosticEventDto : SidecarEventDto
{
public string SessionId { get; init; } = string.Empty;
public string Severity { get; init; } = string.Empty;
public string DiagnosticKind { get; init; } = string.Empty;
public string Message { get; init; } = string.Empty;
public string? AgentId { get; init; }
public string? AgentName { get; init; }
public string? ExecutorId { get; init; }
public string? SubworkflowId { get; init; }
public string? ExceptionType { get; init; }
}
public sealed class SessionsListedEventDto : SidecarEventDto
{
public IReadOnlyList<CopilotSessionInfoDto> Sessions { get; init; } = [];
@@ -566,6 +614,13 @@ public sealed class ExitPlanModeRequestedEventDto : SidecarEventDto
public string? RecommendedAction { get; init; }
}
public sealed class WorkflowCheckpointResumeDto
{
public string WorkflowSessionId { get; init; } = string.Empty;
public string CheckpointId { get; init; } = string.Empty;
public string StorePath { get; init; } = string.Empty;
}
public sealed class CommandErrorEventDto : SidecarEventDto
{
public string Message { get; init; } = string.Empty;
@@ -51,27 +51,7 @@ internal static class AgentInstructionComposer
return JoinInstructionBlocks(baseInstructions, repositoryInstructions, workspaceGuidance, planModeGuidance, groupChatGuidance);
}
if (!string.Equals(pattern.Mode, "handoff", StringComparison.OrdinalIgnoreCase))
{
return JoinInstructionBlocks(baseInstructions, repositoryInstructions, workspaceGuidance, planModeGuidance);
}
string runtimeGuidance = agentIndex == 0
? """
You are the routing gate for this handoff workflow.
Your job is to classify the request and hand it off to the most appropriate specialist as soon as you know who should own the substantive work.
For any substantive task, your next meaningful action must be the actual handoff rather than a plain-text promise to delegate later.
Do not inspect files, call tools, draft the implementation, or produce the final user-facing answer yourself once a specialist is appropriate.
Do not claim that you handed work off unless you actually executed the handoff.
Only answer directly if the user is asking for pure triage or a minimal clarification that must happen before delegation.
"""
: """
You are a specialist participating in a handoff workflow.
Once the triage agent hands work to you, you own the substantive answer within your specialty and should carry it through.
Do not push the actual work back to triage unless you are blocked or the request is clearly outside your specialty.
""";
return JoinInstructionBlocks(baseInstructions, repositoryInstructions, workspaceGuidance, planModeGuidance, runtimeGuidance);
return JoinInstructionBlocks(baseInstructions, repositoryInstructions, workspaceGuidance, planModeGuidance);
}
private static string JoinInstructionBlocks(params string[] blocks)
@@ -1,3 +1,4 @@
using System.Collections.Concurrent;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.Json;
@@ -104,6 +105,7 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
try
{
Channel<AgentResponseUpdate> channel = Channel.CreateUnbounded<AgentResponseUpdate>();
ConcurrentDictionary<string, string> toolNamesByCallId = new(StringComparer.Ordinal);
using IDisposable subscription = copilotSession.On(evt =>
{
@@ -114,9 +116,19 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
break;
case AssistantMessageEvent assistantMessage:
TrackToolRequestNames(toolNamesByCallId, assistantMessage.Data?.ToolRequests);
channel.Writer.TryWrite(ConvertToAgentResponseUpdate(assistantMessage));
break;
case ToolExecutionCompleteEvent toolExecutionComplete:
AgentResponseUpdate? toolResultUpdate = ConvertToAgentResponseUpdate(toolExecutionComplete, toolNamesByCallId);
if (toolResultUpdate is not null)
{
channel.Writer.TryWrite(toolResultUpdate);
}
break;
case AssistantUsageEvent usageEvent:
channel.Writer.TryWrite(ConvertToAgentResponseUpdate(usageEvent));
break;
@@ -232,16 +244,6 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
continue;
}
// Only project handoff tool calls as FunctionCallContent for the Agent Framework.
// Other tool calls (ask_user, MCP tools, etc.) are resolved by the Copilot SDK
// internally and must not be surfaced, because AIAgentHostExecutor tracks every
// FunctionCallContent as an outstanding request. An unmatched request prevents
// the executor from emitting a TurnToken, which stalls group-chat advancement.
if (!IsHandoffToolName(toolRequest.Name))
{
continue;
}
contents.Add(new FunctionCallContent(
toolRequest.ToolCallId,
toolRequest.Name,
@@ -251,6 +253,26 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
return contents;
}
internal static FunctionResultContent? TryCreateToolResultContent(
ToolExecutionCompleteEvent toolExecutionComplete,
string? toolName = null)
{
// Regular Copilot tools need their result projected back into AF so the function call
// remains part of workflow-visible history. Handoff tools are finalized separately by
// HandoffAgentExecutor, which already injects its own "Transferred." result.
string? toolCallId = toolExecutionComplete.Data?.ToolCallId?.Trim();
if (string.IsNullOrWhiteSpace(toolCallId) || IsHandoffToolName(toolName))
{
return null;
}
string result = ResolveToolResultText(toolExecutionComplete.Data);
return new FunctionResultContent(toolCallId, result)
{
RawRepresentation = toolExecutionComplete,
};
}
private static bool IsHandoffToolName(string? name)
{
return !string.IsNullOrWhiteSpace(name)
@@ -441,6 +463,36 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
};
}
private AgentResponseUpdate? ConvertToAgentResponseUpdate(
ToolExecutionCompleteEvent toolExecutionComplete,
ConcurrentDictionary<string, string> toolNamesByCallId)
{
string? toolCallId = toolExecutionComplete.Data?.ToolCallId?.Trim();
if (string.IsNullOrWhiteSpace(toolCallId))
{
return null;
}
string? toolName = null;
if (toolNamesByCallId.TryRemove(toolCallId, out string? trackedToolName))
{
toolName = trackedToolName;
}
FunctionResultContent? toolResult = TryCreateToolResultContent(toolExecutionComplete, toolName);
if (toolResult is null)
{
return null;
}
return new AgentResponseUpdate(ChatRole.Tool, [toolResult])
{
AgentId = Id,
MessageId = toolCallId,
CreatedAt = toolExecutionComplete.Timestamp,
};
}
private AgentResponseUpdate ConvertToAgentResponseUpdate(SessionEvent sessionEvent)
{
AIContent content = new()
@@ -455,6 +507,45 @@ internal sealed class AryxCopilotAgent : AIAgent, IAsyncDisposable
};
}
private static void TrackToolRequestNames(
ConcurrentDictionary<string, string> toolNamesByCallId,
AssistantMessageDataToolRequestsItem[]? toolRequests)
{
if (toolRequests is not { Length: > 0 })
{
return;
}
foreach (AssistantMessageDataToolRequestsItem toolRequest in toolRequests)
{
string? toolCallId = toolRequest.ToolCallId?.Trim();
string? toolName = toolRequest.Name?.Trim();
if (string.IsNullOrWhiteSpace(toolCallId) || string.IsNullOrWhiteSpace(toolName))
{
continue;
}
toolNamesByCallId[toolCallId] = toolName;
}
}
private static string ResolveToolResultText(ToolExecutionCompleteData? toolExecutionCompleteData)
{
if (toolExecutionCompleteData is null)
{
return string.Empty;
}
if (toolExecutionCompleteData.Success)
{
return toolExecutionCompleteData.Result?.Content
?? toolExecutionCompleteData.Result?.DetailedContent
?? string.Empty;
}
return toolExecutionCompleteData.Error?.Message ?? string.Empty;
}
private static Dictionary<string, object?>? ParseToolArguments(object? arguments)
{
if (arguments is null)
@@ -189,9 +189,9 @@ internal sealed class CopilotAgentBundle : IAsyncDisposable
{
return pattern.Mode switch
{
"single" => AgentWorkflowBuilder.BuildSequential(pattern.Name, ResolveOrderedAgents(pattern)),
"sequential" => AgentWorkflowBuilder.BuildSequential(pattern.Name, ResolveOrderedAgents(pattern)),
"concurrent" => AgentWorkflowBuilder.BuildConcurrent(pattern.Name, ResolveOrderedAgents(pattern)),
"single" => BuildSequentialWorkflow(pattern),
"sequential" => BuildSequentialWorkflow(pattern),
"concurrent" => BuildConcurrentWorkflow(pattern),
"handoff" => BuildHandoffWorkflow(pattern),
"group-chat" => BuildGroupChatWorkflow(pattern),
"magentic" => throw new NotSupportedException(
@@ -222,8 +222,7 @@ internal sealed class CopilotAgentBundle : IAsyncDisposable
: pattern.Agents.FirstOrDefault()?.Id ?? topology.EntryAgentId;
AIAgent entryAgent = agentMap.GetValueOrDefault(entryAgentId) ?? Agents[0];
HandoffsWorkflowBuilder builder = AgentWorkflowBuilder.CreateHandoffBuilderWith(entryAgent)
.WithHandoffInstructions(HandoffWorkflowGuidance.CreateWorkflowInstructions());
HandoffsWorkflowBuilder builder = CreateHandoffWorkflowBuilder(entryAgent);
foreach (PatternHandoffRoute route in topology.Routes)
{
@@ -250,20 +249,136 @@ internal sealed class CopilotAgentBundle : IAsyncDisposable
return builder.Build();
}
internal static AIAgentHostOptions CreateAgentHostOptions()
{
return new AIAgentHostOptions
{
// Aryx controls per-turn streaming with TurnToken(emitEvents: true), so keep this
// null to preserve that behavior while making the host defaults explicit in code.
EmitAgentUpdateEvents = null,
// Aryx already projects streamed transcript state itself; enabling this would add
// extra response events that need separate reconciliation first.
EmitAgentResponseEvents = false,
InterceptUserInputRequests = false,
InterceptUnterminatedFunctionCalls = false,
ReassignOtherAgentsAsUsers = true,
ForwardIncomingMessages = true,
};
}
internal static HandoffsWorkflowBuilder CreateHandoffWorkflowBuilder(AIAgent entryAgent)
{
return AgentWorkflowBuilder.CreateHandoffBuilderWith(entryAgent)
// Preserve normal tool-call history across handoffs while still hiding the
// workflow's handoff plumbing. Make this explicit so AF default changes
// cannot silently alter Aryx handoff behavior.
.WithToolCallFilteringBehavior(HandoffToolCallFilteringBehavior.HandoffOnly)
.WithHandoffInstructions(HandoffWorkflowGuidance.CreateWorkflowInstructions());
}
private Workflow BuildSequentialWorkflow(PatternDefinitionDto pattern)
{
IReadOnlyList<AIAgent> agents = ResolveOrderedAgents(pattern);
List<ExecutorBinding> agentExecutors = agents
.Select(CreateAgentExecutorBinding)
.ToList();
ExecutorBinding previous = agentExecutors[0];
WorkflowBuilder builder = new(previous);
foreach (ExecutorBinding next in agentExecutors.Skip(1))
{
builder.AddEdge(previous, next);
previous = next;
}
WorkflowOutputMessagesExecutor end = new();
builder = builder.AddEdge(previous, end).WithOutputFrom(end);
if (pattern.Name is not null)
{
builder = builder.WithName(pattern.Name);
}
return builder.Build();
}
private Workflow BuildConcurrentWorkflow(PatternDefinitionDto pattern)
{
IReadOnlyList<AIAgent> agents = ResolveOrderedAgents(pattern);
ChatForwardingExecutor start = new("Start");
WorkflowBuilder builder = new(start);
ExecutorBinding[] agentExecutors = agents
.Select(CreateAgentExecutorBinding)
.ToArray();
ExecutorBinding[] accumulators = agentExecutors
.Select(executor => CreateAggregateMessagesExecutorBinding($"Batcher/{executor.Id}"))
.ToArray();
builder.AddFanOutEdge(start, agentExecutors);
for (int index = 0; index < agentExecutors.Length; index++)
{
builder.AddEdge(agentExecutors[index], accumulators[index]);
}
Func<string, string, ValueTask<WorkflowConcurrentEndExecutor>> endFactory =
(_, __) => new(new WorkflowConcurrentEndExecutor(agentExecutors.Length, AggregateConcurrentResults));
ExecutorBinding end = endFactory.BindExecutor(WorkflowConcurrentEndExecutor.ExecutorId);
builder.AddFanInBarrierEdge(accumulators, end);
builder = builder.WithOutputFrom(end);
if (pattern.Name is not null)
{
builder = builder.WithName(pattern.Name);
}
return builder.Build();
}
private Workflow BuildGroupChatWorkflow(PatternDefinitionDto pattern)
{
int maximumIterations = pattern.MaxIterations <= 0 ? 5 : pattern.MaxIterations;
AIAgent[] agents = ResolveOrderedAgents(pattern).ToArray();
Dictionary<AIAgent, ExecutorBinding> agentMap = agents.ToDictionary(
agent => agent,
CreateAgentExecutorBinding);
return AgentWorkflowBuilder
.CreateGroupChatBuilderWith(agents =>
new RoundRobinGroupChatManager(agents)
{
MaximumIterationCount = maximumIterations,
})
.AddParticipants(ResolveOrderedAgents(pattern).ToArray())
.Build();
Func<string, string, ValueTask<WorkflowRoundRobinGroupChatHost>> groupChatHostFactory =
(id, _) => new(new WorkflowRoundRobinGroupChatHost(
id,
agents,
agentMap,
maximumIterations));
ExecutorBinding host = groupChatHostFactory.BindExecutor("GroupChatHost");
WorkflowBuilder builder = new(host);
foreach (ExecutorBinding participant in agentMap.Values)
{
builder
.AddEdge(host, participant)
.AddEdge(participant, host);
}
return builder.WithOutputFrom(host).Build();
}
private static ExecutorBinding CreateAgentExecutorBinding(AIAgent agent)
=> agent.BindAsExecutor(CreateAgentHostOptions());
private static ExecutorBinding CreateAggregateMessagesExecutorBinding(string id)
{
Func<string, string, ValueTask<WorkflowAggregateTurnMessagesExecutor>> factory =
(_, __) => new(new WorkflowAggregateTurnMessagesExecutor(id));
return factory.BindExecutor(id);
}
private static List<ChatMessage> AggregateConcurrentResults(IList<List<ChatMessage>> lists)
=> [.. from list in lists where list.Count > 0 select list.Last()];
private IReadOnlyList<AIAgent> ResolveOrderedAgents(PatternDefinitionDto pattern)
{
Dictionary<string, AIAgent> agentMap = BuildAgentMap(pattern);
@@ -21,6 +21,24 @@ internal sealed class CopilotApprovalCoordinator
private const string HookPermissionKind = "hook";
private const string ToolCallingActivityType = "tool-calling";
private static readonly Dictionary<string, string> HookToolCategories = new(StringComparer.OrdinalIgnoreCase)
{
["view"] = ReadPermissionKind,
["glob"] = ReadPermissionKind,
["grep"] = ReadPermissionKind,
["lsp"] = ReadPermissionKind,
["edit"] = WritePermissionKind,
["create"] = WritePermissionKind,
["powershell"] = ShellPermissionKind,
["read_powershell"] = ShellPermissionKind,
["write_powershell"] = ShellPermissionKind,
["stop_powershell"] = ShellPermissionKind,
["list_powershell"] = ShellPermissionKind,
["web_fetch"] = UrlPermissionKind,
["web_search"] = UrlPermissionKind,
["store_memory"] = MemoryPermissionKind,
};
private readonly ConcurrentDictionary<string, PendingApprovalRequest> _pendingApprovals = new(StringComparer.Ordinal);
private readonly ConcurrentDictionary<string, ConcurrentDictionary<string, byte>> _requestApprovedTools = new(StringComparer.Ordinal);
@@ -80,7 +98,7 @@ internal sealed class CopilotApprovalCoordinator
{
string? toolName = ResolveApprovalToolName(request, toolNamesByCallId);
string? autoApprovedToolName = ResolveAutoApprovedToolName(request);
string? mcpServerApprovalKey = ResolveMcpServerApprovalKey(request);
string? mcpServerApprovalKey = ResolveMcpServerApprovalKey(request, command.Tooling?.McpServers);
string? approvalCacheKey = ResolveApprovalCacheKey(toolName, autoApprovedToolName);
AgentActivityEventDto? fileChangeActivity = BuildToolCallFileChangeActivity(command, agent, request, toolName);
@@ -137,9 +155,8 @@ internal sealed class CopilotApprovalCoordinator
string approvalId,
string? toolName)
{
string permissionKind = string.IsNullOrWhiteSpace(request.Kind)
? "tool access"
: request.Kind.Trim();
string permissionKind = ResolvePermissionKind(request, command.Tooling?.McpServers);
string agentName = string.IsNullOrWhiteSpace(agent.Name) ? agent.Id : agent.Name;
string? sessionId = NormalizeOptionalString(invocation.SessionId);
string? normalizedToolName = NormalizeOptionalString(toolName);
@@ -180,7 +197,7 @@ internal sealed class CopilotApprovalCoordinator
PermissionKind = permissionKind,
Title = title,
Detail = detail,
PermissionDetail = BuildPermissionDetail(request),
PermissionDetail = BuildPermissionDetail(request, command.Tooling?.McpServers),
};
}
@@ -224,7 +241,9 @@ internal sealed class CopilotApprovalCoordinator
};
}
internal static PermissionDetailDto BuildPermissionDetail(PermissionRequest request)
internal static PermissionDetailDto BuildPermissionDetail(
PermissionRequest request,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers = null)
{
ArgumentNullException.ThrowIfNull(request);
@@ -281,12 +300,7 @@ internal sealed class CopilotApprovalCoordinator
ToolDescription = NormalizeOptionalString(customTool.ToolDescription),
Args = customTool.Args,
},
PermissionRequestHook hook => new PermissionDetailDto
{
Kind = HookPermissionKind,
Args = hook.ToolArgs,
HookMessage = NormalizeOptionalString(hook.HookMessage),
},
PermissionRequestHook hook => BuildHookPermissionDetail(hook, configuredMcpServers),
_ => new PermissionDetailDto
{
Kind = NormalizeOptionalString(request.Kind) ?? "unknown",
@@ -402,15 +416,45 @@ internal sealed class CopilotApprovalCoordinator
private const string McpServerApprovalPrefix = "mcp_server:";
private static string? ResolveMcpServerApprovalKey(PermissionRequest request)
private static string? ResolveMcpServerApprovalKey(
PermissionRequest request,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers)
{
if (request is not PermissionRequestMcp mcp)
return request switch
{
PermissionRequestMcp mcp => BuildMcpServerApprovalKey(mcp.ServerName),
PermissionRequestHook hook => ResolveHookMcpServerApprovalKey(hook.ToolName, configuredMcpServers),
_ => null,
};
}
internal static string? BuildMcpServerApprovalKey(string? serverName)
{
string? normalizedServerName = NormalizeOptionalString(serverName);
return normalizedServerName is not null ? $"{McpServerApprovalPrefix}{normalizedServerName}" : null;
}
internal static string? ResolveHookMcpServerApprovalKey(
string? toolName,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers)
=> BuildMcpServerApprovalKey(ResolveHookMcpServerName(toolName, configuredMcpServers));
internal static string? ResolveHookMcpServerName(
string? toolName,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers)
{
string? normalizedToolName = NormalizeOptionalString(toolName);
if (normalizedToolName is null || configuredMcpServers is null || configuredMcpServers.Count == 0)
{
return null;
}
string? serverName = NormalizeOptionalString(mcp.ServerName);
return serverName is not null ? $"{McpServerApprovalPrefix}{serverName}" : null;
return configuredMcpServers
.Select(ResolveConfiguredMcpServerName)
.OfType<string>()
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderByDescending(static serverName => serverName.Length)
.FirstOrDefault(serverName => MatchesHookMcpServerToolName(normalizedToolName, serverName));
}
private static string? ResolveApprovalCacheKey(
@@ -476,10 +520,103 @@ internal sealed class CopilotApprovalCoordinator
PermissionRequestWrite => WritePermissionKind,
PermissionRequestRead => ReadPermissionKind,
PermissionRequestMemory => StoreMemoryToolName,
PermissionRequestHook hook => ResolveHookToolCategory(hook.ToolName),
_ => null,
};
}
internal static string? ResolveHookToolCategory(string? toolName)
{
string? normalized = NormalizeOptionalString(toolName);
if (normalized is null)
{
return null;
}
return HookToolCategories.TryGetValue(normalized, out string? category) ? category : null;
}
private static string ResolvePermissionKind(
PermissionRequest request,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers)
{
string permissionKind = string.IsNullOrWhiteSpace(request.Kind)
? "tool access"
: request.Kind.Trim();
if (request is not PermissionRequestHook hook)
{
return permissionKind;
}
string? resolvedCategory = ResolveHookToolCategory(hook.ToolName);
if (resolvedCategory is not null)
{
return resolvedCategory;
}
return ResolveHookMcpServerName(hook.ToolName, configuredMcpServers) is not null
? McpPermissionKind
: permissionKind;
}
private static PermissionDetailDto BuildHookPermissionDetail(
PermissionRequestHook hook,
IReadOnlyList<RunTurnMcpServerConfigDto>? configuredMcpServers)
{
string? serverName = ResolveHookMcpServerName(hook.ToolName, configuredMcpServers);
if (serverName is null)
{
return new PermissionDetailDto
{
Kind = HookPermissionKind,
Args = hook.ToolArgs,
HookMessage = NormalizeOptionalString(hook.HookMessage),
};
}
return new PermissionDetailDto
{
Kind = McpPermissionKind,
ServerName = serverName,
ToolTitle = ResolveHookMcpToolTitle(hook.ToolName, serverName),
Args = hook.ToolArgs,
};
}
private static string? ResolveConfiguredMcpServerName(RunTurnMcpServerConfigDto configuredServer)
=> NormalizeOptionalString(configuredServer.Name) ?? NormalizeOptionalString(configuredServer.Id);
private static bool MatchesHookMcpServerToolName(string toolName, string serverName)
{
if (string.Equals(toolName, serverName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
return toolName.StartsWith($"{serverName}-", StringComparison.OrdinalIgnoreCase);
}
private static string? ResolveHookMcpToolTitle(string? toolName, string serverName)
{
string? normalizedToolName = NormalizeOptionalString(toolName);
if (normalizedToolName is null)
{
return null;
}
string prefix = $"{serverName}-";
if (!normalizedToolName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
return normalizedToolName;
}
string strippedToolName = normalizedToolName[prefix.Length..];
return string.IsNullOrWhiteSpace(strippedToolName)
? normalizedToolName
: strippedToolName;
}
private static bool MatchesAutoApprovedTool(
IReadOnlyList<string> autoApprovedToolNames,
string? toolName,
@@ -11,14 +11,30 @@ internal static class CopilotSessionHooks
private const string AllowDecision = "allow";
private const string AskDecision = "ask";
private const string DenyDecision = "deny";
private const string ExitPlanModeToolName = "exit_plan_mode";
private const string FetchCopilotCliDocumentationToolName = "fetch_copilot_cli_documentation";
private const string HandoffToolPrefix = "handoff_to_";
private const string ListAgentsToolName = "list_agents";
private const string ReadAgentToolName = "read_agent";
private const string ReportIntentToolName = "report_intent";
private const string SkillToolName = "skill";
private const string SqlToolName = "sql";
private const string TaskToolName = "task";
private const string TaskCompleteToolName = "task_complete";
private const string UpdateTodoToolName = "update_todo";
private static readonly HashSet<string> AlwaysAllowedToolNames = new(StringComparer.OrdinalIgnoreCase)
{
AskUserToolName,
ExitPlanModeToolName,
FetchCopilotCliDocumentationToolName,
ListAgentsToolName,
ReadAgentToolName,
ReportIntentToolName,
SkillToolName,
SqlToolName,
TaskToolName,
TaskCompleteToolName,
UpdateTodoToolName,
};
private static readonly JsonSerializerOptions HookJsonOptions = CreateHookJsonOptions();
@@ -232,11 +248,17 @@ internal static class CopilotSessionHooks
};
}
string? autoApprovedToolName = CopilotApprovalCoordinator.ResolveHookToolCategory(toolName) ?? toolName;
string? mcpServerApprovalKey = CopilotApprovalCoordinator.ResolveHookMcpServerApprovalKey(
toolName,
command.Tooling?.McpServers);
bool requiresApproval = CopilotApprovalCoordinator.RequiresToolCallApproval(
command.Pattern.ApprovalPolicy,
agentDefinition.Id,
toolName,
toolName);
autoApprovedToolName,
mcpServerApprovalKey);
return new PreToolUseHookOutput
{
@@ -9,11 +9,13 @@ internal sealed class CopilotTurnExecutionState
{
private readonly RunTurnCommandDto _command;
private readonly HashSet<string> _startedAgents = new(StringComparer.OrdinalIgnoreCase);
private readonly HashSet<string> _reclassifiedMessageIds = new(StringComparer.Ordinal);
private readonly ConcurrentQueue<SidecarEventDto> _pendingEvents = new();
private readonly ConcurrentQueue<McpOauthRequiredEventDto> _pendingMcpOauthRequests = new();
private readonly ConcurrentDictionary<string, AgentIdentity> _observedAgentsByMessageId = new(StringComparer.Ordinal);
private readonly StreamingTranscriptBuffer _transcriptBuffer = new();
private int _fallbackMessageIndex;
private string? _lastObservedMessageId;
public CopilotTurnExecutionState(RunTurnCommandDto command)
{
@@ -79,15 +81,43 @@ internal sealed class CopilotTurnExecutionState
case AssistantMessageEvent assistantMessage when !string.IsNullOrWhiteSpace(assistantMessage.Data?.MessageId):
RecordObservedAgentForMessage(agent, assistantMessage.Data!.MessageId);
QueueThinkingIfNeeded(agent);
if (assistantMessage.Data?.ToolRequests is { Length: > 0 })
{
QueueMessageReclassifiedIfNeeded(assistantMessage.Data.MessageId);
}
break;
case ToolExecutionStartEvent toolExecutionStart
when !string.IsNullOrWhiteSpace(toolExecutionStart.Data?.ToolCallId)
&& !string.IsNullOrWhiteSpace(toolExecutionStart.Data?.ToolName):
ToolNamesByCallId[toolExecutionStart.Data.ToolCallId.Trim()] = toolExecutionStart.Data.ToolName.Trim();
string toolCallId = toolExecutionStart.Data.ToolCallId.Trim();
string toolName = toolExecutionStart.Data.ToolName.Trim();
ToolNamesByCallId[toolCallId] = toolName;
ActiveAgent = agent;
AgentActivityEventDto? toolActivity = CreateToolCallingActivity(agent, toolName, toolCallId);
if (toolActivity is not null)
{
_pendingEvents.Enqueue(toolActivity);
}
QueueMessageReclassifiedIfNeeded(_lastObservedMessageId);
break;
case AssistantReasoningDeltaEvent:
case AssistantIntentEvent intentEvent:
ActiveAgent = agent;
QueueThinkingIfNeeded(agent);
AssistantIntentEventDto? assistantIntent = CreateAssistantIntentEvent(agent, intentEvent.Data);
if (assistantIntent is not null)
{
_pendingEvents.Enqueue(assistantIntent);
}
break;
case AssistantReasoningDeltaEvent reasoningDelta:
ActiveAgent = agent;
QueueThinkingIfNeeded(agent);
ReasoningDeltaEventDto? reasoningDeltaEvent = CreateReasoningDeltaEvent(agent, reasoningDelta.Data);
if (reasoningDeltaEvent is not null)
{
_pendingEvents.Enqueue(reasoningDeltaEvent);
}
break;
case SubagentStartedEvent started:
ActiveAgent = agent;
@@ -218,6 +248,23 @@ internal sealed class CopilotTurnExecutionState
{
ActiveAgent = agent;
_observedAgentsByMessageId[messageId] = agent;
_lastObservedMessageId = messageId;
}
private void QueueMessageReclassifiedIfNeeded(string? messageId)
{
if (string.IsNullOrWhiteSpace(messageId))
{
return;
}
string normalizedMessageId = messageId.Trim();
if (!_reclassifiedMessageIds.Add(normalizedMessageId))
{
return;
}
_pendingEvents.Enqueue(CreateMessageReclassifiedEvent(normalizedMessageId));
}
private AgentActivityEventDto? CreateThinkingActivityIfNeeded(AgentIdentity agent)
@@ -240,6 +287,41 @@ internal sealed class CopilotTurnExecutionState
};
}
private AgentActivityEventDto? CreateToolCallingActivity(
AgentIdentity agent,
string toolName,
string toolCallId)
{
if (toolName.StartsWith("handoff_to_", StringComparison.Ordinal))
{
return null;
}
return new AgentActivityEventDto
{
Type = "agent-activity",
RequestId = _command.RequestId,
SessionId = _command.SessionId,
ActivityType = "tool-calling",
AgentId = agent.AgentId,
AgentName = agent.AgentName,
ToolName = toolName,
ToolCallId = toolCallId,
};
}
private MessageReclassifiedEventDto CreateMessageReclassifiedEvent(string messageId)
{
return new MessageReclassifiedEventDto
{
Type = "message-reclassified",
RequestId = _command.RequestId,
SessionId = _command.SessionId,
MessageId = messageId,
NewKind = "thinking",
};
}
public void UpdateCompletedMessages(
IReadOnlyList<ChatMessage> allMessages,
IReadOnlyList<ChatMessage> inputMessages)
@@ -263,6 +345,14 @@ internal sealed class CopilotTurnExecutionState
ActiveAgent);
}
foreach (ChatMessageDto message in CompletedMessages)
{
if (_reclassifiedMessageIds.Contains(message.Id))
{
message.MessageKind = "thinking";
}
}
return CompletedMessages;
}
@@ -354,6 +444,50 @@ internal sealed class CopilotTurnExecutionState
};
}
private AssistantIntentEventDto? CreateAssistantIntentEvent(
AgentIdentity agent,
AssistantIntentData? data)
{
string? intent = data?.Intent?.Trim();
if (string.IsNullOrWhiteSpace(intent))
{
return null;
}
return new AssistantIntentEventDto
{
Type = "assistant-intent",
RequestId = _command.RequestId,
SessionId = _command.SessionId,
AgentId = agent.AgentId,
AgentName = agent.AgentName,
Intent = intent,
};
}
private ReasoningDeltaEventDto? CreateReasoningDeltaEvent(
AgentIdentity agent,
AssistantReasoningDeltaData? data)
{
if (data is null
|| string.IsNullOrWhiteSpace(data.ReasoningId)
|| string.IsNullOrEmpty(data.DeltaContent))
{
return null;
}
return new ReasoningDeltaEventDto
{
Type = "reasoning-delta",
RequestId = _command.RequestId,
SessionId = _command.SessionId,
AgentId = agent.AgentId,
AgentName = agent.AgentName,
ReasoningId = data.ReasoningId,
ContentDelta = data.DeltaContent,
};
}
private SkillInvokedEventDto CreateSkillInvokedEvent(
AgentIdentity agent,
SkillInvokedData? data)
@@ -1,7 +1,9 @@
using System.IO;
using System.Linq;
using Aryx.AgentHost.Contracts;
using GitHub.Copilot.SDK;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Agents.AI.Workflows.Checkpointing;
using Microsoft.Extensions.AI;
namespace Aryx.AgentHost.Services;
@@ -81,7 +83,16 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
List<ChatMessage> inputMessages = command.Messages.Select(WorkflowTranscriptProjector.ToChatMessage).ToList();
WorkflowTranscriptProjector.AttachMessageMode(inputMessages, command.MessageMode);
await using StreamingRun run = await InProcessExecution.RunStreamingAsync(workflow, inputMessages).ConfigureAwait(false);
using FileSystemJsonCheckpointStore? checkpointStore = CreateCheckpointStore(command);
CheckpointManager? checkpointManager = checkpointStore is not null
? CheckpointManager.CreateJson(checkpointStore)
: null;
await using StreamingRun run = await OpenWorkflowRunAsync(
command,
workflow,
inputMessages,
checkpointManager).ConfigureAwait(false);
await run.TrySendMessageAsync(new TurnToken(emitEvents: true)).ConfigureAwait(false);
await foreach (WorkflowEvent evt in run.WatchStreamAsync(runCancellation.Token).ConfigureAwait(false))
@@ -120,6 +131,62 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
}
}
internal static FileSystemJsonCheckpointStore? CreateCheckpointStore(RunTurnCommandDto command)
{
if (!ShouldEnableWorkflowCheckpointing(command))
{
return null;
}
DirectoryInfo checkpointDirectory = new(GetCheckpointStorePath(command));
return new FileSystemJsonCheckpointStore(checkpointDirectory);
}
internal static bool ShouldEnableWorkflowCheckpointing(RunTurnCommandDto command)
{
ArgumentNullException.ThrowIfNull(command);
return string.Equals(command.Pattern.Mode, "handoff", StringComparison.OrdinalIgnoreCase);
}
internal static string GetCheckpointStorePath(RunTurnCommandDto command)
{
ArgumentNullException.ThrowIfNull(command);
if (!string.IsNullOrWhiteSpace(command.ResumeFromCheckpoint?.StorePath))
{
return command.ResumeFromCheckpoint.StorePath;
}
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
return Path.Combine(localAppData, "Aryx", "workflow-checkpoints", command.SessionId, command.RequestId);
}
private static ValueTask<StreamingRun> OpenWorkflowRunAsync(
RunTurnCommandDto command,
Workflow workflow,
IReadOnlyList<ChatMessage> inputMessages,
CheckpointManager? checkpointManager)
{
if (checkpointManager is not null && command.ResumeFromCheckpoint is { } resumeFromCheckpoint)
{
return InProcessExecution.ResumeStreamingAsync(
workflow,
new CheckpointInfo(resumeFromCheckpoint.WorkflowSessionId, resumeFromCheckpoint.CheckpointId),
checkpointManager);
}
if (checkpointManager is not null)
{
return InProcessExecution.RunStreamingAsync(
workflow,
inputMessages.ToList(),
checkpointManager,
sessionId: command.RequestId);
}
return InProcessExecution.RunStreamingAsync(workflow, inputMessages.ToList());
}
internal static void ConfigureHookLifecycleEventSuppression(
CopilotTurnExecutionState state,
CopilotAgentBundle bundle)
@@ -211,6 +278,18 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
return false;
}
if (TryCreateWorkflowCheckpointSavedEvent(command, evt, out WorkflowCheckpointSavedEventDto? checkpointSaved))
{
await onEvent(checkpointSaved).ConfigureAwait(false);
return false;
}
if (TryCreateWorkflowDiagnosticEvent(command, evt, state, out WorkflowDiagnosticEventDto? diagnostic))
{
await onEvent(diagnostic).ConfigureAwait(false);
return false;
}
if (evt is AgentResponseUpdateEvent update)
{
await HandleAgentResponseUpdateAsync(command, update, state, onDelta, onEvent).ConfigureAwait(false);
@@ -274,6 +353,14 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
updateAgent = resolvedUpdateAgent;
authorName = resolvedUpdateAgent.AgentName;
}
else if (state.ActiveAgent is AgentIdentity activeAgent)
{
updateAgent = activeAgent;
authorName = activeAgent.AgentName;
TraceHandoff(
command,
$"Agent response update fell back to active agent {activeAgent.AgentName} ({activeAgent.AgentId}) for executor '{update.ExecutorId}' and message '{update.Update.MessageId ?? "<none>"}'.");
}
if (updateAgent.HasValue)
{
@@ -341,6 +428,121 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
}
}
internal static bool TryCreateWorkflowCheckpointSavedEvent(
RunTurnCommandDto command,
WorkflowEvent evt,
out WorkflowCheckpointSavedEventDto checkpointSaved)
{
checkpointSaved = default!;
if (!ShouldEnableWorkflowCheckpointing(command)
|| evt is not SuperStepCompletedEvent superStepCompleted
|| superStepCompleted.CompletionInfo?.Checkpoint is not CheckpointInfo checkpoint)
{
return false;
}
checkpointSaved = new WorkflowCheckpointSavedEventDto
{
Type = "workflow-checkpoint-saved",
RequestId = command.RequestId,
SessionId = command.SessionId,
WorkflowSessionId = checkpoint.SessionId,
CheckpointId = checkpoint.CheckpointId,
StorePath = GetCheckpointStorePath(command),
StepNumber = superStepCompleted.StepNumber,
};
return true;
}
private static bool TryCreateWorkflowDiagnosticEvent(
RunTurnCommandDto command,
WorkflowEvent evt,
CopilotTurnExecutionState state,
out WorkflowDiagnosticEventDto diagnostic)
{
diagnostic = default!;
switch (evt)
{
case ExecutorFailedEvent executorFailed:
{
AgentIdentity? agent = AgentIdentityResolver.TryResolveObservedAgentIdentity(
command.Pattern,
executorFailed.ExecutorId,
state.ActiveAgent,
out AgentIdentity resolvedAgent)
? resolvedAgent
: null;
Exception? exception = executorFailed.Data;
diagnostic = new WorkflowDiagnosticEventDto
{
Type = "workflow-diagnostic",
RequestId = command.RequestId,
SessionId = command.SessionId,
Severity = "error",
DiagnosticKind = "executor-failed",
Message = ResolveDiagnosticMessage(exception, "Executor failed."),
AgentId = agent?.AgentId,
AgentName = agent?.AgentName,
ExecutorId = executorFailed.ExecutorId,
ExceptionType = exception?.GetBaseException().GetType().Name,
};
return true;
}
case WorkflowWarningEvent workflowWarning:
diagnostic = new WorkflowDiagnosticEventDto
{
Type = "workflow-diagnostic",
RequestId = command.RequestId,
SessionId = command.SessionId,
Severity = "warning",
DiagnosticKind = workflowWarning is SubworkflowWarningEvent
? "subworkflow-warning"
: "workflow-warning",
Message = ResolveDiagnosticMessage(workflowWarning.Data as string, "Workflow warning."),
SubworkflowId = workflowWarning is SubworkflowWarningEvent subworkflowWarning
? subworkflowWarning.SubWorkflowId
: null,
};
return true;
case WorkflowErrorEvent workflowError:
{
Exception? exception = workflowError.Exception;
diagnostic = new WorkflowDiagnosticEventDto
{
Type = "workflow-diagnostic",
RequestId = command.RequestId,
SessionId = command.SessionId,
Severity = "error",
DiagnosticKind = workflowError is SubworkflowErrorEvent
? "subworkflow-error"
: "workflow-error",
Message = ResolveDiagnosticMessage(exception, "Workflow failed."),
SubworkflowId = workflowError is SubworkflowErrorEvent subworkflowError
? subworkflowError.SubworkflowId
: null,
ExceptionType = exception?.GetBaseException().GetType().Name,
};
return true;
}
default:
return false;
}
}
private static string ResolveDiagnosticMessage(Exception? exception, string fallback)
{
return ResolveDiagnosticMessage(
exception?.GetBaseException().Message,
fallback);
}
private static string ResolveDiagnosticMessage(string? message, string fallback)
{
return string.IsNullOrWhiteSpace(message) ? fallback : message;
}
private static bool IsHandoffFunctionName(string? candidate)
{
return !string.IsNullOrWhiteSpace(candidate)
@@ -8,11 +8,15 @@ internal static class HandoffWorkflowGuidance
{
return """
This workflow uses explicit handoffs to transfer ownership between agents.
If you are acting as the routing or triage agent, classify the request and hand it off to the best specialist as soon as ownership is clear.
If another agent should do the substantive work, perform an actual handoff instead of answering as though the handoff already happened.
For any substantive task, your next meaningful action must be the actual handoff rather than a plain-text promise to delegate later.
Do not claim that you delegated unless you actually executed the handoff.
The triage agent should route to the best specialist promptly once ownership is clear.
In a specialist workflow, the triage agent should hand off before inspecting files, calling tools, or drafting the substantive implementation.
If a specialist is appropriate, do not inspect files, call tools, draft the implementation, or produce the final user-facing answer before handing off.
Only answer directly when the request is pure triage or a minimal clarification is required before delegation.
Do not narrate a handoff in plain text without executing the handoff itself.
If you receive work as a specialist, own the substantive answer within your specialty and carry it through.
Do not push the work back to triage unless you are blocked or the request is clearly outside your specialty.
Specialists should complete the substantive work after handoff and only hand control back when the task needs re-routing, broader coordination, or is outside their specialty.
""";
}
@@ -0,0 +1,149 @@
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
namespace Aryx.AgentHost.Services;
internal sealed class WorkflowOutputMessagesExecutor(ChatProtocolExecutorOptions? options = null)
: ChatProtocolExecutor(ExecutorId, options, declareCrossRunShareable: true), IResettableExecutor
{
public const string ExecutorId = "OutputMessages";
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
=> base.ConfigureProtocol(protocolBuilder)
.YieldsOutput<List<ChatMessage>>();
protected override ValueTask TakeTurnAsync(
List<ChatMessage> messages,
IWorkflowContext context,
bool? emitEvents,
CancellationToken cancellationToken = default)
=> context.YieldOutputAsync(messages, cancellationToken);
ValueTask IResettableExecutor.ResetAsync() => default;
}
internal sealed class WorkflowAggregateTurnMessagesExecutor(string id)
: ChatProtocolExecutor(id, s_options, declareCrossRunShareable: true), IResettableExecutor
{
private static readonly ChatProtocolExecutorOptions s_options = new() { AutoSendTurnToken = false };
protected override ValueTask TakeTurnAsync(
List<ChatMessage> messages,
IWorkflowContext context,
bool? emitEvents,
CancellationToken cancellationToken = default)
=> context.SendMessageAsync(messages, cancellationToken: cancellationToken);
ValueTask IResettableExecutor.ResetAsync() => this.ResetAsync();
}
internal sealed class WorkflowConcurrentEndExecutor : Executor, IResettableExecutor
{
public const string ExecutorId = "ConcurrentEnd";
private readonly int _expectedInputs;
private readonly Func<IList<List<ChatMessage>>, List<ChatMessage>> _aggregator;
private List<List<ChatMessage>> _allResults;
private int _remaining;
public WorkflowConcurrentEndExecutor(
int expectedInputs,
Func<IList<List<ChatMessage>>, List<ChatMessage>> aggregator)
: base(ExecutorId)
{
_expectedInputs = expectedInputs;
_aggregator = aggregator;
_allResults = new List<List<ChatMessage>>(expectedInputs);
_remaining = expectedInputs;
}
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
{
protocolBuilder.RouteBuilder.AddHandler<List<ChatMessage>>(async (messages, context, cancellationToken) =>
{
bool done;
lock (_allResults)
{
_allResults.Add(messages);
done = --_remaining == 0;
}
if (!done)
{
return;
}
_remaining = _expectedInputs;
List<List<ChatMessage>> results = _allResults;
_allResults = new List<List<ChatMessage>>(_expectedInputs);
await context.YieldOutputAsync(_aggregator(results), cancellationToken).ConfigureAwait(false);
});
return protocolBuilder.YieldsOutput<List<ChatMessage>>();
}
public ValueTask ResetAsync()
{
_allResults = new List<List<ChatMessage>>(_expectedInputs);
_remaining = _expectedInputs;
return default;
}
}
internal sealed class WorkflowRoundRobinGroupChatHost(
string id,
AIAgent[] agents,
Dictionary<AIAgent, ExecutorBinding> agentMap,
int maximumIterations)
: ChatProtocolExecutor(id, s_options), IResettableExecutor
{
private static readonly ChatProtocolExecutorOptions s_options = new()
{
StringMessageChatRole = ChatRole.User,
AutoSendTurnToken = false,
};
private readonly AIAgent[] _agents = agents;
private readonly Dictionary<AIAgent, ExecutorBinding> _agentMap = agentMap;
private readonly int _maximumIterations = maximumIterations;
private int _iterationCount;
private int _nextIndex;
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
=> base.ConfigureProtocol(protocolBuilder).YieldsOutput<List<ChatMessage>>();
protected override async ValueTask TakeTurnAsync(
List<ChatMessage> messages,
IWorkflowContext context,
bool? emitEvents,
CancellationToken cancellationToken = default)
{
if (_iterationCount < _maximumIterations)
{
AIAgent nextAgent = _agents[_nextIndex];
_nextIndex = (_nextIndex + 1) % _agents.Length;
if (_agentMap.TryGetValue(nextAgent, out ExecutorBinding? executor))
{
_iterationCount++;
await context.SendMessageAsync(messages, executor.Id, cancellationToken).ConfigureAwait(false);
await context.SendMessageAsync(new TurnToken(emitEvents), executor.Id, cancellationToken).ConfigureAwait(false);
return;
}
}
_iterationCount = 0;
_nextIndex = 0;
await context.YieldOutputAsync(messages, cancellationToken).ConfigureAwait(false);
}
protected override ValueTask ResetAsync()
{
_iterationCount = 0;
_nextIndex = 0;
return base.ResetAsync();
}
ValueTask IResettableExecutor.ResetAsync() => this.ResetAsync();
}
@@ -57,12 +57,17 @@ internal static class WorkflowRequestInfoInterpreter
};
}
private static AgentActivityEventDto CreateToolCallingActivity(
private static AgentActivityEventDto? CreateToolCallingActivity(
RunTurnCommandDto command,
AgentIdentity activeAgent,
ToolRequestInterpretation tool,
ConcurrentDictionary<string, string> toolNamesByCallId)
{
if (tool.ToolCallId is not null && toolNamesByCallId.ContainsKey(tool.ToolCallId))
{
return null;
}
TrackToolCallId(toolNamesByCallId, tool.ToolCallId, tool.ToolName);
return new AgentActivityEventDto
@@ -54,7 +54,7 @@ public sealed class AgentInstructionComposerTests
}
[Fact]
public void Compose_StrengthensHandoffTriageInstructions()
public void Compose_LeavesHandoffTriagePromptFocusedOnAgentInstructions()
{
PatternDefinitionDto pattern = new()
{
@@ -70,14 +70,13 @@ public sealed class AgentInstructionComposerTests
string instructions = AgentInstructionComposer.Compose(pattern, triage, agentIndex: 0);
Assert.Contains("routing gate", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not inspect files", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("actual handoff", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not claim that you handed work off", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Equal("You triage requests and must hand them off to the most appropriate specialist.", instructions);
Assert.DoesNotContain("routing", instructions, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("actual handoff", instructions, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void Compose_StrengthensHandoffSpecialistInstructions()
public void Compose_LeavesHandoffSpecialistPromptFocusedOnAgentInstructions()
{
PatternDefinitionDto pattern = new()
{
@@ -93,8 +92,9 @@ public sealed class AgentInstructionComposerTests
string instructions = AgentInstructionComposer.Compose(pattern, specialist, agentIndex: 1);
Assert.Contains("Once the triage agent hands work to you", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("own the substantive answer", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Equal("You focus on navigation, UX, and interaction details.", instructions);
Assert.DoesNotContain("triage agent", instructions, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("substantive answer", instructions, StringComparison.OrdinalIgnoreCase);
}
[Fact]
@@ -4,6 +4,7 @@ using Aryx.AgentHost.Contracts;
using GitHub.Copilot.SDK;
using Aryx.AgentHost.Services;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
namespace Aryx.AgentHost.Tests;
@@ -111,6 +112,54 @@ public sealed class CopilotAgentBundleTests
Assert.Throws<NotSupportedException>(() => AryxCopilotAgent.CreateConfiguredSessionConfig(new SessionConfig(), options));
}
[Fact]
public void CreateHandoffWorkflowBuilder_ExplicitlyUsesHandoffOnlyFiltering()
{
ChatClientAgent entryAgent = CreateChatClientAgent("agent-1", "Primary");
HandoffsWorkflowBuilder builder = CopilotAgentBundle.CreateHandoffWorkflowBuilder(entryAgent);
FieldInfo field = typeof(HandoffsWorkflowBuilder).GetField(
"_toolCallFilteringBehavior",
BindingFlags.Instance | BindingFlags.NonPublic)
?? throw new InvalidOperationException("Expected HandoffsWorkflowBuilder to expose a filtering field.");
HandoffToolCallFilteringBehavior behavior = Assert.IsType<HandoffToolCallFilteringBehavior>(field.GetValue(builder));
Assert.Equal(HandoffToolCallFilteringBehavior.HandoffOnly, behavior);
Assert.Equal(HandoffWorkflowGuidance.CreateWorkflowInstructions(), builder.HandoffInstructions);
}
[Theory]
[InlineData("single", 1)]
[InlineData("sequential", 2)]
[InlineData("concurrent", 2)]
[InlineData("group-chat", 2)]
public void BuildWorkflow_ExplicitlyConfiguresAgentHostOptions(string mode, int agentCount)
{
CopilotAgentBundle bundle = new(CreateAgents(agentCount), hasConfiguredHooks: false);
PatternDefinitionDto pattern = CreatePattern(mode, agentCount);
Workflow workflow = bundle.BuildWorkflow(pattern);
AIAgentBinding[] bindings = workflow.ReflectExecutors().Values
.OfType<AIAgentBinding>()
.ToArray();
Assert.Equal(agentCount, bindings.Length);
foreach (AIAgentBinding binding in bindings)
{
AIAgentHostOptions options = Assert.IsType<AIAgentHostOptions>(binding.Options);
Assert.Null(options.EmitAgentUpdateEvents);
Assert.False(options.EmitAgentResponseEvents);
Assert.False(options.InterceptUserInputRequests);
Assert.False(options.InterceptUnterminatedFunctionCalls);
Assert.True(options.ReassignOtherAgentsAsUsers);
Assert.True(options.ForwardIncomingMessages);
}
}
[Fact]
public void ConvertToolRequestsToFunctionCalls_MapsCallIdsNamesAndArguments()
{
@@ -136,7 +185,7 @@ public sealed class CopilotAgentBundleTests
}
[Fact]
public void ConvertToolRequestsToFunctionCalls_SkipsNonHandoffToolCalls()
public void ConvertToolRequestsToFunctionCalls_MapsNonHandoffToolCalls()
{
AssistantMessageDataToolRequestsItem[] toolRequests =
{
@@ -148,9 +197,99 @@ public sealed class CopilotAgentBundleTests
IReadOnlyList<FunctionCallContent> result = AryxCopilotAgent.ConvertToolRequestsToFunctionCalls(toolRequests);
FunctionCallContent single = Assert.Single(result);
Assert.Equal("call-003", single.CallId);
Assert.Equal("handoff_to_reviewer", single.Name);
Assert.Collection(
result,
functionCall =>
{
Assert.Equal("call-001", functionCall.CallId);
Assert.Equal("ask_user", functionCall.Name);
},
functionCall =>
{
Assert.Equal("call-002", functionCall.CallId);
Assert.Equal("web_fetch", functionCall.Name);
},
functionCall =>
{
Assert.Equal("call-003", functionCall.CallId);
Assert.Equal("handoff_to_reviewer", functionCall.Name);
},
functionCall =>
{
Assert.Equal("call-004", functionCall.CallId);
Assert.Equal("grep", functionCall.Name);
});
}
[Fact]
public void TryCreateToolResultContent_UsesSdkResultContentForNonHandoffTools()
{
ToolExecutionCompleteEvent toolExecutionComplete = new()
{
Data = new ToolExecutionCompleteData
{
ToolCallId = "call-123",
Success = true,
Result = new ToolExecutionCompleteDataResult
{
Content = "Search complete.",
DetailedContent = "Search complete with extra context.",
},
},
};
FunctionResultContent? toolResult = AryxCopilotAgent.TryCreateToolResultContent(toolExecutionComplete, "rg");
Assert.NotNull(toolResult);
Assert.Equal("call-123", toolResult.CallId);
Assert.Equal("Search complete.", Assert.IsType<string>(toolResult.Result));
Assert.Same(toolExecutionComplete, toolResult.RawRepresentation);
}
[Fact]
public void TryCreateToolResultContent_UsesSdkErrorMessageForFailedTools()
{
ToolExecutionCompleteEvent toolExecutionComplete = new()
{
Data = new ToolExecutionCompleteData
{
ToolCallId = "call-456",
Success = false,
Error = new ToolExecutionCompleteDataError
{
Message = "Permission denied.",
},
},
};
FunctionResultContent? toolResult = AryxCopilotAgent.TryCreateToolResultContent(toolExecutionComplete, "view");
Assert.NotNull(toolResult);
Assert.Equal("call-456", toolResult.CallId);
Assert.Equal("Permission denied.", Assert.IsType<string>(toolResult.Result));
}
[Fact]
public void TryCreateToolResultContent_SkipsHandoffTools()
{
ToolExecutionCompleteEvent toolExecutionComplete = new()
{
Data = new ToolExecutionCompleteData
{
ToolCallId = "call-789",
Success = true,
Result = new ToolExecutionCompleteDataResult
{
Content = "Transferred.",
},
},
};
FunctionResultContent? toolResult = AryxCopilotAgent.TryCreateToolResultContent(
toolExecutionComplete,
"handoff_to_reviewer");
Assert.Null(toolResult);
}
[Fact]
@@ -369,8 +508,75 @@ public sealed class CopilotAgentBundleTests
CreateTool().JsonSchema);
}
private static IReadOnlyList<AIAgent> CreateAgents(int count)
=> Enumerable.Range(1, count)
.Select(index => (AIAgent)CreateChatClientAgent($"agent-{index}", $"Agent {index}"))
.ToArray();
private static PatternDefinitionDto CreatePattern(string mode, int agentCount)
{
return new PatternDefinitionDto
{
Id = $"pattern-{mode}",
Name = $"Pattern {mode}",
Mode = mode,
Availability = "available",
Agents =
[
.. Enumerable.Range(1, agentCount).Select(index => new PatternAgentDefinitionDto
{
Id = $"agent-{index}",
Name = $"Agent {index}",
Description = $"Agent {index} description.",
Instructions = $"Agent {index} instructions.",
Model = "gpt-5.4",
}),
],
};
}
private static ChatClientAgent CreateChatClientAgent(string id, string name)
{
return new ChatClientAgent(
new StubChatClient(),
id,
name,
"Stub agent for handoff builder tests.",
[],
null!,
null!);
}
private sealed class ToolTarget
{
public string Echo() => "ok";
}
private sealed class StubChatClient : IChatClient
{
public void Dispose()
{
}
public Task<ChatResponse> GetResponseAsync(
IEnumerable<ChatMessage> messages,
ChatOptions? options,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
public object? GetService(Type serviceType, object? serviceKey = null)
{
return null;
}
public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
IEnumerable<ChatMessage> messages,
ChatOptions? options,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
}
}
@@ -108,11 +108,19 @@ public sealed class CopilotSessionHooksTests
[Theory]
[InlineData("ask_user")]
[InlineData("exit_plan_mode")]
[InlineData("fetch_copilot_cli_documentation")]
[InlineData("list_agents")]
[InlineData("read_agent")]
[InlineData("report_intent")]
[InlineData("skill")]
[InlineData("sql")]
[InlineData("task")]
[InlineData("task_complete")]
[InlineData("update_todo")]
[InlineData("handoff_to_2")]
[InlineData("handoff_to_specialist")]
public async Task Create_PreToolUseAutoAllowsInfrastructureTools(string toolName)
public async Task Create_PreToolUseAutoAllowsInternalOrchestrationTools(string toolName)
{
RunTurnCommandDto command = CreateCommandWithToolApproval();
SessionHooks hooks = CopilotSessionHooks.Create(command, command.Pattern.Agents[0], ResolvedHookSet.Empty, new RecordingHookCommandRunner());
@@ -127,6 +135,76 @@ public sealed class CopilotSessionHooksTests
Assert.Equal("allow", decision?.PermissionDecision);
}
[Fact]
public async Task Create_PreToolUseKeepsStoreMemoryUnderApprovalPolicy()
{
RunTurnCommandDto command = CreateCommandWithToolApproval();
SessionHooks hooks = CopilotSessionHooks.Create(command, command.Pattern.Agents[0], ResolvedHookSet.Empty, new RecordingHookCommandRunner());
PreToolUseHookOutput? decision = await hooks.OnPreToolUse!(
new PreToolUseHookInput
{
ToolName = "store_memory",
},
null!);
Assert.Equal("ask", decision?.PermissionDecision);
}
[Theory]
[InlineData("view", "read")]
[InlineData("grep", "read")]
[InlineData("edit", "write")]
[InlineData("powershell", "shell")]
public async Task Create_PreToolUseAutoAllowsWhenCategoryIsApproved(string toolName, string category)
{
RunTurnCommandDto command = CreateCommandWithAutoApprovedCategory(category);
SessionHooks hooks = CopilotSessionHooks.Create(command, command.Pattern.Agents[0], ResolvedHookSet.Empty, new RecordingHookCommandRunner());
PreToolUseHookOutput? decision = await hooks.OnPreToolUse!(
new PreToolUseHookInput
{
ToolName = toolName,
},
null!);
Assert.Equal("allow", decision?.PermissionDecision);
}
[Fact]
public async Task Create_PreToolUseAutoAllowsWhenMcpServerIsApproved()
{
RunTurnCommandDto command = CreateCommandWithConfiguredMcpServers(
["icm-mcp"],
["mcp_server:icm-mcp"]);
SessionHooks hooks = CopilotSessionHooks.Create(command, command.Pattern.Agents[0], ResolvedHookSet.Empty, new RecordingHookCommandRunner());
PreToolUseHookOutput? decision = await hooks.OnPreToolUse!(
new PreToolUseHookInput
{
ToolName = "icm-mcp-get_incident_details_by_id",
},
null!);
Assert.Equal("allow", decision?.PermissionDecision);
}
[Fact]
public async Task Create_PreToolUseRequiresApprovalWhenMcpServerIsNotApproved()
{
RunTurnCommandDto command = CreateCommandWithConfiguredMcpServers(["icm-mcp"]);
SessionHooks hooks = CopilotSessionHooks.Create(command, command.Pattern.Agents[0], ResolvedHookSet.Empty, new RecordingHookCommandRunner());
PreToolUseHookOutput? decision = await hooks.OnPreToolUse!(
new PreToolUseHookInput
{
ToolName = "icm-mcp-get_incident_details_by_id",
},
null!);
Assert.Equal("ask", decision?.PermissionDecision);
}
[Fact]
public async Task Create_RunsConfiguredNonPreToolHooks()
{
@@ -285,6 +363,82 @@ public sealed class CopilotSessionHooksTests
};
}
private static RunTurnCommandDto CreateCommandWithAutoApprovedCategory(string category)
{
return new RunTurnCommandDto
{
RequestId = "turn-1",
SessionId = "session-1",
ProjectPath = @"C:\workspace\project",
Pattern = new PatternDefinitionDto
{
Id = "pattern-1",
Name = "Pattern",
Mode = "single",
Availability = "available",
ApprovalPolicy = new ApprovalPolicyDto
{
Rules =
[
new ApprovalCheckpointRuleDto
{
Kind = "tool-call",
AgentIds = ["agent-1"],
},
],
AutoApprovedToolNames = [category],
},
Agents =
[
new PatternAgentDefinitionDto
{
Id = "agent-1",
Name = "Primary",
Model = "gpt-5.4",
Instructions = "Help.",
},
],
},
};
}
private static RunTurnCommandDto CreateCommandWithConfiguredMcpServers(
IReadOnlyList<string> serverNames,
IReadOnlyList<string>? autoApprovedToolNames = null)
{
RunTurnCommandDto command = CreateCommandWithToolApproval();
return new RunTurnCommandDto
{
RequestId = command.RequestId,
SessionId = command.SessionId,
ProjectPath = command.ProjectPath,
Tooling = new RunTurnToolingConfigDto
{
McpServers = [.. serverNames.Select(CreateMcpServerConfig)],
},
Pattern = new PatternDefinitionDto
{
Id = command.Pattern.Id,
Name = command.Pattern.Name,
Mode = command.Pattern.Mode,
Availability = command.Pattern.Availability,
ApprovalPolicy = new ApprovalPolicyDto
{
Rules = command.Pattern.ApprovalPolicy?.Rules ?? [],
AutoApprovedToolNames = autoApprovedToolNames ?? [],
},
Agents = command.Pattern.Agents,
},
};
}
private static RunTurnMcpServerConfigDto CreateMcpServerConfig(string serverName)
=> new()
{
Id = serverName,
Name = serverName,
};
private static HookCommandDefinition CreateHookCommand(string name)
=> new()
{
@@ -1,6 +1,7 @@
using Aryx.AgentHost.Contracts;
using Aryx.AgentHost.Services;
using GitHub.Copilot.SDK;
using Microsoft.Extensions.AI;
namespace Aryx.AgentHost.Tests;
@@ -59,7 +60,42 @@ public sealed class CopilotTurnExecutionStateTests
}
[Fact]
public void ObserveSessionEvent_ToolExecutionStart_TracksToolNameByCallId()
public void ObserveSessionEvent_ToolExecutionStart_TracksToolNameByCallIdAndQueuesToolActivity()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""{"type":"tool.execution_start","data":{"toolCallId":"tool-call-1","toolName":"view"},"id":"33333333-3333-3333-3333-333333333333","timestamp":"2026-03-27T00:00:00Z"}"""));
AgentActivityEventDto toolActivity = Assert.Single(state.DrainPendingEvents().OfType<AgentActivityEventDto>());
Assert.Equal("tool-calling", toolActivity.ActivityType);
Assert.Equal("view", toolActivity.ToolName);
Assert.Equal("tool-call-1", toolActivity.ToolCallId);
Assert.True(state.ToolNamesByCallId.TryGetValue("tool-call-1", out string? toolName));
Assert.Equal("view", toolName);
}
[Fact]
public void ObserveSessionEvent_ToolExecutionStart_DoesNotQueueToolActivityForHandoffTools()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""{"type":"tool.execution_start","data":{"toolCallId":"tool-call-1","toolName":"handoff_to_specialist"},"id":"1ce9d1dc-68f1-4df5-9728-f97017233279","timestamp":"2026-03-27T00:00:00Z"}"""));
Assert.Empty(state.DrainPendingEvents().OfType<AgentActivityEventDto>());
Assert.True(state.ToolNamesByCallId.TryGetValue("tool-call-1", out string? toolName));
Assert.Equal("handoff_to_specialist", toolName);
}
[Fact]
public void ObserveSessionEvent_AssistantMessageWithToolRequests_QueuesMessageReclassifiedEvent()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
@@ -69,18 +105,123 @@ public sealed class CopilotTurnExecutionStateTests
SessionEvent.FromJson(
"""
{
"type": "tool.execution_start",
"type": "assistant.message",
"data": {
"toolCallId": "tool-call-1",
"toolName": "view"
"messageId": "msg-2",
"content": "Let me search for that.",
"toolRequests": [
{
"toolCallId": "tool-call-1",
"name": "rg",
"arguments": {
"pattern": "identifierUri"
}
}
]
},
"id": "33333333-3333-3333-3333-333333333333",
"id": "3f75988b-8e69-4c90-a203-6b01d1c1f90b",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
Assert.True(state.ToolNamesByCallId.TryGetValue("tool-call-1", out string? toolName));
Assert.Equal("view", toolName);
IReadOnlyList<SidecarEventDto> pending = state.DrainPendingEvents();
AgentActivityEventDto thinking = Assert.Single(pending.OfType<AgentActivityEventDto>());
Assert.Equal("thinking", thinking.ActivityType);
MessageReclassifiedEventDto reclassified = Assert.Single(pending.OfType<MessageReclassifiedEventDto>());
Assert.Equal("session-1", reclassified.SessionId);
Assert.Equal("msg-2", reclassified.MessageId);
Assert.Equal("thinking", reclassified.NewKind);
}
[Fact]
public void ObserveSessionEvent_ToolExecutionStart_ReclassifiesLastObservedMessageOnce()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "assistant.message_delta",
"data": {
"messageId": "msg-3",
"deltaContent": "Searching"
},
"id": "0b65f0e9-d0fb-417e-ab5c-7a3343d8581b",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
_ = state.DrainPendingEvents();
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "tool.execution_start",
"data": {
"toolCallId": "tool-call-1",
"toolName": "rg"
},
"id": "8f33240e-bd3f-475c-aeb6-a4b7908e47b0",
"timestamp": "2026-03-27T00:00:01Z"
}
"""));
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "tool.execution_start",
"data": {
"toolCallId": "tool-call-2",
"toolName": "view"
},
"id": "a23f9c9a-f947-4282-866d-f599451c3899",
"timestamp": "2026-03-27T00:00:02Z"
}
"""));
IReadOnlyList<SidecarEventDto> pending = state.DrainPendingEvents();
AgentActivityEventDto[] toolActivities = [.. pending.OfType<AgentActivityEventDto>().Where(activity => activity.ActivityType == "tool-calling")];
Assert.Equal(2, toolActivities.Length);
Assert.Contains(toolActivities, activity => activity.ToolCallId == "tool-call-1" && activity.ToolName == "rg");
Assert.Contains(toolActivities, activity => activity.ToolCallId == "tool-call-2" && activity.ToolName == "view");
MessageReclassifiedEventDto reclassified = Assert.Single(pending.OfType<MessageReclassifiedEventDto>());
Assert.Equal("msg-3", reclassified.MessageId);
Assert.True(state.ToolNamesByCallId.TryGetValue("tool-call-1", out string? firstToolName));
Assert.Equal("rg", firstToolName);
Assert.True(state.ToolNamesByCallId.TryGetValue("tool-call-2", out string? secondToolName));
Assert.Equal("view", secondToolName);
}
[Fact]
public void ObserveSessionEvent_AssistantMessageWithoutToolRequests_DoesNotQueueMessageReclassifiedEvent()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "assistant.message",
"data": {
"messageId": "msg-4",
"content": "Final answer."
},
"id": "d07fe954-1258-4f6a-bf79-1550d6143ed0",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
Assert.Empty(state.DrainPendingEvents().OfType<MessageReclassifiedEventDto>());
}
[Fact]
@@ -119,6 +260,70 @@ public sealed class CopilotTurnExecutionStateTests
Assert.Equal("agent-1", thinking.AgentId);
}
[Fact]
public void ObserveSessionEvent_AssistantIntent_QueuesIntentEvent()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "assistant.intent",
"data": {
"intent": "Searching incident playbooks"
},
"id": "64cf59fe-63f0-4217-adf4-9bd6b3a80452",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
IReadOnlyList<SidecarEventDto> pending = state.DrainPendingEvents();
AgentActivityEventDto thinking = Assert.Single(pending.OfType<AgentActivityEventDto>());
Assert.Equal("thinking", thinking.ActivityType);
AssistantIntentEventDto intent = Assert.Single(pending.OfType<AssistantIntentEventDto>());
Assert.Equal("session-1", intent.SessionId);
Assert.Equal("agent-1", intent.AgentId);
Assert.Equal("Searching incident playbooks", intent.Intent);
}
[Fact]
public void ObserveSessionEvent_AssistantReasoningDelta_QueuesReasoningDeltaEvent()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "assistant.reasoning_delta",
"data": {
"reasoningId": "reasoning-2",
"deltaContent": "Searching logs."
},
"id": "bd269258-5e5d-46b6-bf3f-bd8cba793b1a",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
IReadOnlyList<SidecarEventDto> pending = state.DrainPendingEvents();
AgentActivityEventDto thinking = Assert.Single(pending.OfType<AgentActivityEventDto>());
Assert.Equal("thinking", thinking.ActivityType);
ReasoningDeltaEventDto reasoning = Assert.Single(pending.OfType<ReasoningDeltaEventDto>());
Assert.Equal("session-1", reasoning.SessionId);
Assert.Equal("agent-1", reasoning.AgentId);
Assert.Equal("reasoning-2", reasoning.ReasoningId);
Assert.Equal("Searching logs.", reasoning.ContentDelta);
}
[Fact]
public void DrainPendingMcpOauthRequests_ReturnsQueuedRequestsAndClearsQueue()
{
@@ -411,6 +616,56 @@ public sealed class CopilotTurnExecutionStateTests
""");
}
[Fact]
public void FinalizeCompletedMessages_TagsReclassifiedMessagesAsThinking()
{
RunTurnCommandDto command = CreateCommand();
CopilotTurnExecutionState state = new(command);
// Simulate assistant message with tool requests → triggers reclassification
state.ObserveSessionEvent(
command.Pattern.Agents[0],
SessionEvent.FromJson(
"""
{
"type": "assistant.message",
"data": {
"messageId": "msg-intermediate",
"content": "Let me search...",
"toolRequests": [
{
"toolCallId": "tool-call-1",
"name": "grep",
"arguments": {}
}
]
},
"id": "11111111-1111-1111-1111-111111111111",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
state.DrainPendingEvents();
// Build completed messages with a reclassified and a non-reclassified message
ChatMessage intermediateMsg = new(ChatRole.Assistant, "Let me search...");
intermediateMsg.MessageId = "msg-intermediate";
intermediateMsg.AuthorName = "Primary";
ChatMessage finalMsg = new(ChatRole.Assistant, "Here are the results.");
finalMsg.MessageId = "msg-final";
finalMsg.AuthorName = "Primary";
state.UpdateCompletedMessages([intermediateMsg, finalMsg], []);
IReadOnlyList<ChatMessageDto> messages = state.FinalizeCompletedMessages();
ChatMessageDto intermediate = Assert.Single(messages, m => m.Id == "msg-intermediate");
Assert.Equal("thinking", intermediate.MessageKind);
ChatMessageDto final_ = Assert.Single(messages, m => m.Id == "msg-final");
Assert.Null(final_.MessageKind);
}
private static RunTurnCommandDto CreateCommand()
{
return new RunTurnCommandDto
@@ -1,3 +1,4 @@
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using Aryx.AgentHost.Contracts;
@@ -798,6 +799,216 @@ public sealed class CopilotWorkflowRunnerTests
});
}
[Fact]
public async Task HandleWorkflowEventAsync_FallsBackToActiveAgentForUnresolvedStreamingUpdates()
{
RunTurnCommandDto command = CreateHandoffCommand();
CopilotTurnExecutionState state = new(command);
state.ObserveSessionEvent(
CreateAgent("agent-handoff-ux", "UX Specialist"),
SessionEvent.FromJson(
"""
{
"type": "assistant.reasoning_delta",
"data": {
"reasoningId": "reasoning-1",
"deltaContent": "Polishing the UI."
},
"id": "77777777-7777-7777-7777-777777777777",
"timestamp": "2026-03-27T00:00:00Z"
}
"""));
_ = state.DrainPendingEvents();
List<TurnDeltaEventDto> deltas = [];
MethodInfo handleWorkflowEvent = typeof(CopilotWorkflowRunner).GetMethod(
"HandleWorkflowEventAsync",
BindingFlags.NonPublic | BindingFlags.Static)!;
Task<bool> handleTask = (Task<bool>)handleWorkflowEvent.Invoke(
null,
[
command,
new AgentResponseUpdateEvent(
"copilot-executor-ux",
new AgentResponseUpdate(ChatRole.Assistant, "The button is ready.")
{
MessageId = "msg-ux-1",
}),
Array.Empty<ChatMessage>(),
state,
(Func<TurnDeltaEventDto, Task>)(delta =>
{
deltas.Add(delta);
return Task.CompletedTask;
}),
(Func<SidecarEventDto, Task>)(_ => Task.CompletedTask),
])!;
bool shouldEndTurn = await handleTask;
Assert.False(shouldEndTurn);
TurnDeltaEventDto delta = Assert.Single(deltas);
Assert.Equal("msg-ux-1", delta.MessageId);
Assert.Equal("UX Specialist", delta.AuthorName);
Assert.Equal("The button is ready.", delta.ContentDelta);
Assert.Equal("The button is ready.", delta.Content);
}
[Fact]
public async Task HandleWorkflowEventAsync_EmitsWorkflowCheckpointSavedEvent()
{
RunTurnCommandDto command = CreateHandoffCommand();
CopilotTurnExecutionState state = new(command);
List<WorkflowCheckpointSavedEventDto> checkpoints = [];
MethodInfo handleWorkflowEvent = typeof(CopilotWorkflowRunner).GetMethod(
"HandleWorkflowEventAsync",
BindingFlags.NonPublic | BindingFlags.Static)!;
Task<bool> handleTask = (Task<bool>)handleWorkflowEvent.Invoke(
null,
[
command,
new SuperStepCompletedEvent(
3,
new SuperStepCompletionInfo([])
{
Checkpoint = new CheckpointInfo(command.RequestId, "checkpoint-1"),
}),
Array.Empty<ChatMessage>(),
state,
(Func<TurnDeltaEventDto, Task>)(_ => Task.CompletedTask),
(Func<SidecarEventDto, Task>)(sidecarEvent =>
{
checkpoints.Add(Assert.IsType<WorkflowCheckpointSavedEventDto>(sidecarEvent));
return Task.CompletedTask;
}),
])!;
bool shouldEndTurn = await handleTask;
Assert.False(shouldEndTurn);
WorkflowCheckpointSavedEventDto checkpoint = Assert.Single(checkpoints);
Assert.Equal("workflow-checkpoint-saved", checkpoint.Type);
Assert.Equal(command.SessionId, checkpoint.SessionId);
Assert.Equal(command.RequestId, checkpoint.WorkflowSessionId);
Assert.Equal("checkpoint-1", checkpoint.CheckpointId);
Assert.Equal(3, checkpoint.StepNumber);
Assert.EndsWith(
Path.Combine("Aryx", "workflow-checkpoints", command.SessionId, command.RequestId),
checkpoint.StorePath);
}
[Fact]
public async Task HandleWorkflowEventAsync_EmitsExecutorFailedDiagnostic()
{
RunTurnCommandDto command = CreateApprovalCommand();
CopilotTurnExecutionState state = new(command);
List<WorkflowDiagnosticEventDto> diagnostics = [];
MethodInfo handleWorkflowEvent = typeof(CopilotWorkflowRunner).GetMethod(
"HandleWorkflowEventAsync",
BindingFlags.NonPublic | BindingFlags.Static)!;
Task<bool> handleTask = (Task<bool>)handleWorkflowEvent.Invoke(
null,
[
command,
new ExecutorFailedEvent("agent-1", new InvalidOperationException("Tool crashed.")),
Array.Empty<ChatMessage>(),
state,
(Func<TurnDeltaEventDto, Task>)(_ => Task.CompletedTask),
(Func<SidecarEventDto, Task>)(sidecarEvent =>
{
diagnostics.Add(Assert.IsType<WorkflowDiagnosticEventDto>(sidecarEvent));
return Task.CompletedTask;
}),
])!;
bool shouldEndTurn = await handleTask;
Assert.False(shouldEndTurn);
WorkflowDiagnosticEventDto diagnostic = Assert.Single(diagnostics);
Assert.Equal("workflow-diagnostic", diagnostic.Type);
Assert.Equal("error", diagnostic.Severity);
Assert.Equal("executor-failed", diagnostic.DiagnosticKind);
Assert.Equal("Tool crashed.", diagnostic.Message);
Assert.Equal("agent-1", diagnostic.AgentId);
Assert.Equal("Primary", diagnostic.AgentName);
Assert.Equal("agent-1", diagnostic.ExecutorId);
Assert.Equal("InvalidOperationException", diagnostic.ExceptionType);
}
[Fact]
public async Task HandleWorkflowEventAsync_EmitsWorkflowWarningDiagnostic()
{
RunTurnCommandDto command = CreateApprovalCommand();
CopilotTurnExecutionState state = new(command);
List<WorkflowDiagnosticEventDto> diagnostics = [];
MethodInfo handleWorkflowEvent = typeof(CopilotWorkflowRunner).GetMethod(
"HandleWorkflowEventAsync",
BindingFlags.NonPublic | BindingFlags.Static)!;
Task<bool> handleTask = (Task<bool>)handleWorkflowEvent.Invoke(
null,
[
command,
new WorkflowWarningEvent("Token budget is nearly exhausted."),
Array.Empty<ChatMessage>(),
state,
(Func<TurnDeltaEventDto, Task>)(_ => Task.CompletedTask),
(Func<SidecarEventDto, Task>)(sidecarEvent =>
{
diagnostics.Add(Assert.IsType<WorkflowDiagnosticEventDto>(sidecarEvent));
return Task.CompletedTask;
}),
])!;
bool shouldEndTurn = await handleTask;
Assert.False(shouldEndTurn);
WorkflowDiagnosticEventDto diagnostic = Assert.Single(diagnostics);
Assert.Equal("warning", diagnostic.Severity);
Assert.Equal("workflow-warning", diagnostic.DiagnosticKind);
Assert.Equal("Token budget is nearly exhausted.", diagnostic.Message);
Assert.Null(diagnostic.SubworkflowId);
Assert.Null(diagnostic.ExceptionType);
}
[Fact]
public async Task HandleWorkflowEventAsync_EmitsSubworkflowErrorDiagnostic()
{
RunTurnCommandDto command = CreateApprovalCommand();
CopilotTurnExecutionState state = new(command);
List<WorkflowDiagnosticEventDto> diagnostics = [];
MethodInfo handleWorkflowEvent = typeof(CopilotWorkflowRunner).GetMethod(
"HandleWorkflowEventAsync",
BindingFlags.NonPublic | BindingFlags.Static)!;
Task<bool> handleTask = (Task<bool>)handleWorkflowEvent.Invoke(
null,
[
command,
new SubworkflowErrorEvent("subworkflow-review", new InvalidOperationException("Reviewer agent failed.")),
Array.Empty<ChatMessage>(),
state,
(Func<TurnDeltaEventDto, Task>)(_ => Task.CompletedTask),
(Func<SidecarEventDto, Task>)(sidecarEvent =>
{
diagnostics.Add(Assert.IsType<WorkflowDiagnosticEventDto>(sidecarEvent));
return Task.CompletedTask;
}),
])!;
bool shouldEndTurn = await handleTask;
Assert.False(shouldEndTurn);
WorkflowDiagnosticEventDto diagnostic = Assert.Single(diagnostics);
Assert.Equal("error", diagnostic.Severity);
Assert.Equal("subworkflow-error", diagnostic.DiagnosticKind);
Assert.Equal("Reviewer agent failed.", diagnostic.Message);
Assert.Equal("subworkflow-review", diagnostic.SubworkflowId);
Assert.Equal("InvalidOperationException", diagnostic.ExceptionType);
}
[Fact]
public void RequiresToolCallApproval_HonorsAutoApprovedToolNames()
{
@@ -1325,6 +1536,223 @@ public sealed class CopilotWorkflowRunnerTests
Assert.Equal("https://example.com", args["url"]);
}
[Fact]
public void BuildPermissionDetail_MapsConfiguredMcpHookToMcpDetail()
{
PermissionDetailDto detail = CopilotApprovalCoordinator.BuildPermissionDetail(
new PermissionRequestHook
{
Kind = "hook",
ToolName = "icm-mcp-get_incident_details_by_id",
ToolArgs = new Dictionary<string, object?>
{
["incidentId"] = 769904783,
},
},
[CreateMcpServerConfig("icm-mcp")]);
Assert.Equal("mcp", detail.Kind);
Assert.Equal("icm-mcp", detail.ServerName);
Assert.Equal("get_incident_details_by_id", detail.ToolTitle);
Dictionary<string, object?> args = Assert.IsType<Dictionary<string, object?>>(detail.Args);
Assert.Equal(769904783, args["incidentId"]);
}
[Theory]
[InlineData("view", "read")]
[InlineData("glob", "read")]
[InlineData("grep", "read")]
[InlineData("lsp", "read")]
[InlineData("edit", "write")]
[InlineData("create", "write")]
[InlineData("powershell", "shell")]
[InlineData("read_powershell", "shell")]
[InlineData("write_powershell", "shell")]
[InlineData("stop_powershell", "shell")]
[InlineData("list_powershell", "shell")]
[InlineData("web_fetch", "url")]
[InlineData("web_search", "url")]
[InlineData("store_memory", "memory")]
public void ResolveHookToolCategory_ReturnsExpectedCategoryForKnownTools(string toolName, string expectedCategory)
{
Assert.Equal(expectedCategory, CopilotApprovalCoordinator.ResolveHookToolCategory(toolName));
}
[Theory]
[InlineData("icm-mcp-get_on_call_schedule")]
[InlineData("custom_tool")]
[InlineData("unknown")]
public void ResolveHookToolCategory_ReturnsNullForUnknownTools(string toolName)
{
Assert.Null(CopilotApprovalCoordinator.ResolveHookToolCategory(toolName));
}
[Fact]
public void ResolveHookToolCategory_ReturnsNullForNullOrEmpty()
{
Assert.Null(CopilotApprovalCoordinator.ResolveHookToolCategory(null));
Assert.Null(CopilotApprovalCoordinator.ResolveHookToolCategory(""));
Assert.Null(CopilotApprovalCoordinator.ResolveHookToolCategory(" "));
}
[Fact]
public void ResolveHookMcpServerApprovalKey_PrefersLongestConfiguredServerName()
{
string? approvalKey = CopilotApprovalCoordinator.ResolveHookMcpServerApprovalKey(
"icm-mcp-get_on_call_schedule",
[CreateMcpServerConfig("icm"), CreateMcpServerConfig("icm-mcp")]);
Assert.Equal("mcp_server:icm-mcp", approvalKey);
}
[Fact]
public void TryGetApprovalToolName_ResolvesHookToolToCategory()
{
Assert.True(
CopilotApprovalCoordinator.TryGetApprovalToolName(
new PermissionRequestHook
{
Kind = "hook",
ToolName = "view",
ToolArgs = """{"path":"README.md"}""",
},
out string? toolName));
Assert.Equal("view", toolName);
// But the auto-approved name (fallback) resolves to the category
PermissionRequestHook hookRequest = new()
{
Kind = "hook",
ToolName = "view",
ToolArgs = """{"path":"README.md"}""",
};
// Verify GetFallbackToolName returns category via ResolveAutoApprovedToolName path
Assert.True(
CopilotApprovalCoordinator.TryGetApprovalToolName(
hookRequest,
out _));
}
[Fact]
public void RequiresToolCallApproval_HonorsHookToolCategoryForAutoApproval()
{
ApprovalPolicyDto policy = new()
{
Rules =
[
new ApprovalCheckpointRuleDto
{
Kind = "tool-call",
AgentIds = ["agent-1"],
},
],
AutoApprovedToolNames = ["read"],
};
// "view" is a hook tool that maps to "read" category — should be auto-approved
Assert.False(CopilotApprovalCoordinator.RequiresToolCallApproval(
policy, "agent-1", "view", "read"));
// "grep" also maps to "read"
Assert.False(CopilotApprovalCoordinator.RequiresToolCallApproval(
policy, "agent-1", "grep", "read"));
// "edit" maps to "write" — not auto-approved
Assert.True(CopilotApprovalCoordinator.RequiresToolCallApproval(
policy, "agent-1", "edit", "write"));
}
[Fact]
public void BuildPermissionApprovalEvent_UsesResolvedCategoryForHookPermissionKind()
{
ApprovalRequestedEventDto approvalEvent = CopilotApprovalCoordinator.BuildPermissionApprovalEvent(
new RunTurnCommandDto
{
RequestId = "turn-1",
SessionId = "session-1",
},
CreateAgent("agent-1", "Primary"),
new PermissionRequestHook
{
Kind = "hook",
ToolName = "view",
ToolArgs = """{"path":"README.md"}""",
},
new PermissionInvocation
{
SessionId = "copilot-session-1",
},
"approval-1",
"view");
Assert.Equal("view", approvalEvent.ToolName);
Assert.Equal("read", approvalEvent.PermissionKind);
Assert.Contains("read permission", approvalEvent.Detail);
}
[Fact]
public void BuildPermissionApprovalEvent_UsesMcpKindForConfiguredMcpHookTools()
{
ApprovalRequestedEventDto approvalEvent = CopilotApprovalCoordinator.BuildPermissionApprovalEvent(
new RunTurnCommandDto
{
RequestId = "turn-1",
SessionId = "session-1",
Tooling = new RunTurnToolingConfigDto
{
McpServers = [CreateMcpServerConfig("icm-mcp")],
},
},
CreateAgent("agent-1", "Primary"),
new PermissionRequestHook
{
Kind = "hook",
ToolName = "icm-mcp-get_schedule",
ToolArgs = """{"teamIds":[91982]}""",
},
new PermissionInvocation
{
SessionId = "copilot-session-1",
},
"approval-1",
"icm-mcp-get_schedule");
Assert.Equal("mcp", approvalEvent.PermissionKind);
Assert.Contains("mcp permission", approvalEvent.Detail);
Assert.NotNull(approvalEvent.PermissionDetail);
Assert.Equal("mcp", approvalEvent.PermissionDetail!.Kind);
Assert.Equal("icm-mcp", approvalEvent.PermissionDetail.ServerName);
Assert.Equal("get_schedule", approvalEvent.PermissionDetail.ToolTitle);
}
[Fact]
public void BuildPermissionApprovalEvent_KeepsHookKindForUnknownHookTools()
{
ApprovalRequestedEventDto approvalEvent = CopilotApprovalCoordinator.BuildPermissionApprovalEvent(
new RunTurnCommandDto
{
RequestId = "turn-1",
SessionId = "session-1",
},
CreateAgent("agent-1", "Primary"),
new PermissionRequestHook
{
Kind = "hook",
ToolName = "icm-mcp-get_schedule",
ToolArgs = """{"teamIds":[91982]}""",
},
new PermissionInvocation
{
SessionId = "copilot-session-1",
},
"approval-1",
"icm-mcp-get_schedule");
Assert.Equal("hook", approvalEvent.PermissionKind);
}
[Fact]
public async Task RequestApprovalAsync_RaisesApprovalAndCompletesAfterResolution()
{
@@ -1464,6 +1892,43 @@ public sealed class CopilotWorkflowRunnerTests
Assert.Equal(PermissionRequestResultKind.Approved, result.Kind);
}
[Fact]
public async Task RequestApprovalAsync_AutoApprovesHookRequestsForApprovedMcpServer()
{
CopilotApprovalCoordinator coordinator = new();
bool sawApproval = false;
RunTurnCommandDto command = CreateApprovalCommand(
autoApprovedToolNames: ["mcp_server:icm-mcp"],
mcpServers: [CreateMcpServerConfig("icm-mcp")]);
PermissionRequestResult result = await coordinator.RequestApprovalAsync(
command,
command.Pattern.Agents[0],
new PermissionRequestHook
{
Kind = "hook",
ToolName = "icm-mcp-get_incident_details_by_id",
ToolArgs = new Dictionary<string, object?>
{
["incidentId"] = 769904783,
},
},
new PermissionInvocation
{
SessionId = "copilot-session-1",
},
new Dictionary<string, string>(StringComparer.Ordinal),
approval =>
{
sawApproval = true;
return Task.CompletedTask;
},
CancellationToken.None);
Assert.False(sawApproval);
Assert.Equal(PermissionRequestResultKind.Approved, result.Kind);
}
[Fact]
public async Task RequestApprovalAsync_AlwaysApproveCachesRuntimeApprovalForCurrentTurn()
{
@@ -1704,12 +2169,21 @@ public sealed class CopilotWorkflowRunnerTests
null!);
}
private static RunTurnCommandDto CreateApprovalCommand(string requestId = "turn-1")
private static RunTurnCommandDto CreateApprovalCommand(
string requestId = "turn-1",
IReadOnlyList<string>? autoApprovedToolNames = null,
IReadOnlyList<RunTurnMcpServerConfigDto>? mcpServers = null)
{
return new RunTurnCommandDto
{
RequestId = requestId,
SessionId = "session-1",
Tooling = mcpServers is null
? null
: new RunTurnToolingConfigDto
{
McpServers = [.. mcpServers],
},
Pattern = new PatternDefinitionDto
{
Id = "pattern-1",
@@ -1726,7 +2200,9 @@ public sealed class CopilotWorkflowRunnerTests
AgentIds = ["agent-1"],
},
],
AutoApprovedToolNames = ["web_fetch"],
AutoApprovedToolNames = autoApprovedToolNames is null
? ["web_fetch"]
: [.. autoApprovedToolNames],
},
Agents =
[
@@ -1736,6 +2212,13 @@ public sealed class CopilotWorkflowRunnerTests
};
}
private static RunTurnMcpServerConfigDto CreateMcpServerConfig(string serverName)
=> new()
{
Id = serverName,
Name = serverName,
};
private sealed class StubChatClient : IChatClient
{
public Task<ChatResponse> GetResponseAsync(
@@ -11,8 +11,12 @@ public sealed class HandoffWorkflowGuidanceTests
string instructions = HandoffWorkflowGuidance.CreateWorkflowInstructions();
Assert.Contains("explicit handoffs", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("routing or triage agent", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("best specialist", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not inspect files", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not claim that you delegated", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Do not narrate a handoff", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("own the substantive answer", instructions, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Specialists should complete the substantive work", instructions, StringComparison.OrdinalIgnoreCase);
}
@@ -232,6 +232,77 @@ public sealed class SidecarProtocolHostTests
});
}
[Fact]
public async Task RunTurnCommand_ReturnsWorkflowDiagnosticEventsAndCompletion()
{
SidecarProtocolHost host = new(
new PatternValidator(),
new FakeWorkflowRunner(async (command, onDelta, onActivity, onApproval, onUserInput, onMcpOAuthRequired, onExitPlanMode, cancellationToken) =>
{
await onActivity(new WorkflowDiagnosticEventDto
{
Type = "workflow-diagnostic",
RequestId = command.RequestId,
SessionId = command.SessionId,
Severity = "error",
DiagnosticKind = "executor-failed",
Message = "Tool crashed.",
AgentId = "agent-1",
AgentName = "Primary",
ExecutorId = "agent-1",
ExceptionType = "InvalidOperationException",
});
return [];
}));
IReadOnlyList<JsonElement> events = await RunHostAsync(
new RunTurnCommandDto
{
Type = "run-turn",
RequestId = "turn-diagnostic",
SessionId = "session-1",
ProjectPath = "C:\\workspace\\project",
Pattern = new PatternDefinitionDto
{
Id = "pattern-1",
Name = "Single Agent",
Mode = "single",
Availability = "available",
Agents =
[
CreateAgent(name: "Primary"),
],
},
Messages = [],
},
host);
Assert.Collection(
events,
diagnosticEvent =>
{
Assert.Equal("workflow-diagnostic", diagnosticEvent.GetProperty("type").GetString());
Assert.Equal("turn-diagnostic", diagnosticEvent.GetProperty("requestId").GetString());
Assert.Equal("session-1", diagnosticEvent.GetProperty("sessionId").GetString());
Assert.Equal("error", diagnosticEvent.GetProperty("severity").GetString());
Assert.Equal("executor-failed", diagnosticEvent.GetProperty("diagnosticKind").GetString());
Assert.Equal("Tool crashed.", diagnosticEvent.GetProperty("message").GetString());
Assert.Equal("agent-1", diagnosticEvent.GetProperty("executorId").GetString());
},
completionEvent =>
{
Assert.Equal("turn-complete", completionEvent.GetProperty("type").GetString());
Assert.Equal("session-1", completionEvent.GetProperty("sessionId").GetString());
Assert.False(completionEvent.GetProperty("cancelled").GetBoolean());
},
commandCompleteEvent =>
{
Assert.Equal("command-complete", commandCompleteEvent.GetProperty("type").GetString());
Assert.Equal("turn-diagnostic", commandCompleteEvent.GetProperty("requestId").GetString());
});
}
[Fact]
public async Task RunTurnCommand_DeserializesInteractionMode()
{
@@ -86,6 +86,26 @@ public sealed class WorkflowRequestInfoInterpreterTests
Assert.Empty(toolNamesByCallId);
}
[Fact]
public void TryCreateActivityFromRequest_SkipsDuplicateTrackedToolCallIds()
{
ConcurrentDictionary<string, string> toolNamesByCallId = new(StringComparer.Ordinal)
{
["call-1"] = "view",
};
RequestInfoEvent requestInfo = CreateRequestInfoEvent(
new FunctionCallContent("call-1", "view", new Dictionary<string, object?>()));
AgentActivityEventDto? activity = WorkflowRequestInfoInterpreter.TryCreateActivityFromRequest(
CreateSingleAgentCommand(),
requestInfo,
new AgentIdentity("agent-1", "Primary"),
toolNamesByCallId);
Assert.Null(activity);
Assert.Equal("view", toolNamesByCallId["call-1"]);
}
[Fact]
public void TryCreateActivityFromRequest_ReturnsHandoffActivityForKnownTargets()
{
+615 -20
View File
@@ -10,11 +10,15 @@ import type {
ExitPlanModeRequestedEvent,
MessageMode,
McpOauthRequiredEvent,
MessageReclassifiedEvent,
RunTurnCustomAgentConfig,
RunTurnCommand,
RunTurnToolingConfig,
SidecarCapabilities,
UserInputRequestedEvent,
TurnDeltaEvent,
WorkflowCheckpointResume,
WorkflowCheckpointSavedEvent,
} from '@shared/contracts/sidecar';
import type { TurnScopedEvent } from '@main/sidecar/runTurnPending';
import {
@@ -61,7 +65,14 @@ import {
type PendingApprovalMessageRecord,
type PendingApprovalRecord,
} from '@shared/domain/approval';
import { isScratchpadProject, type ProjectRecord } from '@shared/domain/project';
import {
isScratchpadProject,
type ProjectGitCommitMessageSuggestion,
type ProjectGitDetails,
type ProjectGitDiffPreview,
type ProjectGitFileReference,
type ProjectRecord,
} from '@shared/domain/project';
import {
branchSessionRecord,
duplicateSessionRecord,
@@ -92,9 +103,11 @@ import {
completeSessionRunRecord,
createSessionRunRecord,
failSessionRunRecord,
setSessionRunGitSummary,
upsertRunApprovalEvent,
upsertRunMessageEvent,
upsertSessionRunRecord,
type RunTimelineEventRecord,
type SessionRunRecord,
} from '@shared/domain/runTimeline';
import {
@@ -129,6 +142,7 @@ import {
SidecarClient,
} from '@main/sidecar/sidecarProcess';
import { TurnCancelledError } from '@main/sidecar/turnCancelledError';
import { buildProjectGitCommitMessageSuggestion } from '@main/git/gitCommitMessageSuggestion';
import { GitService } from '@main/git/gitService';
import {
buildRunTurnToolingConfig as buildSessionToolingConfig,
@@ -160,6 +174,15 @@ type PendingUserInputHandle = {
resolve: (answer: string, wasFreeform: boolean) => void | Promise<void>;
};
type WorkflowCheckpointRecoveryState = {
workflowSessionId: string;
checkpointId: string;
storePath: string;
stepNumber: number;
sessionMessages: ChatMessageRecord[];
runEvents: RunTimelineEventRecord[];
};
type DiscoveredToolingResolution = 'accept' | 'dismiss';
function isBuiltinPattern(patternId: string): boolean {
@@ -180,10 +203,22 @@ function isSidecarStoppedBeforeCompletionError(error: unknown): error is Error {
return error instanceof Error && error.message === SIDECAR_STOPPED_BEFORE_COMPLETION_MESSAGE;
}
function isUnexpectedSidecarTerminationError(error: unknown): error is Error {
if (!(error instanceof Error)) {
return false;
}
const { message } = error;
return isSidecarStoppedBeforeCompletionError(error)
|| message.startsWith('The .NET sidecar exited unexpectedly with code ');
}
const INTERRUPTED_RUN_ERROR =
'This session was interrupted because Aryx restarted while a run was in progress.';
const INTERRUPTED_APPROVAL_ERROR =
'Pending approval was interrupted because Aryx restarted before a decision was recorded.';
const GIT_REFRESH_DEBOUNCE_MS = 750;
const GIT_REFRESH_INTERVAL_MS = 60_000;
export class AryxAppService extends EventEmitter<AppServiceEvents> {
private readonly workspaceRepository = new WorkspaceRepository();
@@ -196,11 +231,18 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
private readonly ptyManager = new PtyManager();
private readonly pendingApprovalHandles = new Map<string, PendingApprovalHandle>();
private readonly pendingUserInputHandles = new Map<string, PendingUserInputHandle>();
private readonly workflowCheckpointRecoveries = new Map<string, WorkflowCheckpointRecoveryState>();
private workspace?: WorkspaceState;
private sidecarCapabilities?: SidecarCapabilities;
private sidecarCapabilitiesPromise?: Promise<SidecarCapabilities>;
private didScheduleInitialProjectGitRefresh = false;
private didStartPeriodicProjectGitRefresh = false;
private mcpProbeUpdateQueue = Promise.resolve();
private pendingProjectGitRefreshIds = new Set<string>();
private pendingRefreshAllProjects = false;
private projectGitRefreshTimer?: ReturnType<typeof setTimeout>;
private periodicProjectGitRefreshTimer?: ReturnType<typeof setInterval>;
private runningProjectGitRefresh?: Promise<void>;
constructor() {
super();
@@ -251,6 +293,9 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
if (!this.didScheduleInitialProjectGitRefresh) {
this.didScheduleInitialProjectGitRefresh = true;
if (this.workspace.settings.gitAutoRefreshEnabled !== false) {
this.startPeriodicProjectGitRefresh();
}
void this.refreshProjectGitContext().catch((error) => {
console.error('[aryx git]', error);
});
@@ -269,11 +314,42 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
}
async dispose(): Promise<void> {
if (this.projectGitRefreshTimer) {
clearTimeout(this.projectGitRefreshTimer);
this.projectGitRefreshTimer = undefined;
}
if (this.periodicProjectGitRefreshTimer) {
clearInterval(this.periodicProjectGitRefreshTimer);
this.periodicProjectGitRefreshTimer = undefined;
}
this.ptyManager.dispose();
await this.sidecar.dispose();
void this.secretStore;
}
isGitAutoRefreshEnabled(): boolean {
return this.workspace?.settings.gitAutoRefreshEnabled !== false;
}
scheduleProjectGitRefresh(projectId?: string): void {
if (projectId) {
this.pendingProjectGitRefreshIds.add(projectId);
} else {
this.pendingRefreshAllProjects = true;
this.pendingProjectGitRefreshIds.clear();
}
if (this.projectGitRefreshTimer) {
clearTimeout(this.projectGitRefreshTimer);
}
this.projectGitRefreshTimer = setTimeout(() => {
this.projectGitRefreshTimer = undefined;
void this.flushScheduledProjectGitRefresh();
}, GIT_REFRESH_DEBOUNCE_MS);
this.projectGitRefreshTimer.unref?.();
}
async openAppDataFolder(): Promise<void> {
const appDataPath = dirname(this.workspaceRepository.filePath);
await shell.openPath(appDataPath);
@@ -526,6 +602,19 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
return this.persistAndBroadcast(workspace);
}
async setGitAutoRefreshEnabled(enabled: boolean): Promise<WorkspaceState> {
const workspace = await this.loadWorkspace();
workspace.settings.gitAutoRefreshEnabled = enabled;
if (enabled) {
this.startPeriodicProjectGitRefresh();
} else {
this.stopPeriodicProjectGitRefresh();
}
return this.persistAndBroadcast(workspace);
}
async describeTerminal(): Promise<TerminalSnapshot | undefined> {
return this.ptyManager.getSnapshot();
}
@@ -1301,6 +1390,16 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
): Promise<void> {
const workspaceKind = isScratchpadProject(project) ? 'scratchpad' : 'project';
const { occurredAt, requestId, triggerMessageId, messageMode, attachments } = options;
const runWorkingDirectory = session.cwd ?? project.path;
const preRunGitSnapshot = workspaceKind === 'project'
? await this.gitService.captureWorkingTreeSnapshot(runWorkingDirectory, occurredAt)
: undefined;
const preRunGitBaselineFiles = workspaceKind === 'project' && preRunGitSnapshot
? await this.gitService.captureWorkingTreeBaseline(runWorkingDirectory, preRunGitSnapshot)
: undefined;
if (workspaceKind === 'project' && project.git?.status === 'ready' && !preRunGitSnapshot) {
console.warn(`[aryx git] Failed to capture pre-run git snapshot for project "${project.id}".`);
}
session.title = resolveSessionTitle(session, effectivePattern, session.messages);
session.status = 'running';
@@ -1312,10 +1411,13 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
createSessionRunRecord({
requestId,
project,
workingDirectory: runWorkingDirectory,
workspaceKind,
pattern: effectivePattern,
triggerMessageId,
startedAt: occurredAt,
preRunGitSnapshot,
preRunGitBaselineFiles,
}),
...session.runs,
];
@@ -1329,21 +1431,29 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
});
try {
const responseMessages = await this.sidecar.runTurn(
{
type: 'run-turn',
requestId,
sessionId: session.id,
projectPath: session.cwd ?? project.path,
workspaceKind,
mode: session.interactionMode ?? 'interactive',
messageMode,
projectInstructions,
pattern: effectivePattern,
messages: session.messages,
attachments: attachments?.length ? attachments : undefined,
tooling: this.buildRunTurnToolingConfig(workspace, session),
},
const createRunTurnCommand = (
resumeFromCheckpoint?: WorkflowCheckpointResume,
): RunTurnCommand => ({
type: 'run-turn',
requestId,
sessionId: session.id,
projectPath: runWorkingDirectory,
workspaceKind,
mode: session.interactionMode ?? 'interactive',
messageMode,
projectInstructions,
pattern: effectivePattern,
messages: session.messages,
attachments: attachments?.length ? attachments : undefined,
tooling: this.buildRunTurnToolingConfig(workspace, session),
resumeFromCheckpoint,
});
const responseMessages = await this.runSidecarTurnWithCheckpointRecovery(
workspace,
session,
requestId,
createRunTurnCommand,
async (event) => {
await this.applyTurnDelta(workspace, session.id, requestId, event);
},
@@ -1364,6 +1474,9 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
async (event) => {
await this.handleExitPlanModeRequested(workspace, session.id, event);
},
async (event) => {
await this.applyMessageReclassified(workspace, session.id, event);
},
async (event) => {
await this.handleTurnScopedEvent(workspace, session.id, event);
},
@@ -1371,11 +1484,31 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
await this.awaitFinalResponseApproval(workspace, session.id, requestId, effectivePattern, responseMessages);
this.finalizeTurn(workspace, session.id, requestId, responseMessages);
if (workspaceKind === 'project') {
const completedRun = await this.refreshSessionRunGitSummary(session, project, requestId, nowIso());
if (completedRun) {
this.emitRunUpdated(session.id, nowIso(), completedRun);
}
}
await this.persistAndBroadcast(workspace);
await this.cleanupWorkflowCheckpointRecovery(requestId);
if (workspaceKind === 'project') {
this.scheduleProjectGitRefresh(project.id);
}
} catch (error) {
if (error instanceof TurnCancelledError) {
this.finalizeCancelledTurn(workspace, session, requestId);
if (workspaceKind === 'project') {
const cancelledRun = await this.refreshSessionRunGitSummary(session, project, requestId, nowIso());
if (cancelledRun) {
this.emitRunUpdated(session.id, nowIso(), cancelledRun);
}
}
await this.persistAndBroadcast(workspace);
await this.cleanupWorkflowCheckpointRecovery(requestId);
if (workspaceKind === 'project') {
this.scheduleProjectGitRefresh(project.id);
}
return;
}
@@ -1397,7 +1530,18 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
this.emitRunUpdated(session.id, failedAt, failedRun);
}
if (workspaceKind === 'project') {
const summarizedRun = await this.refreshSessionRunGitSummary(session, project, requestId, failedAt);
if (summarizedRun) {
this.emitRunUpdated(session.id, failedAt, summarizedRun);
}
}
await this.persistAndBroadcast(workspace);
await this.cleanupWorkflowCheckpointRecovery(requestId);
if (workspaceKind === 'project') {
this.scheduleProjectGitRefresh(project.id);
}
}
}
@@ -1482,9 +1626,164 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
}
async refreshProjectGitContext(projectId?: string): Promise<WorkspaceState> {
return this.refreshProjectGitContexts(projectId ? [projectId] : undefined);
}
async getProjectGitDetails(projectId: string, commitLimit = 20): Promise<ProjectGitDetails> {
const workspace = await this.loadWorkspace();
const projects = projectId
? [this.requireProject(workspace, projectId)]
const project = this.requireProject(workspace, projectId);
return this.gitService.describeProjectGitDetails(project.path, nowIso(), commitLimit);
}
async getProjectGitFilePreview(
projectId: string,
file: ProjectGitFileReference,
): Promise<ProjectGitDiffPreview | undefined> {
const workspace = await this.loadWorkspace();
const project = this.requireProject(workspace, projectId);
return this.gitService.getWorkingTreeFilePreview(project.path, file);
}
async discardSessionRunGitChanges(
sessionId: string,
runId: string,
files?: ProjectGitFileReference[],
): Promise<WorkspaceState> {
const workspace = await this.loadWorkspace();
const session = this.requireSession(workspace, sessionId);
const project = this.requireProject(workspace, session.projectId);
const run = this.requireSessionRun(session, runId);
if (run.workspaceKind !== 'project') {
throw new Error('Run change review is only available for project-backed sessions.');
}
if (!run.postRunGitSummary) {
throw new Error('This run does not have any tracked git changes to discard.');
}
await this.gitService.discardRunChanges(
this.resolveRunWorkingDirectory(session, project, run),
{
summary: run.postRunGitSummary,
preRunBaselineFiles: run.preRunGitBaselineFiles,
files,
},
);
await this.refreshProjectGitContexts([project.id]);
const refreshedWorkspace = await this.loadWorkspace();
const refreshedSession = this.requireSession(refreshedWorkspace, sessionId);
const refreshedProject = this.requireProject(refreshedWorkspace, refreshedSession.projectId);
const nextRun = await this.refreshSessionRunGitSummary(
refreshedSession,
refreshedProject,
run.requestId,
nowIso(),
);
if (nextRun) {
this.emitRunUpdated(refreshedSession.id, nowIso(), nextRun);
}
return this.persistAndBroadcast(refreshedWorkspace);
}
async stageProjectGitFiles(projectId: string, files: ProjectGitFileReference[]): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.stageFiles(project.path, files);
});
}
async unstageProjectGitFiles(projectId: string, files: ProjectGitFileReference[]): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.unstageFiles(project.path, files);
});
}
async suggestProjectGitCommitMessage(
sessionId: string,
runId?: string,
conventionalType?: ProjectGitCommitMessageSuggestion['type'],
): Promise<ProjectGitCommitMessageSuggestion> {
const workspace = await this.loadWorkspace();
const session = this.requireSession(workspace, sessionId);
const run = runId
? this.requireSessionRun(session, runId)
: session.runs[0];
if (!run) {
throw new Error('This session does not have a run to summarize into a commit message.');
}
return buildProjectGitCommitMessageSuggestion({
session,
run,
summary: run.postRunGitSummary,
conventionalType,
});
}
async commitProjectGitChanges(
projectId: string,
message: string,
files?: ProjectGitFileReference[],
push = false,
): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
if (files && files.length > 0) {
await this.gitService.stageFiles(project.path, files);
}
await this.gitService.commit(project.path, message);
if (push) {
await this.gitService.push(project.path);
}
});
}
async pushProjectGit(projectId: string): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.push(project.path);
});
}
async fetchProjectGit(projectId: string): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.fetch(project.path);
});
}
async pullProjectGit(projectId: string, rebase = false): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.pull(project.path, rebase);
});
}
async createProjectGitBranch(
projectId: string,
name: string,
startPoint?: string,
checkout = true,
): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.createBranch(project.path, name, startPoint, checkout);
});
}
async switchProjectGitBranch(projectId: string, name: string): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.switchBranch(project.path, name);
});
}
async deleteProjectGitBranch(projectId: string, name: string, force = false): Promise<WorkspaceState> {
return this.runProjectGitMutation(projectId, async (project) => {
await this.gitService.deleteBranch(project.path, name, force);
});
}
private async refreshProjectGitContexts(projectIds?: readonly string[]): Promise<WorkspaceState> {
const workspace = await this.loadWorkspace();
const projects = projectIds?.length
? projectIds.map((currentProjectId) => this.requireProject(workspace, currentProjectId))
: workspace.projects;
let didRefreshGit = false;
@@ -1566,6 +1865,61 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
return project;
}
private requireSessionRun(session: SessionRecord, runId: string): SessionRunRecord {
const run = session.runs.find((candidate) => candidate.id === runId);
if (!run) {
throw new Error(`Run "${runId}" was not found for session "${session.id}".`);
}
return run;
}
private resolveRunWorkingDirectory(
session: SessionRecord,
project: ProjectRecord,
run: SessionRunRecord,
): string {
return run.workingDirectory ?? session.cwd ?? run.projectPath ?? project.path;
}
private async refreshSessionRunGitSummary(
session: SessionRecord,
project: ProjectRecord,
requestId: string,
occurredAt: string,
): Promise<SessionRunRecord | undefined> {
const run = session.runs.find((candidate) => candidate.requestId === requestId);
if (!run || run.workspaceKind !== 'project' || !run.preRunGitSnapshot) {
return undefined;
}
const summary = await this.gitService.computeRunChangeSummary(
this.resolveRunWorkingDirectory(session, project, run),
{
generatedAt: occurredAt,
preRunSnapshot: run.preRunGitSnapshot,
preRunBaselineFiles: run.preRunGitBaselineFiles,
},
);
return this.updateSessionRun(session, requestId, (currentRun) =>
setSessionRunGitSummary(currentRun, summary));
}
private async runProjectGitMutation(
projectId: string,
mutation: (project: ProjectRecord) => Promise<void>,
): Promise<WorkspaceState> {
const workspace = await this.loadWorkspace();
const project = this.requireProject(workspace, projectId);
if (isScratchpadProject(project)) {
throw new Error('Git operations are not available for the Scratchpad project.');
}
await mutation(project);
return this.refreshProjectGitContexts([project.id]);
}
private resolveTerminalWorkingDirectory(workspace: WorkspaceState): string {
const selectedSession = workspace.selectedSessionId
? workspace.sessions.find((session) => session.id === workspace.selectedSessionId)
@@ -1599,6 +1953,54 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
return true;
}
private startPeriodicProjectGitRefresh(): void {
if (this.didStartPeriodicProjectGitRefresh) {
return;
}
this.didStartPeriodicProjectGitRefresh = true;
this.periodicProjectGitRefreshTimer = setInterval(() => {
this.scheduleProjectGitRefresh();
}, GIT_REFRESH_INTERVAL_MS);
this.periodicProjectGitRefreshTimer.unref?.();
}
private stopPeriodicProjectGitRefresh(): void {
if (this.periodicProjectGitRefreshTimer) {
clearInterval(this.periodicProjectGitRefreshTimer);
this.periodicProjectGitRefreshTimer = undefined;
}
this.didStartPeriodicProjectGitRefresh = false;
}
private async flushScheduledProjectGitRefresh(): Promise<void> {
if (this.runningProjectGitRefresh) {
return;
}
const projectIds = this.pendingRefreshAllProjects
? undefined
: [...this.pendingProjectGitRefreshIds];
this.pendingRefreshAllProjects = false;
this.pendingProjectGitRefreshIds.clear();
this.runningProjectGitRefresh = this.refreshProjectGitContexts(projectIds).then(
() => undefined,
(error) => {
console.error('[aryx git]', error);
},
);
try {
await this.runningProjectGitRefresh;
} finally {
this.runningProjectGitRefresh = undefined;
if (this.pendingRefreshAllProjects || this.pendingProjectGitRefreshIds.size > 0) {
this.scheduleProjectGitRefresh();
}
}
}
private requirePattern(workspace: WorkspaceState, patternId: string): PatternDefinition {
const pattern = workspace.patterns.find((current) => current.id === patternId);
if (!pattern) {
@@ -1715,6 +2117,31 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
}
}
private async applyMessageReclassified(
workspace: WorkspaceState,
sessionId: string,
event: MessageReclassifiedEvent,
): Promise<void> {
const session = this.requireSession(workspace, sessionId);
const message = session.messages.find((m) => m.id === event.messageId);
if (!message || message.messageKind === 'thinking') {
return;
}
message.messageKind = 'thinking';
const occurredAt = nowIso();
session.updatedAt = occurredAt;
await this.workspaceRepository.save(workspace);
this.emitSessionEvent({
sessionId,
kind: 'message-reclassified',
occurredAt,
messageId: event.messageId,
messageKind: 'thinking',
});
}
private async applyAgentActivity(
workspace: WorkspaceState,
sessionId: string,
@@ -1795,6 +2222,15 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
const pattern = this.requirePattern(workspace, session.patternId);
const incomingIds = new Set(messages.map((message) => message.id));
// Messages that were streamed during the turn already exist in session.messages
// (possibly with messageKind: 'thinking' from reclassification). Unstreamed messages
// (e.g. from sub-agents) only appear now. Classify them as thinking when a visible
// response was already streamed, since they are intermediate tool-driving steps.
const existingIds = new Set(session.messages.map((m) => m.id));
const hasVisibleResponse = session.messages.some(
(m) => m.role === 'assistant' && m.messageKind !== 'thinking',
);
for (const message of messages) {
const occurredAt = nowIso();
const existing = session.messages.find((current) => current.id === message.id);
@@ -1803,9 +2239,22 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
existing.content = message.content;
existing.pending = false;
} else {
session.messages.push({ ...message, pending: false });
const isUnstreamedIntermediate =
message.role === 'assistant'
&& hasVisibleResponse
&& !message.messageKind;
session.messages.push({
...message,
pending: false,
messageKind: message.messageKind ?? (isUnstreamedIntermediate ? 'thinking' : undefined),
});
}
const reclassifiedAsThinking =
!existingIds.has(message.id)
&& (message.messageKind === 'thinking'
|| (message.role === 'assistant' && hasVisibleResponse && !message.messageKind));
const nextRun = this.updateSessionRun(session, requestId, (run) =>
upsertRunMessageEvent(run, {
messageId: message.id,
@@ -1822,6 +2271,15 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
authorName: message.authorName,
content: message.content,
});
if (reclassifiedAsThinking) {
this.emitSessionEvent({
sessionId,
kind: 'message-reclassified',
occurredAt,
messageId: message.id,
messageKind: 'thinking',
});
}
if (nextRun) {
this.emitRunUpdated(sessionId, occurredAt, nextRun);
}
@@ -1998,13 +2456,22 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
}
private handleTurnScopedEvent(
_workspace: WorkspaceState,
workspace: WorkspaceState,
sessionId: string,
event: TurnScopedEvent,
): void {
const occurredAt = nowIso();
switch (event.type) {
case 'workflow-checkpoint-saved': {
const session = this.requireSession(workspace, sessionId);
const run = session.runs.find((candidate) => candidate.requestId === event.requestId);
if (run) {
this.recordWorkflowCheckpointRecovery(session, run, event);
}
return;
}
case 'subagent-event':
this.emitSessionEvent({
sessionId,
@@ -2081,6 +2548,21 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
agentName: event.agentName,
});
return;
case 'workflow-diagnostic':
this.emitSessionEvent({
sessionId,
kind: 'workflow-diagnostic',
occurredAt,
agentId: event.agentId,
agentName: event.agentName,
diagnosticSeverity: event.severity,
diagnosticKind: event.diagnosticKind,
diagnosticMessage: event.message,
executorId: event.executorId,
subworkflowId: event.subworkflowId,
exceptionType: event.exceptionType,
});
return;
case 'assistant-usage':
this.emitSessionEvent({
sessionId,
@@ -2102,6 +2584,119 @@ export class AryxAppService extends EventEmitter<AppServiceEvents> {
}
}
private async runSidecarTurnWithCheckpointRecovery(
workspace: WorkspaceState,
session: SessionRecord,
requestId: string,
createCommand: (resumeFromCheckpoint?: WorkflowCheckpointResume) => RunTurnCommand,
onDelta: (event: TurnDeltaEvent) => void | Promise<void>,
onActivity: (event: AgentActivityEvent) => void | Promise<void>,
onApproval: (event: ApprovalRequestedEvent) => void | Promise<void>,
onUserInput: (event: UserInputRequestedEvent) => void | Promise<void>,
onMcpOAuthRequired: (event: McpOauthRequiredEvent) => void | Promise<void>,
onExitPlanMode: (event: ExitPlanModeRequestedEvent) => void | Promise<void>,
onMessageReclassified: (event: MessageReclassifiedEvent) => void | Promise<void>,
onTurnScopedEvent: (event: TurnScopedEvent) => void | Promise<void>,
): Promise<ChatMessageRecord[]> {
const invokeTurn = (resumeFromCheckpoint?: WorkflowCheckpointResume) => this.sidecar.runTurn(
createCommand(resumeFromCheckpoint),
onDelta,
onActivity,
onApproval,
onUserInput,
onMcpOAuthRequired,
onExitPlanMode,
onMessageReclassified,
onTurnScopedEvent,
);
try {
return await invokeTurn();
} catch (error) {
const recovery = this.workflowCheckpointRecoveries.get(requestId);
if (!isUnexpectedSidecarTerminationError(error) || !recovery) {
throw error;
}
const restoredRun = this.restoreWorkflowCheckpointRecovery(session, requestId, recovery);
await this.persistAndBroadcast(workspace);
if (restoredRun) {
this.emitRunUpdated(session.id, session.updatedAt, restoredRun);
}
return invokeTurn({
workflowSessionId: recovery.workflowSessionId,
checkpointId: recovery.checkpointId,
storePath: recovery.storePath,
});
}
}
private recordWorkflowCheckpointRecovery(
session: SessionRecord,
run: SessionRunRecord,
event: WorkflowCheckpointSavedEvent,
): void {
this.workflowCheckpointRecoveries.set(event.requestId, {
workflowSessionId: event.workflowSessionId,
checkpointId: event.checkpointId,
storePath: event.storePath,
stepNumber: event.stepNumber,
sessionMessages: structuredClone(session.messages),
runEvents: structuredClone(run.events),
});
}
private restoreWorkflowCheckpointRecovery(
session: SessionRecord,
requestId: string,
recovery: WorkflowCheckpointRecoveryState,
): SessionRunRecord | undefined {
session.messages = structuredClone(recovery.sessionMessages);
session.status = 'running';
session.lastError = undefined;
session.updatedAt = nowIso();
this.clearPendingRunState(session, requestId);
return this.updateSessionRun(session, requestId, (run) => ({
...run,
events: structuredClone(recovery.runEvents),
}));
}
private clearPendingRunState(session: SessionRecord, requestId: string): void {
this.setSessionPendingApprovalState(session, {});
session.pendingUserInput = undefined;
session.pendingPlanReview = undefined;
session.pendingMcpAuth = undefined;
for (const [approvalId, handle] of this.pendingApprovalHandles.entries()) {
if (handle.sessionId === session.id && handle.requestId === requestId) {
this.pendingApprovalHandles.delete(approvalId);
}
}
for (const [userInputId, handle] of this.pendingUserInputHandles.entries()) {
if (handle.sessionId === session.id && handle.requestId === requestId) {
this.pendingUserInputHandles.delete(userInputId);
}
}
}
private async cleanupWorkflowCheckpointRecovery(requestId: string): Promise<void> {
const recovery = this.workflowCheckpointRecoveries.get(requestId);
this.workflowCheckpointRecoveries.delete(requestId);
if (!recovery) {
return;
}
try {
await rm(recovery.storePath, { recursive: true, force: true });
} catch (error) {
console.warn('[aryx workflow-checkpoint] Failed to clean checkpoint store:', error);
}
}
private createPendingApprovalFromSidecarEvent(event: ApprovalRequestedEvent): PendingApprovalRecord {
return {
id: event.approvalId,
+141
View File
@@ -0,0 +1,141 @@
import { basename } from 'node:path';
import type {
ProjectGitCommitMessageSuggestion,
ProjectGitConventionalCommitType,
ProjectGitRunChangeSummary,
} from '@shared/domain/project';
import type { SessionRecord } from '@shared/domain/session';
import type { SessionRunRecord } from '@shared/domain/runTimeline';
interface BuildCommitMessageSuggestionInput {
session: Pick<SessionRecord, 'messages' | 'title'>;
run: Pick<SessionRunRecord, 'triggerMessageId'>;
summary?: ProjectGitRunChangeSummary;
conventionalType?: ProjectGitConventionalCommitType;
}
const COMMIT_TYPES: readonly ProjectGitConventionalCommitType[] = [
'feat',
'fix',
'refactor',
'docs',
'test',
'chore',
];
function normalizeWhitespace(value: string): string {
return value.replace(/\s+/g, ' ').trim();
}
function isCommitType(value: string | undefined): value is ProjectGitConventionalCommitType {
return value !== undefined && COMMIT_TYPES.includes(value as ProjectGitConventionalCommitType);
}
function findTriggerMessageContent(
session: Pick<SessionRecord, 'messages'>,
triggerMessageId: string,
): string | undefined {
return session.messages.find((message) => message.id === triggerMessageId)?.content;
}
function inferCommitTypeFromSummary(
prompt: string | undefined,
summary: ProjectGitRunChangeSummary | undefined,
): ProjectGitConventionalCommitType {
const promptText = normalizeWhitespace(prompt?.toLowerCase() ?? '');
const files = summary?.files ?? [];
const filePaths = files.map((file) => file.path.toLowerCase());
if (filePaths.length > 0 && filePaths.every((path) => path.endsWith('.md') || path.includes('readme'))) {
return 'docs';
}
if (filePaths.length > 0 && filePaths.every((path) => path.includes('test') || path.endsWith('.snap'))) {
return 'test';
}
if (/\b(fix|bug|error|issue|regression|broken|failure)\b/.test(promptText)) {
return 'fix';
}
if (/\b(refactor|cleanup|restructure|rename|simplify)\b/.test(promptText)) {
return 'refactor';
}
if (/\b(doc|readme|documentation)\b/.test(promptText)) {
return 'docs';
}
if (/\b(test|coverage|assertion)\b/.test(promptText)) {
return 'test';
}
if (/\b(chore|config|build|deps|dependency|tooling)\b/.test(promptText)) {
return 'chore';
}
return 'feat';
}
function stripPromptLead(text: string): string {
return text
.replace(/^[`"'“”‘’]+|[`"'“”‘’]+$/g, '')
.replace(/^(please\s+)?(can|could|would)\s+you\s+/i, '')
.replace(/^(implement|add|create|build|make|update|improve|refactor|fix|support|handle)\s+/i, '')
.replace(/[.?!:;]+$/g, '')
.trim();
}
function summarizeFiles(summary: ProjectGitRunChangeSummary | undefined): string | undefined {
const firstFile = summary?.files[0];
if (!summary || summary.files.length === 0 || !firstFile) {
return undefined;
}
if (summary.files.length === 1) {
return basename(firstFile.path).replace(/\.[^.]+$/, '');
}
return `${summary.fileCount} files`;
}
function buildSubject(
prompt: string | undefined,
summary: ProjectGitRunChangeSummary | undefined,
): string {
const normalizedPrompt = normalizeWhitespace(prompt ?? '');
if (normalizedPrompt) {
const firstSentence = normalizedPrompt.split(/[\r\n.?!]/, 1)[0] ?? normalizedPrompt;
const stripped = stripPromptLead(firstSentence);
if (stripped) {
return stripped
.replace(/\b(the|a|an)\s+/gi, '')
.replace(/\s+/g, ' ')
.trim()
.toLowerCase();
}
}
const fallback = summarizeFiles(summary);
if (fallback) {
return `update ${fallback}`.toLowerCase();
}
return 'update project changes';
}
export function buildProjectGitCommitMessageSuggestion(
input: BuildCommitMessageSuggestionInput,
): ProjectGitCommitMessageSuggestion {
const prompt = findTriggerMessageContent(input.session, input.run.triggerMessageId);
const type = isCommitType(input.conventionalType)
? input.conventionalType
: inferCommitTypeFromSummary(prompt, input.summary);
const subject = buildSubject(prompt, input.summary);
return {
type,
subject,
message: `${type}: ${subject}`,
};
}
+327
View File
@@ -0,0 +1,327 @@
import { Buffer } from 'node:buffer';
import { isUtf8 } from 'node:buffer';
import type {
ProjectGitBaselineFile,
ProjectGitDiffPreview,
ProjectGitRunChangeCounts,
ProjectGitRunChangeKind,
ProjectGitRunChangeSummary,
ProjectGitRunChangedFile,
ProjectGitWorkingTreeFile,
ProjectGitWorkingTreeSnapshot,
} from '@shared/domain/project';
interface DiffStats {
additions: number;
deletions: number;
}
interface BuildProjectGitRunChangeSummaryInput {
generatedAt: string;
preRunSnapshot?: ProjectGitWorkingTreeSnapshot;
preRunBaselineFiles?: readonly ProjectGitBaselineFile[];
postRunSnapshot?: ProjectGitWorkingTreeSnapshot;
postRunBaselineFiles?: readonly ProjectGitBaselineFile[];
}
function parseDiffStats(diff: string | undefined): DiffStats {
if (!diff) {
return { additions: 0, deletions: 0 };
}
let additions = 0;
let deletions = 0;
for (const line of diff.split('\n')) {
if (line.startsWith('+') && !line.startsWith('+++')) {
additions += 1;
} else if (line.startsWith('-') && !line.startsWith('---')) {
deletions += 1;
}
}
return { additions, deletions };
}
function isBinaryDiff(diff: string | undefined): boolean {
if (!diff) {
return false;
}
return diff.includes('GIT binary patch') || diff.includes('Binary files ');
}
function decodeUtf8FromBase64(value: string | undefined): string | undefined {
if (value === undefined) {
return undefined;
}
const buffer = Buffer.from(value, 'base64');
return isUtf8(buffer) ? buffer.toString('utf8') : undefined;
}
function canRestoreBaseline(
baseline: ProjectGitBaselineFile | undefined,
): baseline is ProjectGitBaselineFile {
return baseline !== undefined
&& (baseline.untrackedContentBase64 !== undefined || baseline.combinedDiff !== undefined);
}
function previewFromBaselineFile(
file: Pick<ProjectGitWorkingTreeFile, 'path'>,
baseline: ProjectGitBaselineFile | undefined,
): ProjectGitDiffPreview | undefined {
if (!baseline) {
return undefined;
}
if (baseline.untrackedContentBase64 !== undefined) {
return {
path: file.path,
previousPath: baseline.previousPath,
newFileContents: decodeUtf8FromBase64(baseline.untrackedContentBase64),
...(baseline.isBinary ? { isBinary: true } : {}),
};
}
if (baseline.combinedDiff === undefined && baseline.isBinary !== true) {
return undefined;
}
return {
path: file.path,
previousPath: baseline.previousPath,
...(baseline.combinedDiff && !isBinaryDiff(baseline.combinedDiff)
? { diff: baseline.combinedDiff }
: {}),
...(baseline.isBinary || isBinaryDiff(baseline.combinedDiff) ? { isBinary: true } : {}),
};
}
function sameWorkingTreeFile(
left: ProjectGitWorkingTreeFile,
right: ProjectGitWorkingTreeFile,
): boolean {
return (
left.path === right.path
&& left.previousPath === right.previousPath
&& left.stagedStatus === right.stagedStatus
&& left.unstagedStatus === right.unstagedStatus
&& left.isConflicted === right.isConflicted
);
}
function sameBaselineFile(
left: ProjectGitBaselineFile | undefined,
right: ProjectGitBaselineFile | undefined,
): boolean {
if (!left && !right) {
return true;
}
if (!left || !right) {
return false;
}
return (
left.path === right.path
&& left.previousPath === right.previousPath
&& left.combinedDiff === right.combinedDiff
&& left.untrackedContentBase64 === right.untrackedContentBase64
&& left.isBinary === right.isBinary
);
}
function createRunChangeCounts(): ProjectGitRunChangeCounts {
return {
added: 0,
modified: 0,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 0,
};
}
function incrementRunChangeCount(
counts: ProjectGitRunChangeCounts,
kind: ProjectGitRunChangeKind,
): void {
switch (kind) {
case 'added':
counts.added += 1;
break;
case 'modified':
counts.modified += 1;
break;
case 'deleted':
counts.deleted += 1;
break;
case 'renamed':
counts.renamed += 1;
break;
case 'copied':
counts.copied += 1;
break;
case 'type-changed':
counts.typeChanged += 1;
break;
case 'unmerged':
counts.unmerged += 1;
break;
case 'untracked':
counts.untracked += 1;
break;
case 'cleaned':
counts.cleaned += 1;
break;
}
}
function resolveRunChangeKind(file: ProjectGitWorkingTreeFile): ProjectGitRunChangeKind {
if (file.isConflicted) {
return 'unmerged';
}
return file.unstagedStatus ?? file.stagedStatus ?? 'modified';
}
function sortRunChangedFiles(
left: ProjectGitRunChangedFile,
right: ProjectGitRunChangedFile,
): number {
if (left.origin !== right.origin) {
return left.origin === 'run-created' ? -1 : 1;
}
return left.path.localeCompare(right.path);
}
export function buildProjectGitRunChangeSummary(
input: BuildProjectGitRunChangeSummaryInput,
): ProjectGitRunChangeSummary | undefined {
const {
generatedAt,
preRunSnapshot,
preRunBaselineFiles,
postRunSnapshot,
postRunBaselineFiles,
} = input;
if (!preRunSnapshot || !postRunSnapshot) {
return undefined;
}
const preRunFilesByPath = new Map(
preRunSnapshot.files.map((file) => [file.path, file] satisfies [string, ProjectGitWorkingTreeFile]),
);
const preRunBaselineByPath = new Map(
(preRunBaselineFiles ?? []).map((file) => [file.path, file] satisfies [string, ProjectGitBaselineFile]),
);
const postRunBaselineByPath = new Map(
(postRunBaselineFiles ?? []).map((file) => [file.path, file] satisfies [string, ProjectGitBaselineFile]),
);
const matchedPreRunPaths = new Set<string>();
const files: ProjectGitRunChangedFile[] = [];
for (const postRunFile of postRunSnapshot.files) {
const matchedPreRunFile = preRunFilesByPath.get(postRunFile.path)
?? (postRunFile.previousPath ? preRunFilesByPath.get(postRunFile.previousPath) : undefined);
const matchedPreRunPath = matchedPreRunFile?.path;
const postRunBaseline = postRunBaselineByPath.get(postRunFile.path);
if (!matchedPreRunFile || !matchedPreRunPath) {
const preview = previewFromBaselineFile(postRunFile, postRunBaseline);
const stats = parseDiffStats(preview?.diff);
files.push({
path: postRunFile.path,
previousPath: postRunFile.previousPath,
kind: resolveRunChangeKind(postRunFile),
origin: 'run-created',
stagedStatus: postRunFile.stagedStatus,
unstagedStatus: postRunFile.unstagedStatus,
...(postRunFile.isConflicted ? { isConflicted: true } : {}),
additions: stats.additions,
deletions: stats.deletions,
canRevert: true,
...(preview ? { preview } : {}),
});
continue;
}
matchedPreRunPaths.add(matchedPreRunPath);
const preRunBaseline = preRunBaselineByPath.get(matchedPreRunPath);
if (sameWorkingTreeFile(matchedPreRunFile, postRunFile) && sameBaselineFile(preRunBaseline, postRunBaseline)) {
continue;
}
const preview = previewFromBaselineFile(postRunFile, postRunBaseline);
const stats = parseDiffStats(preview?.diff);
files.push({
path: postRunFile.path,
previousPath: postRunFile.previousPath,
kind: resolveRunChangeKind(postRunFile),
origin: 'pre-existing',
stagedStatus: postRunFile.stagedStatus,
unstagedStatus: postRunFile.unstagedStatus,
...(postRunFile.isConflicted ? { isConflicted: true } : {}),
additions: stats.additions,
deletions: stats.deletions,
canRevert: canRestoreBaseline(preRunBaseline),
...(preview ? { preview } : {}),
});
}
for (const preRunFile of preRunSnapshot.files) {
if (matchedPreRunPaths.has(preRunFile.path)) {
continue;
}
const preRunBaseline = preRunBaselineByPath.get(preRunFile.path);
const preview = previewFromBaselineFile(preRunFile, preRunBaseline);
const stats = parseDiffStats(preview?.diff);
files.push({
path: preRunFile.path,
previousPath: preRunFile.previousPath,
kind: 'cleaned',
origin: 'pre-existing',
stagedStatus: preRunFile.stagedStatus,
unstagedStatus: preRunFile.unstagedStatus,
...(preRunFile.isConflicted ? { isConflicted: true } : {}),
additions: stats.additions,
deletions: stats.deletions,
canRevert: canRestoreBaseline(preRunBaseline),
...(preview ? { preview } : {}),
});
}
const branchChanged = preRunSnapshot.branch !== postRunSnapshot.branch;
if (files.length === 0 && !branchChanged) {
return undefined;
}
files.sort(sortRunChangedFiles);
const counts = createRunChangeCounts();
let additions = 0;
let deletions = 0;
for (const file of files) {
incrementRunChangeCount(counts, file.kind);
additions += file.additions;
deletions += file.deletions;
}
return {
generatedAt,
branchAtStart: preRunSnapshot.branch,
branchAtEnd: postRunSnapshot.branch,
...(branchChanged ? { branchChanged: true } : {}),
fileCount: files.length,
additions,
deletions,
counts,
files,
};
}
+604 -7
View File
@@ -1,9 +1,30 @@
import { isUtf8 } from 'node:buffer';
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { promisify } from 'node:util';
import type { ProjectGitChangeSummary, ProjectGitCommitSummary, ProjectGitContext } from '@shared/domain/project';
import type {
ProjectGitBaselineFile,
ProjectGitBranchSummary,
ProjectGitChangeSummary,
ProjectGitCommitLogEntry,
ProjectGitCommitSummary,
ProjectGitContext,
ProjectGitDetails,
ProjectGitDiffPreview,
ProjectGitFileReference,
ProjectGitRunChangeSummary,
ProjectGitRunChangedFile,
ProjectGitWorkingTreeFile,
ProjectGitWorkingTreeFileStatus,
ProjectGitWorkingTreeSnapshot,
} from '@shared/domain/project';
import { nowIso } from '@shared/utils/ids';
import { buildProjectGitRunChangeSummary } from '@main/git/gitRunChangeSummary';
type ExecFileException = import('node:child_process').ExecFileException;
const require = createRequire(import.meta.url);
@@ -73,6 +94,11 @@ function isNotRepository(error: GitCommandFailure): boolean {
return detail.includes('not a git repository');
}
function isUnknownPathspec(error: GitCommandFailure): boolean {
const detail = `${error.message}\n${error.stderr ?? ''}`.toLowerCase();
return detail.includes('did not match any file') || detail.includes('pathspec');
}
function summarizeGitFailure(error: GitCommandFailure): string {
return error.stderr?.trim() || error.message;
}
@@ -102,9 +128,46 @@ function isConflictedStatus(x: string, y: string): boolean {
);
}
function parseChangeSummary(stdout: string): {
function parseWorkingTreeFileStatus(value: string): ProjectGitWorkingTreeFileStatus | undefined {
switch (value) {
case 'A':
return 'added';
case 'M':
return 'modified';
case 'D':
return 'deleted';
case 'R':
return 'renamed';
case 'C':
return 'copied';
case 'T':
return 'type-changed';
case 'U':
return 'unmerged';
case '?':
return 'untracked';
default:
return undefined;
}
}
function parseWorkingTreePath(rawPath: string): Pick<ProjectGitWorkingTreeFile, 'path' | 'previousPath'> {
const separator = ' -> ';
const separatorIndex = rawPath.indexOf(separator);
if (separatorIndex < 0) {
return { path: rawPath };
}
return {
previousPath: rawPath.slice(0, separatorIndex).trim(),
path: rawPath.slice(separatorIndex + separator.length).trim(),
};
}
function parseWorkingTree(stdout: string): {
changedFileCount: number;
changes: ProjectGitChangeSummary;
files: ProjectGitWorkingTreeFile[];
} {
const summary: ProjectGitChangeSummary = {
staged: 0,
@@ -112,6 +175,7 @@ function parseChangeSummary(stdout: string): {
untracked: 0,
conflicted: 0,
};
const files: ProjectGitWorkingTreeFile[] = [];
const lines = stdout
.split(/\r?\n/)
@@ -122,20 +186,42 @@ function parseChangeSummary(stdout: string): {
for (const line of lines) {
if (line.startsWith('??')) {
const path = line.slice(3).trim();
if (!path) {
continue;
}
summary.untracked += 1;
changedFileCount += 1;
files.push({
path,
unstagedStatus: 'untracked',
});
continue;
}
if (line.length < 2) {
if (line.length < 3) {
continue;
}
const x = line[0];
const y = line[1];
changedFileCount += 1;
const rawPath = line.slice(3).trim();
if (!rawPath) {
continue;
}
if (isConflictedStatus(x, y)) {
changedFileCount += 1;
const isConflicted = isConflictedStatus(x, y);
const pathInfo = parseWorkingTreePath(rawPath);
files.push({
...pathInfo,
stagedStatus: parseWorkingTreeFileStatus(x),
unstagedStatus: parseWorkingTreeFileStatus(y),
...(isConflicted ? { isConflicted: true } : {}),
});
if (isConflicted) {
summary.conflicted += 1;
continue;
}
@@ -152,6 +238,7 @@ function parseChangeSummary(stdout: string): {
return {
changedFileCount,
changes: summary,
files,
};
}
@@ -173,6 +260,122 @@ function parseHead(stdout: string): ProjectGitCommitSummary | undefined {
};
}
function parseBranchList(stdout: string): ProjectGitBranchSummary[] {
return stdout
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
.flatMap((line) => {
const [name, currentMarker, upstream] = line.split('\0');
const trimmedName = name?.trim();
if (!trimmedName) {
return [];
}
return [{
name: trimmedName,
isCurrent: currentMarker?.trim() === '*',
upstream: upstream?.trim() || undefined,
}];
});
}
function parseCommitLog(stdout: string): ProjectGitCommitLogEntry[] {
return stdout
.split('\x1e')
.map((record) => record.trim())
.filter(Boolean)
.flatMap((record) => {
const [hash, shortHash, authorName, subject, committedAt, refNames] = record.split('\0');
if (!hash || !shortHash || !authorName || !subject || !committedAt) {
return [];
}
return [{
hash: hash.trim(),
shortHash: shortHash.trim(),
authorName: authorName.trim(),
subject: subject.trim(),
committedAt: committedAt.trim(),
refNames: refNames?.trim() || undefined,
}];
});
}
function isPureUntrackedFile(file: ProjectGitWorkingTreeFile): boolean {
return file.stagedStatus === undefined && file.unstagedStatus === 'untracked';
}
function buildGitPaths(file: ProjectGitFileReference): string[] {
const paths = new Set<string>();
if (file.previousPath?.trim()) {
paths.add(file.previousPath.trim());
}
if (file.path.trim()) {
paths.add(file.path.trim());
}
return [...paths];
}
function uniqueGitPaths(files: readonly ProjectGitFileReference[]): string[] {
const paths = new Set<string>();
for (const file of files) {
for (const path of buildGitPaths(file)) {
paths.add(path);
}
}
return [...paths];
}
function isBinaryDiff(diff: string | undefined): boolean {
if (!diff) {
return false;
}
return diff.includes('GIT binary patch') || diff.includes('Binary files ');
}
function canRestoreBaseline(
baseline: ProjectGitBaselineFile | undefined,
): baseline is ProjectGitBaselineFile {
return baseline !== undefined
&& (baseline.untrackedContentBase64 !== undefined || baseline.combinedDiff !== undefined);
}
function baselineToPreview(
file: Pick<ProjectGitFileReference, 'path' | 'previousPath'>,
baseline: ProjectGitBaselineFile | undefined,
): ProjectGitDiffPreview | undefined {
if (!baseline) {
return undefined;
}
if (baseline.untrackedContentBase64 !== undefined) {
const contentBuffer = Buffer.from(baseline.untrackedContentBase64, 'base64');
return {
path: file.path,
previousPath: file.previousPath,
...(isUtf8(contentBuffer) ? { newFileContents: contentBuffer.toString('utf8') } : {}),
...(baseline.isBinary ? { isBinary: true } : {}),
};
}
if (baseline.combinedDiff === undefined && baseline.isBinary !== true) {
return undefined;
}
return {
path: file.path,
previousPath: file.previousPath,
...(baseline.combinedDiff && !isBinaryDiff(baseline.combinedDiff)
? { diff: baseline.combinedDiff }
: {}),
...(baseline.isBinary || isBinaryDiff(baseline.combinedDiff) ? { isBinary: true } : {}),
};
}
export class GitService {
constructor(private readonly runGitCommand: GitCommandRunner = defaultGitCommandRunner) {}
@@ -219,7 +422,7 @@ export class GitService {
this.tryRun(projectPath, ['log', '-1', '--format=%H%n%h%n%s%n%cI']),
]);
const { changedFileCount, changes } = parseChangeSummary(statusResult.stdout);
const { changedFileCount, changes } = parseWorkingTree(statusResult.stdout);
const upstream = upstreamResult.ok ? upstreamResult.stdout.trim() || undefined : undefined;
const aheadBehind = countsResult.ok ? parseAheadBehind(countsResult.stdout) : {};
@@ -238,11 +441,405 @@ export class GitService {
};
}
async describeProjectGitDetails(
projectPath: string,
scannedAt = nowIso(),
commitLimit = 20,
): Promise<ProjectGitDetails> {
const context = await this.describeProject(projectPath, scannedAt);
if (context.status !== 'ready') {
return {
scannedAt,
context,
branches: [],
recentCommits: [],
};
}
const [workingTree, branches, recentCommits] = await Promise.all([
this.captureWorkingTreeSnapshot(projectPath, scannedAt),
this.listBranches(projectPath),
this.listRecentCommits(projectPath, commitLimit),
]);
return {
scannedAt,
context,
workingTree: workingTree ?? undefined,
branches,
recentCommits,
};
}
async captureWorkingTreeSnapshot(
projectPath: string,
scannedAt = nowIso(),
): Promise<ProjectGitWorkingTreeSnapshot | undefined> {
const repoRootResult = await this.tryRun(projectPath, ['rev-parse', '--show-toplevel']);
if (!repoRootResult.ok) {
return undefined;
}
const statusResult = await this.tryRun(projectPath, ['status', '--porcelain=1', '--untracked-files=all']);
if (!statusResult.ok) {
return undefined;
}
const branchResult = await this.tryRun(projectPath, ['branch', '--show-current']);
const { changedFileCount, changes, files } = parseWorkingTree(statusResult.stdout);
return {
scannedAt,
repoRoot: repoRootResult.stdout.trim(),
branch: branchResult.ok ? parseBranch(branchResult.stdout) : undefined,
changedFileCount,
changes,
files,
};
}
async captureWorkingTreeBaseline(
projectPath: string,
snapshot?: ProjectGitWorkingTreeSnapshot,
): Promise<ProjectGitBaselineFile[]> {
const effectiveSnapshot = snapshot ?? await this.captureWorkingTreeSnapshot(projectPath);
if (!effectiveSnapshot || effectiveSnapshot.files.length === 0) {
return [];
}
const baselineFiles = await Promise.all(
effectiveSnapshot.files.map((file) => this.captureBaselineFile(projectPath, file)),
);
return baselineFiles.flatMap((file) => (file ? [file] : []));
}
async computeRunChangeSummary(
projectPath: string,
options: {
generatedAt?: string;
preRunSnapshot?: ProjectGitWorkingTreeSnapshot;
preRunBaselineFiles?: readonly ProjectGitBaselineFile[];
},
): Promise<ProjectGitRunChangeSummary | undefined> {
const generatedAt = options.generatedAt ?? nowIso();
const postRunSnapshot = await this.captureWorkingTreeSnapshot(projectPath, generatedAt);
if (!options.preRunSnapshot || !postRunSnapshot) {
return undefined;
}
const postRunBaselineFiles = await this.captureWorkingTreeBaseline(projectPath, postRunSnapshot);
return buildProjectGitRunChangeSummary({
generatedAt,
preRunSnapshot: options.preRunSnapshot,
preRunBaselineFiles: options.preRunBaselineFiles,
postRunSnapshot,
postRunBaselineFiles,
});
}
async getWorkingTreeFilePreview(
projectPath: string,
file: ProjectGitFileReference,
): Promise<ProjectGitDiffPreview | undefined> {
const snapshot = await this.captureWorkingTreeSnapshot(projectPath);
if (!snapshot) {
return undefined;
}
const matchedFile = snapshot.files.find((candidate) =>
candidate.path === file.path
|| candidate.previousPath === file.path
|| (file.previousPath !== undefined && candidate.path === file.previousPath)
|| (file.previousPath !== undefined && candidate.previousPath === file.previousPath));
if (!matchedFile) {
return undefined;
}
const baseline = await this.captureBaselineFile(projectPath, matchedFile);
return baselineToPreview(matchedFile, baseline);
}
async stageFiles(projectPath: string, files: readonly ProjectGitFileReference[]): Promise<void> {
const paths = uniqueGitPaths(files);
if (paths.length === 0) {
return;
}
await this.run(projectPath, ['add', '--', ...paths]);
}
async unstageFiles(projectPath: string, files: readonly ProjectGitFileReference[]): Promise<void> {
const paths = uniqueGitPaths(files);
if (paths.length === 0) {
return;
}
await this.run(projectPath, ['restore', '--staged', '--', ...paths]);
}
async commit(projectPath: string, message: string): Promise<ProjectGitCommitSummary> {
await this.run(projectPath, ['commit', '-m', message]);
const head = await this.getHeadCommit(projectPath);
if (!head) {
throw new Error('Git commit completed, but the new HEAD commit could not be resolved.');
}
return head;
}
async push(projectPath: string): Promise<void> {
await this.run(projectPath, ['push']);
}
async fetch(projectPath: string): Promise<void> {
await this.run(projectPath, ['fetch', '--all', '--prune']);
}
async pull(projectPath: string, rebase = false): Promise<void> {
await this.run(projectPath, rebase ? ['pull', '--rebase'] : ['pull']);
}
async createBranch(
projectPath: string,
name: string,
startPoint?: string,
checkout = true,
): Promise<void> {
const trimmedName = name.trim();
if (!trimmedName) {
throw new Error('A branch name is required.');
}
if (checkout) {
await this.run(
projectPath,
['switch', '-c', trimmedName, ...(startPoint?.trim() ? [startPoint.trim()] : [])],
);
return;
}
await this.run(
projectPath,
['branch', trimmedName, ...(startPoint?.trim() ? [startPoint.trim()] : [])],
);
}
async switchBranch(projectPath: string, name: string): Promise<void> {
const trimmedName = name.trim();
if (!trimmedName) {
throw new Error('A branch name is required.');
}
await this.run(projectPath, ['switch', trimmedName]);
}
async deleteBranch(projectPath: string, name: string, force = false): Promise<void> {
const trimmedName = name.trim();
if (!trimmedName) {
throw new Error('A branch name is required.');
}
await this.run(projectPath, ['branch', force ? '-D' : '-d', trimmedName]);
}
async listBranches(projectPath: string): Promise<ProjectGitBranchSummary[]> {
const result = await this.tryRun(projectPath, [
'for-each-ref',
'--format=%(refname:short)%00%(HEAD)%00%(upstream:short)',
'refs/heads',
]);
return result.ok ? parseBranchList(result.stdout) : [];
}
async listRecentCommits(projectPath: string, limit = 20): Promise<ProjectGitCommitLogEntry[]> {
const result = await this.tryRun(projectPath, [
'log',
`-n${Math.max(1, Math.round(limit))}`,
'--format=%H%x00%h%x00%an%x00%s%x00%cI%x00%D%x1e',
]);
return result.ok ? parseCommitLog(result.stdout) : [];
}
async discardRunChanges(
projectPath: string,
options: {
summary: ProjectGitRunChangeSummary;
preRunBaselineFiles?: readonly ProjectGitBaselineFile[];
files?: readonly ProjectGitFileReference[];
},
): Promise<void> {
const selectedFiles = options.files && options.files.length > 0
? options.summary.files.filter((candidate) =>
options.files?.some((selected) =>
selected.path === candidate.path
|| selected.path === candidate.previousPath
|| (selected.previousPath !== undefined && selected.previousPath === candidate.previousPath)))
: options.summary.files;
if (selectedFiles.length === 0) {
return;
}
const baselinesByPath = new Map(
(options.preRunBaselineFiles ?? []).map((file) => [file.path, file] satisfies [string, ProjectGitBaselineFile]),
);
for (const file of selectedFiles) {
if (file.origin === 'pre-existing') {
if (!file.canRevert) {
throw new Error(`Cannot restore "${file.path}" to its pre-run state because no restorable baseline was captured.`);
}
const baseline = baselinesByPath.get(file.previousPath ?? file.path) ?? baselinesByPath.get(file.path);
if (!canRestoreBaseline(baseline)) {
throw new Error(`Cannot restore "${file.path}" to its pre-run state because no restorable baseline was captured.`);
}
await this.restorePreExistingChange(projectPath, file, baseline);
continue;
}
await this.restoreRunCreatedChange(projectPath, file);
}
}
private async captureBaselineFile(
projectPath: string,
file: ProjectGitWorkingTreeFile,
): Promise<ProjectGitBaselineFile | undefined> {
if (!file.path.trim()) {
return undefined;
}
if (isPureUntrackedFile(file)) {
try {
const contents = await readFile(join(projectPath, file.path));
return {
path: file.path,
previousPath: file.previousPath,
untrackedContentBase64: contents.toString('base64'),
...(isUtf8(contents) ? {} : { isBinary: true }),
};
} catch {
return {
path: file.path,
previousPath: file.previousPath,
};
}
}
const diffPaths = buildGitPaths(file);
const diffResult = await this.tryRun(projectPath, [
'diff',
'--binary',
'--no-ext-diff',
'--no-renames',
'HEAD',
'--',
...diffPaths,
]);
if (!diffResult.ok) {
return {
path: file.path,
previousPath: file.previousPath,
};
}
return {
path: file.path,
previousPath: file.previousPath,
combinedDiff: diffResult.stdout.trim() ? diffResult.stdout : undefined,
...(isBinaryDiff(diffResult.stdout) ? { isBinary: true } : {}),
};
}
private async getHeadCommit(projectPath: string): Promise<ProjectGitCommitSummary | undefined> {
const result = await this.tryRun(projectPath, ['log', '-1', '--format=%H%n%h%n%s%n%cI']);
return result.ok ? parseHead(result.stdout) : undefined;
}
private async restoreRunCreatedChange(
projectPath: string,
file: ProjectGitRunChangedFile,
): Promise<void> {
if (file.kind === 'renamed' && file.previousPath) {
await this.restorePathFromHead(projectPath, file.previousPath);
await this.removePath(projectPath, file.path);
return;
}
if (file.kind === 'added' || file.kind === 'untracked' || file.kind === 'copied') {
await this.removePath(projectPath, file.path);
return;
}
await this.restorePathFromHead(projectPath, file.path);
}
private async restorePreExistingChange(
projectPath: string,
file: ProjectGitRunChangedFile,
baseline: ProjectGitBaselineFile,
): Promise<void> {
await this.restorePathFromHead(projectPath, baseline.path);
if (file.path !== baseline.path) {
await this.removePath(projectPath, file.path);
}
if (baseline.untrackedContentBase64 !== undefined) {
const contents = Buffer.from(baseline.untrackedContentBase64, 'base64');
await mkdir(dirname(join(projectPath, baseline.path)), { recursive: true });
await writeFile(join(projectPath, baseline.path), contents);
return;
}
if (baseline.combinedDiff) {
await this.applyPatch(projectPath, baseline.combinedDiff);
}
}
private async restorePathFromHead(projectPath: string, path: string): Promise<void> {
const result = await this.tryRun(projectPath, ['restore', '--source=HEAD', '--staged', '--worktree', '--', path]);
if (!result.ok && !isUnknownPathspec(result.error)) {
throw result.error;
}
}
private async removePath(projectPath: string, path: string): Promise<void> {
const unstageResult = await this.tryRun(projectPath, ['rm', '--cached', '--force', '--ignore-unmatch', '--', path]);
if (!unstageResult.ok && !isUnknownPathspec(unstageResult.error)) {
throw unstageResult.error;
}
await rm(join(projectPath, path), { force: true });
}
private async applyPatch(projectPath: string, diff: string): Promise<void> {
const tempDirectory = await mkdtemp(join(tmpdir(), 'aryx-git-patch-'));
const patchPath = join(tempDirectory, 'restore.diff');
try {
await writeFile(patchPath, diff, 'utf8');
await this.run(projectPath, ['apply', '--whitespace=nowarn', '--recount', patchPath]);
} finally {
await rm(tempDirectory, { force: true, recursive: true });
}
}
private async run(projectPath: string, args: string[]): Promise<string> {
try {
return await this.runGitCommand(projectPath, args);
} catch (error) {
throw createGitCommandFailure(projectPath, args, error);
}
}
private async tryRun(projectPath: string, args: string[]): Promise<GitCommandResult> {
try {
return {
ok: true,
stdout: await this.runGitCommand(projectPath, args),
stdout: await this.run(projectPath, args),
};
} catch (error) {
return {
+74
View File
@@ -6,12 +6,23 @@ import type {
BranchSessionInput,
CancelSessionTurnInput,
CreateSessionInput,
CreateProjectGitBranchInput,
DismissSessionMcpAuthInput,
DismissSessionPlanReviewInput,
DeleteProjectGitBranchInput,
DeleteSessionInput,
DiscardSessionRunGitChangesInput,
EditAndResendSessionMessageInput,
CommitProjectGitChangesInput,
ProjectGitDetailsInput,
ProjectGitFilePreviewInput,
ProjectGitFileSelectionInput,
ProjectGitInput,
PullProjectGitInput,
RegenerateSessionMessageInput,
StartSessionMcpAuthInput,
SuggestProjectGitCommitMessageInput,
SwitchProjectGitBranchInput,
DuplicateSessionInput,
RenameSessionInput,
RescanProjectConfigsInput,
@@ -52,6 +63,12 @@ export function registerIpcHandlers(
service: AryxAppService,
autoUpdateService: AutoUpdateService,
): void {
window.on('focus', () => {
if (service.isGitAutoRefreshEnabled()) {
service.scheduleProjectGitRefresh();
}
});
ipcMain.handle(ipcChannels.describeSidecarCapabilities, () => service.describeSidecarCapabilities());
ipcMain.handle(ipcChannels.refreshSidecarCapabilities, () => service.refreshSidecarCapabilities());
ipcMain.handle(ipcChannels.loadWorkspace, () => service.loadWorkspace());
@@ -65,6 +82,12 @@ export function registerIpcHandlers(
ipcMain.handle(ipcChannels.refreshProjectGitContext, (_event, projectId?: string) =>
service.refreshProjectGitContext(projectId),
);
ipcMain.handle(ipcChannels.getProjectGitDetails, (_event, input: ProjectGitDetailsInput) =>
service.getProjectGitDetails(input.projectId, input.commitLimit),
);
ipcMain.handle(ipcChannels.getProjectGitFilePreview, (_event, input: ProjectGitFilePreviewInput) =>
service.getProjectGitFilePreview(input.projectId, input.file),
);
ipcMain.handle(ipcChannels.rescanProjectConfigs, (_event, input: RescanProjectConfigsInput) =>
service.rescanProjectConfigs(input.projectId),
);
@@ -105,6 +128,10 @@ export function registerIpcHandlers(
ipcChannels.setMinimizeToTray,
(_event, enabled: boolean) => service.setMinimizeToTray(enabled),
);
ipcMain.handle(
ipcChannels.setGitAutoRefreshEnabled,
(_event, enabled: boolean) => service.setGitAutoRefreshEnabled(enabled),
);
ipcMain.handle(ipcChannels.checkForUpdates, () => autoUpdateService.checkForUpdates());
ipcMain.handle(ipcChannels.installUpdate, () => {
autoUpdateService.installUpdate();
@@ -197,11 +224,58 @@ export function registerIpcHandlers(
ipcMain.handle(ipcChannels.startSessionMcpAuth, (_event, input: StartSessionMcpAuthInput) =>
service.startSessionMcpAuth(input.sessionId),
);
ipcMain.handle(
ipcChannels.discardSessionRunGitChanges,
(_event, input: DiscardSessionRunGitChangesInput) =>
service.discardSessionRunGitChanges(input.sessionId, input.runId, input.files),
);
ipcMain.handle(
ipcChannels.suggestProjectGitCommitMessage,
(_event, input: SuggestProjectGitCommitMessageInput) =>
service.suggestProjectGitCommitMessage(input.sessionId, input.runId, input.conventionalType),
);
ipcMain.handle(
ipcChannels.updateSessionModelConfig,
(_event, input: UpdateSessionModelConfigInput) =>
service.updateSessionModelConfig(input.sessionId, input.model, input.reasoningEffort),
);
ipcMain.handle(
ipcChannels.stageProjectGitFiles,
(_event, input: ProjectGitFileSelectionInput) => service.stageProjectGitFiles(input.projectId, input.files),
);
ipcMain.handle(
ipcChannels.unstageProjectGitFiles,
(_event, input: ProjectGitFileSelectionInput) => service.unstageProjectGitFiles(input.projectId, input.files),
);
ipcMain.handle(
ipcChannels.commitProjectGitChanges,
(_event, input: CommitProjectGitChangesInput) =>
service.commitProjectGitChanges(input.projectId, input.message, input.files, input.push),
);
ipcMain.handle(ipcChannels.pushProjectGit, (_event, input: ProjectGitInput) =>
service.pushProjectGit(input.projectId),
);
ipcMain.handle(ipcChannels.fetchProjectGit, (_event, input: ProjectGitInput) =>
service.fetchProjectGit(input.projectId),
);
ipcMain.handle(ipcChannels.pullProjectGit, (_event, input: PullProjectGitInput) =>
service.pullProjectGit(input.projectId, input.rebase),
);
ipcMain.handle(
ipcChannels.createProjectGitBranch,
(_event, input: CreateProjectGitBranchInput) =>
service.createProjectGitBranch(input.projectId, input.name, input.startPoint, input.checkout),
);
ipcMain.handle(
ipcChannels.switchProjectGitBranch,
(_event, input: SwitchProjectGitBranchInput) =>
service.switchProjectGitBranch(input.projectId, input.name),
);
ipcMain.handle(
ipcChannels.deleteProjectGitBranch,
(_event, input: DeleteProjectGitBranchInput) =>
service.deleteProjectGitBranch(input.projectId, input.name, input.force),
);
ipcMain.handle(ipcChannels.querySessions, (_event, input: QuerySessionsInput) => service.querySessions(input));
ipcMain.handle(ipcChannels.selectProject, (_event, projectId?: string) => service.selectProject(projectId));
ipcMain.handle(ipcChannels.selectPattern, (_event, patternId?: string) => service.selectPattern(patternId));
+4 -6
View File
@@ -23,6 +23,7 @@ type AutoUpdateListener = (...args: any[]) => void;
interface AutoUpdaterLike {
autoDownload: boolean;
autoInstallOnAppQuit: boolean;
forceDevUpdateConfig: boolean;
on(event: string, listener: AutoUpdateListener): this;
removeListener(event: string, listener: AutoUpdateListener): this;
checkForUpdates(): Promise<unknown>;
@@ -151,7 +152,7 @@ export class AutoUpdateService {
};
private readonly notAvailableListener = () => {
this.publishStatus({ state: 'idle' });
this.publishStatus({ state: 'up-to-date' });
};
private readonly progressListener = (progress: AutoUpdateProgressLike) => {
@@ -180,6 +181,7 @@ export class AutoUpdateService {
this.scheduler = options.scheduler ?? defaultScheduler;
this.updater.autoDownload = true;
this.updater.autoInstallOnAppQuit = false;
this.updater.forceDevUpdateConfig = !options.isPackaged;
this.updater.on('checking-for-update', this.checkingListener);
this.updater.on('update-available', this.availableListener);
@@ -190,7 +192,7 @@ export class AutoUpdateService {
}
start(): void {
if (this.started || !this.options.isPackaged) {
if (this.started) {
return;
}
@@ -215,10 +217,6 @@ export class AutoUpdateService {
}
async checkForUpdates(): Promise<UpdateStatus> {
if (!this.options.isPackaged) {
return this.getStatus();
}
if (this.pendingCheck) {
return this.pendingCheck;
}
+11 -1
View File
@@ -3,6 +3,7 @@ import type {
ApprovalRequestedEvent,
ExitPlanModeRequestedEvent,
McpOauthRequiredEvent,
MessageReclassifiedEvent,
TurnDeltaEvent,
UserInputRequestedEvent,
SubagentEvent,
@@ -11,7 +12,11 @@ import type {
SessionUsageEvent,
SessionCompactionEvent,
PendingMessagesModifiedEvent,
WorkflowCheckpointSavedEvent,
AssistantUsageEvent,
AssistantIntentEvent,
ReasoningDeltaEvent,
WorkflowDiagnosticEvent,
} from '@shared/contracts/sidecar';
import type { ChatMessageRecord } from '@shared/domain/session';
@@ -22,7 +27,11 @@ export type TurnScopedEvent =
| SessionUsageEvent
| SessionCompactionEvent
| PendingMessagesModifiedEvent
| AssistantUsageEvent;
| WorkflowCheckpointSavedEvent
| AssistantUsageEvent
| AssistantIntentEvent
| ReasoningDeltaEvent
| WorkflowDiagnosticEvent;
export interface RunTurnPendingCommand {
kind: 'run-turn';
@@ -34,6 +43,7 @@ export interface RunTurnPendingCommand {
onUserInput: (event: UserInputRequestedEvent) => void | Promise<void>;
onMcpOAuthRequired: (event: McpOauthRequiredEvent) => void | Promise<void>;
onExitPlanMode: (event: ExitPlanModeRequestedEvent) => void | Promise<void>;
onMessageReclassified: (event: MessageReclassifiedEvent) => void | Promise<void>;
onTurnScopedEvent: (event: TurnScopedEvent) => void | Promise<void>;
errored: boolean;
}
+17 -4
View File
@@ -9,6 +9,7 @@ import type {
SidecarCapabilities,
SidecarEvent,
TurnDeltaEvent,
MessageReclassifiedEvent,
UserInputRequestedEvent,
McpOauthRequiredEvent,
ExitPlanModeRequestedEvent,
@@ -134,9 +135,10 @@ export class SidecarClient {
onUserInput: (event: UserInputRequestedEvent) => void | Promise<void>,
onMcpOAuthRequired: (event: McpOauthRequiredEvent) => void | Promise<void>,
onExitPlanMode: (event: ExitPlanModeRequestedEvent) => void | Promise<void>,
onMessageReclassified: (event: MessageReclassifiedEvent) => void | Promise<void>,
onTurnScopedEvent: (event: TurnScopedEvent) => void | Promise<void>,
): Promise<ChatMessageRecord[]> {
return this.dispatch<ChatMessageRecord[]>(command, onDelta, onActivity, onApproval, onUserInput, onMcpOAuthRequired, onExitPlanMode, onTurnScopedEvent);
return this.dispatch<ChatMessageRecord[]>(command, onDelta, onActivity, onApproval, onUserInput, onMcpOAuthRequired, onExitPlanMode, onMessageReclassified, onTurnScopedEvent);
}
async resolveUserInput(userInputId: string, answer: string, wasFreeform: boolean): Promise<void> {
@@ -286,6 +288,7 @@ export class SidecarClient {
onUserInput?: (event: UserInputRequestedEvent) => void | Promise<void>,
onMcpOAuthRequired?: (event: McpOauthRequiredEvent) => void | Promise<void>,
onExitPlanMode?: (event: ExitPlanModeRequestedEvent) => void | Promise<void>,
onMessageReclassified?: (event: MessageReclassifiedEvent) => void | Promise<void>,
onTurnScopedEvent?: (event: TurnScopedEvent) => void | Promise<void>,
): Promise<TResult> {
const state = await this.ensureProcess();
@@ -303,6 +306,7 @@ export class SidecarClient {
onUserInput: onUserInput ?? (() => undefined),
onMcpOAuthRequired: onMcpOAuthRequired ?? (() => undefined),
onExitPlanMode: onExitPlanMode ?? (() => undefined),
onMessageReclassified: onMessageReclassified ?? (() => undefined),
onTurnScopedEvent: onTurnScopedEvent ?? (() => undefined),
errored: false,
});
@@ -439,13 +443,22 @@ export class SidecarClient {
this.invokeRunTurnHandler(event.requestId, pending, () => pending.onExitPlanMode(event));
}
return;
case 'message-reclassified':
if (pending.kind === 'run-turn' && shouldHandleRunTurnEvent(pending)) {
this.invokeRunTurnHandler(event.requestId, pending, () => pending.onMessageReclassified(event));
}
return;
case 'subagent-event':
case 'skill-invoked':
case 'hook-lifecycle':
case 'session-usage':
case 'session-compaction':
case 'pending-messages-modified':
case 'assistant-usage':
case 'session-compaction':
case 'pending-messages-modified':
case 'workflow-checkpoint-saved':
case 'workflow-diagnostic':
case 'assistant-usage':
case 'assistant-intent':
case 'reasoning-delta':
if (pending.kind === 'run-turn' && shouldHandleRunTurnEvent(pending)) {
this.invokeRunTurnHandler(event.requestId, pending, () => pending.onTurnScopedEvent(event));
}
+3
View File
@@ -21,6 +21,9 @@ export function createMainWindow(): BrowserWindowType {
}),
backgroundColor: '#09090b',
titleBarStyle: 'hidden',
...(process.platform === 'darwin' && {
trafficLightPosition: { x: 16, y: 22 },
}),
titleBarOverlay: {
color: '#09090b',
symbolColor: '#a1a1aa',
+14
View File
@@ -14,6 +14,8 @@ const api: ElectronApi = {
resolveWorkspaceDiscoveredTooling: (input) =>
ipcRenderer.invoke(ipcChannels.resolveWorkspaceDiscoveredTooling, input),
refreshProjectGitContext: (projectId) => ipcRenderer.invoke(ipcChannels.refreshProjectGitContext, projectId),
getProjectGitDetails: (input) => ipcRenderer.invoke(ipcChannels.getProjectGitDetails, input),
getProjectGitFilePreview: (input) => ipcRenderer.invoke(ipcChannels.getProjectGitFilePreview, input),
rescanProjectConfigs: (input) => ipcRenderer.invoke(ipcChannels.rescanProjectConfigs, input),
rescanProjectCustomization: (input) =>
ipcRenderer.invoke(ipcChannels.rescanProjectCustomization, input),
@@ -28,6 +30,7 @@ const api: ElectronApi = {
setTerminalHeight: (input) => ipcRenderer.invoke(ipcChannels.setTerminalHeight, input),
setNotificationsEnabled: (enabled) => ipcRenderer.invoke(ipcChannels.setNotificationsEnabled, enabled),
setMinimizeToTray: (enabled) => ipcRenderer.invoke(ipcChannels.setMinimizeToTray, enabled),
setGitAutoRefreshEnabled: (enabled) => ipcRenderer.invoke(ipcChannels.setGitAutoRefreshEnabled, enabled),
checkForUpdates: () => ipcRenderer.invoke(ipcChannels.checkForUpdates),
installUpdate: () => ipcRenderer.invoke(ipcChannels.installUpdate),
saveMcpServer: (input) => ipcRenderer.invoke(ipcChannels.saveMcpServer, input),
@@ -65,9 +68,20 @@ const api: ElectronApi = {
dismissSessionPlanReview: (input) => ipcRenderer.invoke(ipcChannels.dismissSessionPlanReview, input),
dismissSessionMcpAuth: (input) => ipcRenderer.invoke(ipcChannels.dismissSessionMcpAuth, input),
startSessionMcpAuth: (input) => ipcRenderer.invoke(ipcChannels.startSessionMcpAuth, input),
discardSessionRunGitChanges: (input) => ipcRenderer.invoke(ipcChannels.discardSessionRunGitChanges, input),
suggestProjectGitCommitMessage: (input) => ipcRenderer.invoke(ipcChannels.suggestProjectGitCommitMessage, input),
updateSessionModelConfig: (input) =>
ipcRenderer.invoke(ipcChannels.updateSessionModelConfig, input),
querySessions: (input) => ipcRenderer.invoke(ipcChannels.querySessions, input),
stageProjectGitFiles: (input) => ipcRenderer.invoke(ipcChannels.stageProjectGitFiles, input),
unstageProjectGitFiles: (input) => ipcRenderer.invoke(ipcChannels.unstageProjectGitFiles, input),
commitProjectGitChanges: (input) => ipcRenderer.invoke(ipcChannels.commitProjectGitChanges, input),
pushProjectGit: (input) => ipcRenderer.invoke(ipcChannels.pushProjectGit, input),
fetchProjectGit: (input) => ipcRenderer.invoke(ipcChannels.fetchProjectGit, input),
pullProjectGit: (input) => ipcRenderer.invoke(ipcChannels.pullProjectGit, input),
createProjectGitBranch: (input) => ipcRenderer.invoke(ipcChannels.createProjectGitBranch, input),
switchProjectGitBranch: (input) => ipcRenderer.invoke(ipcChannels.switchProjectGitBranch, input),
deleteProjectGitBranch: (input) => ipcRenderer.invoke(ipcChannels.deleteProjectGitBranch, input),
selectProject: (projectId) => ipcRenderer.invoke(ipcChannels.selectProject, projectId),
selectPattern: (patternId) => ipcRenderer.invoke(ipcChannels.selectPattern, patternId),
selectSession: (sessionId) => ipcRenderer.invoke(ipcChannels.selectSession, sessionId),
+138 -25
View File
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { CommitComposer } from '@renderer/components/chat/CommitComposer';
import { AppShell } from '@renderer/components/AppShell';
import { ActivityPanel } from '@renderer/components/ActivityPanel';
import { ChatPane } from '@renderer/components/ChatPane';
@@ -8,10 +9,13 @@ import { DiscoveredToolingModal } from '@renderer/components/DiscoveredToolingMo
import { KeyboardShortcutsPanel } from '@renderer/components/KeyboardShortcutsPanel';
import { NewSessionModal } from '@renderer/components/NewSessionModal';
import { ProjectSettingsPanel } from '@renderer/components/ProjectSettingsPanel';
import { BookmarksPanel } from '@renderer/components/BookmarksPanel';
import { SessionSearchPanel } from '@renderer/components/SessionSearchPanel';
import { SettingsPanel } from '@renderer/components/SettingsPanel';
import { SettingsPanel, type SettingsSection } from '@renderer/components/SettingsPanel';
import { Sidebar } from '@renderer/components/Sidebar';
import { TerminalPanel, DEFAULT_HEIGHT as DEFAULT_TERMINAL_HEIGHT, MIN_HEIGHT as MIN_TERMINAL_HEIGHT } from '@renderer/components/TerminalPanel';
import { BottomPanel, DEFAULT_HEIGHT as DEFAULT_BOTTOM_HEIGHT, MIN_HEIGHT as MIN_BOTTOM_HEIGHT, type BottomPanelTab } from '@renderer/components/BottomPanel';
import { GitPanel } from '@renderer/components/GitPanel';
import { TerminalPanel } from '@renderer/components/TerminalPanel';
import { resolveChatToolingSettings } from '@renderer/lib/chatTooling';
import {
applySessionEventActivity,
@@ -42,9 +46,11 @@ import { createDefaultToolApprovalPolicy } from '@shared/domain/approval';
import { listPendingDiscoveredMcpServers } from '@shared/domain/discoveredTooling';
import { syncPatternGraph, type PatternDefinition } from '@shared/domain/pattern';
import { isScratchpadProject, SCRATCHPAD_PROJECT_ID } from '@shared/domain/project';
import type { ProjectGitFileReference } from '@shared/domain/project';
import { applySessionModelConfig } from '@shared/domain/session';
import type { AppearanceTheme, LspProfileDefinition, McpServerDefinition } from '@shared/domain/tooling';
import type { WorkspaceState } from '@shared/domain/workspace';
import type { UpdateStatus } from '@shared/contracts/ipc';
import { createId, nowIso } from '@shared/utils/ids';
function createDraftPattern(defaultModelId: string, defaultReasoningEffort: PatternDefinition['agents'][0]['reasoningEffort']): PatternDefinition {
@@ -112,19 +118,27 @@ export default function App() {
const [activeSubagents, setActiveSubagents] = useState<ActiveSubagentMap>({});
const [showSettings, setShowSettings] = useState(false);
const [settingsSection, setSettingsSection] = useState<SettingsSection>();
const [updateStatus, setUpdateStatus] = useState<UpdateStatus>({ state: 'idle' });
const [projectSettingsId, setProjectSettingsId] = useState<string>();
const [newSessionProjectId, setNewSessionProjectId] = useState<string>();
const [showDiscoveryModal, setShowDiscoveryModal] = useState(false);
const [commandPaletteOpen, setCommandPaletteOpen] = useState(false);
const [showShortcuts, setShowShortcuts] = useState(false);
const [showSearch, setShowSearch] = useState(false);
const [showBookmarks, setShowBookmarks] = useState(false);
// Terminal state
const [terminalOpen, setTerminalOpen] = useState(false);
const [terminalHeight, setTerminalHeight] = useState(
() => workspace?.settings.terminalHeight ?? DEFAULT_TERMINAL_HEIGHT,
// Commit composer state
const [commitComposerCtx, setCommitComposerCtx] = useState<{ projectId: string; sessionId: string; runId?: string }>();
// Bottom panel state (terminal + git)
const [bottomPanelOpen, setBottomPanelOpen] = useState(false);
const [bottomPanelTab, setBottomPanelTab] = useState<BottomPanelTab>('terminal');
const [bottomPanelHeight, setBottomPanelHeight] = useState(
() => workspace?.settings.terminalHeight ?? DEFAULT_BOTTOM_HEIGHT,
);
const [terminalRunning, setTerminalRunning] = useState(false);
const [gitDirty, setGitDirty] = useState(false);
// Load workspace on mount
useEffect(() => {
@@ -186,6 +200,12 @@ export default function App() {
};
}, [api]);
// Subscribe to auto-update status pushes from the main process
useEffect(() => {
const off = api.onUpdateStatus((status) => setUpdateStatus(status));
return off;
}, [api]);
// Apply theme to the document root
const themeSetting: AppearanceTheme = workspace?.settings.theme ?? 'dark';
useTheme(themeSetting);
@@ -299,7 +319,7 @@ export default function App() {
// ── Ctrl+` — Toggle terminal ──
if (e.ctrlKey && e.key === '`') {
e.preventDefault();
setTerminalOpen((prev) => !prev);
handleTerminalToggle();
return;
}
@@ -324,6 +344,13 @@ export default function App() {
return;
}
// ── Ctrl/Cmd+Shift+B — Bookmarks ──
if (mod && e.shiftKey && e.key === 'B') {
e.preventDefault();
setShowBookmarks((prev) => !prev);
return;
}
// ── Ctrl/Cmd+, — Open settings ──
if (mod && e.key === ',') {
e.preventDefault();
@@ -439,26 +466,38 @@ export default function App() {
};
}, [api]);
// Sync terminalHeight from workspace settings when workspace loads
// Sync bottom panel height from workspace settings when workspace loads
useEffect(() => {
if (workspace?.settings.terminalHeight) {
setTerminalHeight(workspace.settings.terminalHeight);
setBottomPanelHeight(workspace.settings.terminalHeight);
}
}, [workspace?.settings.terminalHeight]);
const handleTerminalHeightChange = useCallback((newHeight: number) => {
const clamped = Math.max(MIN_TERMINAL_HEIGHT, Math.round(newHeight));
setTerminalHeight(clamped);
const handleBottomPanelHeightChange = useCallback((newHeight: number) => {
const clamped = Math.max(MIN_BOTTOM_HEIGHT, Math.round(newHeight));
setBottomPanelHeight(clamped);
void api.setTerminalHeight({ height: clamped });
}, [api]);
const handleTerminalClose = useCallback(() => {
setTerminalOpen(false);
const handleBottomPanelClose = useCallback(() => {
setBottomPanelOpen(false);
}, []);
const handleTerminalToggle = useCallback(() => {
setTerminalOpen((prev) => !prev);
}, []);
setBottomPanelOpen((prev) => {
if (prev && bottomPanelTab === 'terminal') return false;
return true;
});
setBottomPanelTab('terminal');
}, [bottomPanelTab]);
const handleGitToggle = useCallback(() => {
setBottomPanelOpen((prev) => {
if (prev && bottomPanelTab === 'git') return false;
return true;
});
setBottomPanelTab('git');
}, [bottomPanelTab]);
const jumpToMessage = useCallback((messageId: string) => {
const element = document.querySelector(`[data-message-id="${CSS.escape(messageId)}"]`);
@@ -469,6 +508,20 @@ export default function App() {
}
}, []);
const handleDiscardRunChanges = useCallback(
(sessionId: string, runId: string, files?: ProjectGitFileReference[]) =>
api.discardSessionRunGitChanges({ sessionId, runId, files }),
[api],
);
const handleOpenCommitComposer = useCallback(() => {
if (!selectedSession) return;
setCommitComposerCtx({
projectId: selectedSession.projectId,
sessionId: selectedSession.id,
});
}, [selectedSession]);
const handleCreateScratchpad = useCallback(() => {
if (!workspace) return;
const singlePatterns = workspace.patterns
@@ -485,6 +538,15 @@ export default function App() {
}
}, [api, workspace]);
const handleOpenSettingsAt = useCallback((section?: SettingsSection) => {
setSettingsSection(section);
setShowSettings(true);
}, []);
const handleInstallUpdate = useCallback(() => {
void api.installUpdate();
}, [api]);
// Listen for tray "Quick Scratchpad" action
const scratchpadRef = useRef(handleCreateScratchpad);
scratchpadRef.current = handleCreateScratchpad;
@@ -591,21 +653,26 @@ export default function App() {
availableModels={availableModels}
mcpProbingServerIds={workspace.mcpProbingServerIds}
onTerminalToggle={handleTerminalToggle}
onGitToggle={!isScratchpadProject(selectedSession.projectId) ? handleGitToggle : undefined}
pattern={patternForSession}
project={projectForSession}
runtimeTools={sidecarCapabilities?.runtimeTools}
session={selectedSession}
sessionUsage={usageForSession}
activeSubagents={subagentsForSession}
terminalOpen={terminalOpen}
terminalOpen={bottomPanelOpen && bottomPanelTab === 'terminal'}
terminalRunning={terminalRunning}
gitPanelOpen={bottomPanelOpen && bottomPanelTab === 'git'}
gitDirty={gitDirty}
toolingSettings={chatToolingSettings ?? workspace.settings.tooling}
/>
);
detailPanel = (
<ActivityPanel
activity={activityForSession}
onDiscard={handleDiscardRunChanges}
onJumpToMessage={jumpToMessage}
onOpenCommitComposer={handleOpenCommitComposer}
pattern={patternForSession}
session={selectedSession}
sessionRequestUsage={requestUsageForSession}
@@ -628,8 +695,9 @@ export default function App() {
const overlay = showSettings ? (
<SettingsPanel
availableModels={availableModels}
initialSection={settingsSection}
isRefreshingCapabilities={isRefreshingCapabilities}
onClose={() => setShowSettings(false)}
onClose={() => { setShowSettings(false); setSettingsSection(undefined); }}
onDeleteLspProfile={async (id) => {
await api.deleteLspProfile(id);
}}
@@ -664,6 +732,8 @@ export default function App() {
onSetNotificationsEnabled={(enabled) => void api.setNotificationsEnabled(enabled)}
minimizeToTray={workspace.settings.minimizeToTray === true}
onSetMinimizeToTray={(enabled) => void api.setMinimizeToTray(enabled)}
gitAutoRefreshEnabled={workspace.settings.gitAutoRefreshEnabled !== false}
onSetGitAutoRefreshEnabled={(enabled) => void api.setGitAutoRefreshEnabled(enabled)}
onOpenAppDataFolder={() => void api.openAppDataFolder()}
onResetLocalWorkspace={async () => {
const fresh = await api.resetLocalWorkspace();
@@ -689,13 +759,30 @@ export default function App() {
content={content}
detailPanel={detailPanel}
overlay={overlay}
terminalPanel={
terminalOpen ? (
<TerminalPanel
height={terminalHeight}
onHeightChange={handleTerminalHeightChange}
onClose={handleTerminalClose}
onMinimize={handleTerminalClose}
bottomPanel={
bottomPanelOpen ? (
<BottomPanel
activeTab={bottomPanelTab}
gitContent={
selectedSession && !isScratchpadProject(selectedSession.projectId) ? (
<GitPanel
onDirtyChange={setGitDirty}
projectId={selectedSession.projectId}
/>
) : (
<div className="flex items-center justify-center py-8 text-[11px] text-[var(--color-text-muted)]">
Git is not available for scratchpad sessions
</div>
)
}
gitDirty={gitDirty}
height={bottomPanelHeight}
onClose={handleBottomPanelClose}
onHeightChange={handleBottomPanelHeightChange}
onTabChange={setBottomPanelTab}
showGitTab={!!selectedSession && !isScratchpadProject(selectedSession.projectId)}
terminalContent={<TerminalPanel onRunningChange={setTerminalRunning} />}
terminalRunning={terminalRunning}
/>
) : undefined
}
@@ -732,6 +819,9 @@ export default function App() {
onRefreshGitContext={(projectId) => {
void api.refreshProjectGitContext(projectId);
}}
updateStatus={updateStatus}
onViewUpdateDetails={() => handleOpenSettingsAt('troubleshooting')}
onInstallUpdate={handleInstallUpdate}
workspace={workspace}
/>
}
@@ -824,6 +914,7 @@ export default function App() {
onOpenAppDataFolder={() => void api.openAppDataFolder()}
onShowShortcuts={() => setShowShortcuts(true)}
onShowSearch={() => setShowSearch(true)}
onShowBookmarks={() => setShowBookmarks(true)}
/>
)}
@@ -840,6 +931,28 @@ export default function App() {
}}
/>
)}
{showBookmarks && workspace && (
<BookmarksPanel
workspace={workspace}
onClose={() => setShowBookmarks(false)}
onSelectSession={(sessionId) => {
void api.selectSession(sessionId);
}}
onUnpinMessage={(sessionId, messageId) => {
void api.setSessionMessagePinned({ sessionId, messageId, isPinned: false });
}}
/>
)}
{commitComposerCtx && (
<CommitComposer
onClose={() => setCommitComposerCtx(undefined)}
projectId={commitComposerCtx.projectId}
runId={commitComposerCtx.runId}
sessionId={commitComposerCtx.sessionId}
/>
)}
</>
);
}
+15 -2
View File
@@ -1,5 +1,5 @@
import { useMemo, type ReactNode } from 'react';
import { Activity, ArrowRight, BarChart3, CheckCircle2, Clock, Cog, ShieldAlert, Sparkles, Users, Zap } from 'lucide-react';
import { Activity, AlertTriangle, ArrowRight, BarChart3, CheckCircle2, Clock, Cog, ShieldAlert, Sparkles, Users, Zap } from 'lucide-react';
import {
buildAgentActivityRows,
@@ -18,6 +18,7 @@ import {
import { RunTimeline } from '@renderer/components/RunTimeline';
import { inferProvider } from '@shared/domain/models';
import type { OrchestrationMode, PatternAgentDefinition, PatternDefinition } from '@shared/domain/pattern';
import type { ProjectGitFileReference } from '@shared/domain/project';
import type { SessionRecord } from '@shared/domain/session';
import { ProviderIcon } from './ProviderIcons';
@@ -189,6 +190,8 @@ function TurnEventIcon({ kind, phase, success }: { kind: SessionEventKind; phase
return <Sparkles className={`${base} text-[var(--color-accent-purple)]`} />;
case 'session-compaction':
return <CheckCircle2 className={`${base} ${phase === 'start' ? 'animate-pulse text-[var(--color-status-warning)]' : 'text-[var(--color-status-success)]'}`} />;
case 'workflow-diagnostic':
return <AlertTriangle className={`${base} ${success === false ? 'text-[var(--color-status-error)]' : 'text-[var(--color-status-warning)]'}`} />;
default:
return <Zap className={`${base} text-[var(--color-text-muted)]`} />;
}
@@ -208,6 +211,8 @@ function formatTurnEventTimestamp(iso: string): string {
interface ActivityPanelProps {
activity?: SessionActivityState;
onJumpToMessage?: (messageId: string) => void;
onDiscard?: (sessionId: string, runId: string, files?: ProjectGitFileReference[]) => Promise<unknown>;
onOpenCommitComposer?: () => void;
pattern: PatternDefinition;
session: SessionRecord;
sessionRequestUsage?: SessionRequestUsageState;
@@ -217,6 +222,8 @@ interface ActivityPanelProps {
export function ActivityPanel({
activity,
onJumpToMessage,
onDiscard,
onOpenCommitComposer,
pattern,
session,
sessionRequestUsage,
@@ -345,7 +352,13 @@ export function ActivityPanel({
)}
</SectionHeader>
<RunTimeline onJumpToMessage={onJumpToMessage} runs={session.runs} />
<RunTimeline
onDiscard={onDiscard}
onJumpToMessage={onJumpToMessage}
onOpenCommitComposer={onOpenCommitComposer}
runs={session.runs}
sessionId={session.id}
/>
</div>
{/* ── Turn events section ─────────────────────────── */}
+4 -4
View File
@@ -4,11 +4,11 @@ interface AppShellProps {
sidebar: ReactNode;
content: ReactNode;
detailPanel?: ReactNode;
terminalPanel?: ReactNode;
bottomPanel?: ReactNode;
overlay?: ReactNode;
}
export function AppShell({ sidebar, content, detailPanel, terminalPanel, overlay }: AppShellProps) {
export function AppShell({ sidebar, content, detailPanel, bottomPanel, overlay }: AppShellProps) {
return (
<div className="relative flex h-screen bg-[var(--color-surface-0)] text-[var(--color-text-primary)]">
{/* Full-width drag region matching the title bar overlay height */}
@@ -19,7 +19,7 @@ export function AppShell({ sidebar, content, detailPanel, terminalPanel, overlay
{sidebar}
</aside>
{/* Main content + terminal */}
{/* Main content + bottom panel */}
<main className="relative flex min-w-0 flex-1 flex-col">
{/* Ambient glow behind active content area */}
<div
@@ -27,7 +27,7 @@ export function AppShell({ sidebar, content, detailPanel, terminalPanel, overlay
style={{ background: 'var(--gradient-glow)' }}
/>
<div className="relative min-h-0 flex-1">{content}</div>
{terminalPanel}
{bottomPanel}
</main>
{/* Detail panel */}
+195
View File
@@ -0,0 +1,195 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Bookmark, BookmarkMinus, ArrowRight } from 'lucide-react';
import type { WorkspaceState } from '@shared/domain/workspace';
import { listPinnedMessages, type PinnedMessageHit } from '@shared/domain/sessionLibrary';
export interface BookmarksPanelProps {
workspace: WorkspaceState;
onClose: () => void;
onSelectSession: (sessionId: string) => void;
onUnpinMessage: (sessionId: string, messageId: string) => void;
}
export function BookmarksPanel({ workspace, onClose, onSelectSession, onUnpinMessage }: BookmarksPanelProps) {
const [selectedIndex, setSelectedIndex] = useState(0);
const listRef = useRef<HTMLDivElement>(null);
// Escape to close in capture phase
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
e.preventDefault();
e.stopImmediatePropagation();
onClose();
}
};
document.addEventListener('keydown', handleEscape, true);
return () => document.removeEventListener('keydown', handleEscape, true);
}, [onClose]);
const hits = useMemo<PinnedMessageHit[]>(
() => listPinnedMessages(workspace),
[workspace],
);
// Clamp selected index when items are removed
useEffect(() => {
if (hits.length > 0 && selectedIndex >= hits.length) {
setSelectedIndex(hits.length - 1);
}
}, [hits.length, selectedIndex]);
const handleSelect = useCallback((hit: PinnedMessageHit) => {
onClose();
onSelectSession(hit.session.id);
requestAnimationFrame(() => {
setTimeout(() => {
const el = document.querySelector(`[data-message-id="${CSS.escape(hit.message.id)}"]`);
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'center' });
el.classList.add('ring-1', 'ring-[var(--color-accent)]/40', 'rounded-lg');
setTimeout(() => el.classList.remove('ring-1', 'ring-[var(--color-accent)]/40', 'rounded-lg'), 2000);
}
}, 100);
});
}, [onClose, onSelectSession]);
const handleUnpin = useCallback((e: React.MouseEvent, hit: PinnedMessageHit) => {
e.stopPropagation();
onUnpinMessage(hit.session.id, hit.message.id);
}, [onUnpinMessage]);
const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => {
if (e.key === 'ArrowDown') {
e.preventDefault();
if (hits.length > 0) setSelectedIndex((i) => Math.min(i + 1, hits.length - 1));
} else if (e.key === 'ArrowUp') {
e.preventDefault();
setSelectedIndex((i) => Math.max(i - 1, 0));
} else if (e.key === 'Enter') {
e.preventDefault();
const hit = hits[selectedIndex];
if (hit) handleSelect(hit);
}
},
[hits, selectedIndex, handleSelect],
);
useEffect(() => {
const item = listRef.current?.querySelector(`[data-bookmark-index="${selectedIndex}"]`);
item?.scrollIntoView({ block: 'nearest' });
}, [selectedIndex]);
return (
<div
className="palette-backdrop-enter fixed inset-0 z-[60] flex justify-center bg-[#07080e]/80 pt-[15vh] backdrop-blur-sm"
onClick={onClose}
role="dialog"
aria-modal="true"
aria-label="Bookmarks"
>
<div
className="palette-enter glow-border flex h-fit max-h-[min(520px,65vh)] w-full max-w-2xl flex-col overflow-hidden rounded-xl bg-[var(--color-surface-1)] shadow-[0_16px_64px_rgba(0,0,0,0.5)]"
onClick={(e) => e.stopPropagation()}
onKeyDown={handleKeyDown}
tabIndex={-1}
ref={(el) => el?.focus()}
>
{/* Header */}
<div className="flex items-center gap-3 border-b border-[var(--color-border)] px-4 py-3.5">
<Bookmark className="size-4 shrink-0 text-[var(--color-text-accent)]" />
<span className="text-[14px] font-medium text-[var(--color-text-primary)]">
Bookmarks
</span>
<span className="text-[11px] text-[var(--color-text-muted)]">
{hits.length} {hits.length === 1 ? 'message' : 'messages'}
</span>
</div>
{/* List */}
<div ref={listRef} className="flex-1 overflow-y-auto py-1.5" role="listbox">
{hits.length === 0 ? (
<div className="flex flex-col items-center gap-2 px-4 py-10 text-center">
<Bookmark className="size-6 text-[var(--color-text-muted)]/40" />
<span className="text-[13px] text-[var(--color-text-muted)]">
No bookmarked messages yet
</span>
<span className="text-[11px] text-[var(--color-text-muted)]/60">
Pin messages from any session to save them here
</span>
</div>
) : (
hits.map((hit, index) => {
const isSelected = index === selectedIndex;
return (
<button
key={`${hit.session.id}-${hit.message.id}`}
data-bookmark-index={index}
className={`group/row flex w-full items-start gap-3 px-4 py-2.5 text-left transition-colors ${
isSelected
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-glass-hover)] hover:text-[var(--color-text-primary)]'
}`}
onClick={() => handleSelect(hit)}
onMouseEnter={() => setSelectedIndex(index)}
role="option"
aria-selected={isSelected}
type="button"
>
<div className="flex min-w-0 flex-1 flex-col gap-1">
{/* Session title row */}
<div className="flex items-center gap-2">
<Bookmark
className={`size-3.5 shrink-0 fill-[var(--color-accent-sky)] text-[var(--color-accent-sky)]`}
/>
<span className="truncate text-[12px] font-medium">{hit.session.title}</span>
<span className="text-[10px] text-[var(--color-text-muted)]">·</span>
<span className="truncate text-[10px] text-[var(--color-text-muted)]">{hit.projectName}</span>
<ArrowRight className="ml-auto size-3 shrink-0 text-[var(--color-text-muted)]" />
</div>
{/* Message snippet */}
<div className="pl-5.5 text-[12px] leading-relaxed text-[var(--color-text-muted)]">
<span className="line-clamp-2">{hit.snippet}</span>
</div>
<div className="pl-5.5 text-[10px] text-[var(--color-text-muted)]">
{hit.message.role === 'user' ? 'You' : hit.message.authorName}
</div>
</div>
{/* Unpin button */}
<button
className="mt-1 flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--color-text-muted)] opacity-0 transition-all duration-100 hover:bg-[var(--color-surface-2)] hover:text-[var(--color-status-error)] group-hover/row:opacity-100"
onClick={(e) => handleUnpin(e, hit)}
aria-label={`Unpin message from ${hit.session.title}`}
title="Remove bookmark"
type="button"
>
<BookmarkMinus className="size-3.5" />
</button>
</button>
);
})
)}
</div>
{/* Footer hints */}
<div className="flex items-center gap-4 border-t border-[var(--color-border)] px-4 py-2 text-[11px] text-[var(--color-text-muted)]">
<span className="flex items-center gap-1">
<kbd className="rounded border border-[var(--color-border-subtle)] px-1 font-mono text-[10px]"></kbd>
navigate
</span>
<span className="flex items-center gap-1">
<kbd className="rounded border border-[var(--color-border-subtle)] px-1 font-mono text-[10px]"></kbd>
jump to message
</span>
<span className="flex items-center gap-1">
<kbd className="rounded border border-[var(--color-border-subtle)] px-1 font-mono text-[10px]">esc</kbd>
close
</span>
</div>
</div>
</div>
);
}
+168
View File
@@ -0,0 +1,168 @@
import { useCallback, useRef, useState, type ReactNode } from 'react';
import { GitBranch, Minus, TerminalSquare, X } from 'lucide-react';
/* ── Constants ────────────────────────────────────────────── */
const MIN_HEIGHT = 120;
const MAX_HEIGHT_FRACTION = 0.7;
const DEFAULT_HEIGHT = 280;
/* ── Types ────────────────────────────────────────────────── */
export type BottomPanelTab = 'terminal' | 'git';
/* ── BottomPanel ──────────────────────────────────────────── */
interface BottomPanelProps {
activeTab: BottomPanelTab;
onTabChange: (tab: BottomPanelTab) => void;
onClose: () => void;
height: number;
onHeightChange: (height: number) => void;
terminalContent: ReactNode;
gitContent: ReactNode;
showGitTab: boolean;
terminalRunning?: boolean;
gitDirty?: boolean;
}
export function BottomPanel({
activeTab,
onTabChange,
onClose,
height,
onHeightChange,
terminalContent,
gitContent,
showGitTab,
terminalRunning,
gitDirty,
}: BottomPanelProps) {
const [isDragging, setIsDragging] = useState(false);
const dragStartRef = useRef<{ y: number; height: number } | null>(null);
const handleDragStart = useCallback((e: React.MouseEvent) => {
e.preventDefault();
dragStartRef.current = { y: e.clientY, height };
setIsDragging(true);
const handleDragMove = (moveEvent: MouseEvent) => {
if (!dragStartRef.current) return;
const maxHeight = window.innerHeight * MAX_HEIGHT_FRACTION;
const delta = dragStartRef.current.y - moveEvent.clientY;
const nextHeight = Math.max(MIN_HEIGHT, Math.min(maxHeight, dragStartRef.current.height + delta));
onHeightChange(nextHeight);
};
const handleDragEnd = () => {
setIsDragging(false);
dragStartRef.current = null;
document.removeEventListener('mousemove', handleDragMove);
document.removeEventListener('mouseup', handleDragEnd);
};
document.addEventListener('mousemove', handleDragMove);
document.addEventListener('mouseup', handleDragEnd);
}, [height, onHeightChange]);
return (
<div
className="flex flex-col border-t border-[var(--color-border)] bg-[var(--color-surface-0)]"
style={{ height, minHeight: MIN_HEIGHT }}
>
{/* Resize handle */}
<div
className={`h-1 shrink-0 cursor-row-resize transition-colors ${isDragging ? 'bg-[var(--color-accent)]/40' : 'hover:bg-[var(--color-surface-3)]/60'}`}
onMouseDown={handleDragStart}
role="separator"
aria-orientation="horizontal"
aria-label="Resize panel"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'ArrowUp') {
e.preventDefault();
onHeightChange(Math.min(window.innerHeight * MAX_HEIGHT_FRACTION, height + 20));
} else if (e.key === 'ArrowDown') {
e.preventDefault();
onHeightChange(Math.max(MIN_HEIGHT, height - 20));
}
}}
/>
{/* Tab bar */}
<div className="flex h-8 shrink-0 items-center border-b border-[var(--color-border)] px-1">
{/* Terminal tab */}
<button
className={`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors duration-100 ${
activeTab === 'terminal'
? 'bg-[var(--color-surface-2)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-muted)] hover:bg-[var(--color-surface-2)]/50 hover:text-[var(--color-text-secondary)]'
}`}
onClick={() => onTabChange('terminal')}
type="button"
role="tab"
aria-selected={activeTab === 'terminal'}
>
{terminalRunning && <span className="size-1.5 shrink-0 rounded-full bg-emerald-400" />}
<TerminalSquare className="size-3" />
Terminal
</button>
{/* Git tab */}
{showGitTab && (
<button
className={`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors duration-100 ${
activeTab === 'git'
? 'bg-[var(--color-surface-2)] text-[var(--color-text-primary)]'
: 'text-[var(--color-text-muted)] hover:bg-[var(--color-surface-2)]/50 hover:text-[var(--color-text-secondary)]'
}`}
onClick={() => onTabChange('git')}
type="button"
role="tab"
aria-selected={activeTab === 'git'}
>
{gitDirty && <span className="size-1.5 shrink-0 rounded-full bg-[var(--color-status-warning)]" />}
<GitBranch className="size-3" />
Git
</button>
)}
<div className="flex-1" />
{/* Minimize */}
<button
aria-label="Minimize panel"
className="rounded p-1 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={onClose}
type="button"
>
<Minus className="size-3" />
</button>
{/* Close */}
<button
aria-label="Close panel"
className="rounded p-1 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-red-400"
onClick={onClose}
type="button"
>
<X className="size-3" />
</button>
</div>
{/* Tab content — both always mounted, only active one visible */}
<div className="relative min-h-0 flex-1">
<div className={`absolute inset-0 flex flex-col ${activeTab === 'terminal' ? '' : 'invisible'}`}>
{terminalContent}
</div>
{showGitTab && (
<div className={`absolute inset-0 flex flex-col overflow-y-auto ${activeTab === 'git' ? '' : 'hidden'}`}>
{gitContent}
</div>
)}
</div>
</div>
);
}
export { DEFAULT_HEIGHT, MIN_HEIGHT };
+188 -113
View File
@@ -9,9 +9,10 @@ import { MessageEditComposer } from '@renderer/components/chat/MessageEditCompos
import { PlanReviewBanner } from '@renderer/components/chat/PlanReviewBanner';
import { McpAuthBanner } from '@renderer/components/chat/McpAuthBanner';
import { UserInputBanner } from '@renderer/components/chat/UserInputBanner';
import { InlineApprovalPill, InlineModelPill, InlineTerminalPill, InlineThinkingPill, InlineToolsPill } from '@renderer/components/chat/InlinePills';
import { InlineApprovalPill, InlineGitPill, InlineModelPill, InlineTerminalPill, InlineThinkingPill, InlineToolsPill } from '@renderer/components/chat/InlinePills';
import { InlinePromptPill } from '@renderer/components/chat/InlinePromptPill';
import { ThinkingDots } from '@renderer/components/chat/ThinkingDots';
import { ThinkingProcess } from '@renderer/components/chat/ThinkingProcess';
import { SubagentActivityList } from '@renderer/components/chat/SubagentActivityCard';
import { getAssistantMessagePhase } from '@renderer/lib/messagePhase';
import type { ApprovalDecision } from '@shared/domain/approval';
@@ -28,8 +29,9 @@ import {
} from '@shared/domain/models';
import { type PatternDefinition, type ReasoningEffort } from '@shared/domain/pattern';
import { isScratchpadProject, type ProjectRecord } from '@shared/domain/project';
import { resolveSessionToolingSelection, type SessionBranchOriginAction, type SessionRecord } from '@shared/domain/session';
import { resolveSessionToolingSelection, type ChatMessageRecord, type SessionBranchOriginAction, type SessionRecord } from '@shared/domain/session';
import {
countApprovedToolsInGroups,
groupApprovalToolsByProvider,
listApprovalToolDefinitions,
type RuntimeToolDefinition,
@@ -39,6 +41,10 @@ import {
/* ── ChatPane ──────────────────────────────────────────────── */
type DisplayItem =
| { type: 'message'; message: ChatMessageRecord }
| { type: 'thinking-group'; messages: ChatMessageRecord[]; turnStartedAt?: string };
interface ChatPaneProps {
project: ProjectRecord;
pattern: PatternDefinition;
@@ -51,6 +57,8 @@ interface ChatPaneProps {
activeSubagents?: ReadonlyArray<ActiveSubagent>;
terminalOpen?: boolean;
terminalRunning?: boolean;
gitPanelOpen?: boolean;
gitDirty?: boolean;
onSend: (content: string, attachments?: ChatMessageAttachment[], messageMode?: MessageMode) => Promise<void>;
onCancelTurn?: () => void;
onResolveApproval?: (approvalId: string, decision: ApprovalDecision, alwaysApprove?: boolean) => Promise<unknown>;
@@ -60,6 +68,7 @@ interface ChatPaneProps {
onDismissMcpAuth?: () => void;
onAuthenticateMcp?: () => void;
onTerminalToggle?: () => void;
onGitToggle?: () => void;
onUpdateSessionModelConfig?: (config: {
model: string;
reasoningEffort?: ReasoningEffort;
@@ -85,6 +94,8 @@ export function ChatPane({
activeSubagents,
terminalOpen,
terminalRunning,
gitPanelOpen,
gitDirty,
onSend,
onCancelTurn,
onResolveApproval,
@@ -94,6 +105,7 @@ export function ChatPane({
onDismissMcpAuth,
onAuthenticateMcp,
onTerminalToggle,
onGitToggle,
onUpdateSessionModelConfig,
onUpdateSessionTooling,
onUpdateSessionApprovalSettings,
@@ -114,11 +126,50 @@ export function ChatPane({
const composerRef = useRef<MarkdownComposerHandle>(null);
const isSessionBusy = session.status === 'running';
const lastAssistantIndex = useMemo(() => {
for (let i = session.messages.length - 1; i >= 0; i--) {
if (session.messages[i].role === 'assistant') return i;
const displayItems = useMemo(() => {
const runsByTrigger = new Map(session.runs.map((r) => [r.triggerMessageId, r]));
const items: DisplayItem[] = [];
let pendingThinking: ChatMessageRecord[] = [];
let lastUserMessageId: string | undefined;
for (const message of session.messages) {
if (message.messageKind === 'thinking') {
pendingThinking.push(message);
} else {
if (pendingThinking.length > 0) {
const run = lastUserMessageId ? runsByTrigger.get(lastUserMessageId) : undefined;
items.push({ type: 'thinking-group', messages: pendingThinking, turnStartedAt: run?.startedAt });
pendingThinking = [];
}
items.push({ type: 'message', message });
if (message.role === 'user') {
lastUserMessageId = message.id;
}
}
}
if (pendingThinking.length > 0) {
const run = lastUserMessageId ? runsByTrigger.get(lastUserMessageId) : undefined;
items.push({ type: 'thinking-group', messages: pendingThinking, turnStartedAt: run?.startedAt });
}
return items;
}, [session.messages, session.runs]);
const lastThinkingGroupIndex = useMemo(() => {
for (let i = displayItems.length - 1; i >= 0; i--) {
if (displayItems[i].type === 'thinking-group') return i;
}
return -1;
}, [displayItems]);
const lastAssistantId = useMemo(() => {
for (let i = session.messages.length - 1; i >= 0; i--) {
const m = session.messages[i];
if (m.role === 'assistant' && m.messageKind !== 'thinking') return m.id;
}
return undefined;
}, [session.messages]);
const pendingApproval = session.pendingApproval?.status === 'pending' ? session.pendingApproval : undefined;
const queuedApprovals = (session.pendingApprovalQueue ?? []).filter((a) => a.status === 'pending');
@@ -162,17 +213,7 @@ export function ChatPane({
);
const effectiveAutoApprovedCount = useMemo(() => {
const groups = groupApprovalToolsByProvider(approvalTools, toolingSettings);
const counted = new Set<string>();
for (const group of groups) {
if (group.serverApprovalKey && effectiveAutoApproved.has(group.serverApprovalKey)) {
for (const tool of group.tools) counted.add(tool.id);
} else {
for (const tool of group.tools) {
if (effectiveAutoApproved.has(tool.id)) counted.add(tool.id);
}
}
}
return counted.size;
return countApprovedToolsInGroups(groups, effectiveAutoApproved);
}, [approvalTools, effectiveAutoApproved, toolingSettings]);
const isProbingMcp = (mcpProbingServerIds?.length ?? 0) > 0;
const hasApprovalContent = approvalTools.length > 0 || isProbingMcp;
@@ -290,17 +331,34 @@ export function ChatPane({
{isScratchpad
? `Scratchpad · ${pattern.name}`
: `${project.name} · ${pattern.name} · ${pattern.mode}`}
{!isScratchpad && project.git?.status === 'ready' && (
<span className="ml-2 inline-flex items-center gap-1 text-[var(--color-text-muted)]">
<GitBranch className="inline size-2.5" />
{project.git.branch ?? project.git.head?.shortHash ?? 'HEAD'}
{project.git.isDirty && (
<Circle className="inline size-1.5 fill-amber-500 text-amber-500" />
)}
{(project.git.ahead ?? 0) > 0 && <span>{project.git.ahead}</span>}
{(project.git.behind ?? 0) > 0 && <span>{project.git.behind}</span>}
</span>
)}
{!isScratchpad && project.git?.status === 'ready' && (() => {
const git = project.git;
const tipLines: string[] = [git.branch ?? git.head?.shortHash ?? 'HEAD'];
if (git.changes) {
const bd: string[] = [];
if (git.changes.staged > 0) bd.push(`${git.changes.staged} staged`);
if (git.changes.unstaged > 0) bd.push(`${git.changes.unstaged} modified`);
if (git.changes.untracked > 0) bd.push(`${git.changes.untracked} untracked`);
if (bd.length > 0) tipLines.push(bd.join(', '));
}
if (git.ahead || git.behind) {
const sync: string[] = [];
if (git.ahead) sync.push(`${git.ahead} ahead`);
if (git.behind) sync.push(`${git.behind} behind`);
tipLines.push(sync.join(', '));
}
return (
<span className="ml-2 inline-flex items-center gap-1 text-[var(--color-text-muted)]" title={tipLines.join('\n')}>
<GitBranch className="inline size-2.5" />
{git.branch ?? git.head?.shortHash ?? 'HEAD'}
{git.isDirty && (
<Circle className="inline size-1.5 fill-amber-500 text-amber-500" />
)}
{(git.ahead ?? 0) > 0 && <span>{git.ahead}</span>}
{(git.behind ?? 0) > 0 && <span>{git.behind}</span>}
</span>
);
})()}
</p>
</div>
<div className="flex items-center gap-2">
@@ -367,11 +425,25 @@ export function ChatPane({
/>
)}
<div className="space-y-1">
{session.messages.map((message, index) => {
{displayItems.map((item, itemIndex) => {
if (item.type === 'thinking-group') {
const isLastThinkingGroup = itemIndex === lastThinkingGroupIndex;
return (
<div key={`thinking-${item.messages[0].id}`} className="py-2">
<ThinkingProcess
messages={item.messages}
isActive={isSessionBusy && isLastThinkingGroup}
turnStartedAt={item.turnStartedAt}
/>
</div>
);
}
const message = item.message;
const isUser = message.role === 'user';
const isEditing = editingMessageId === message.id;
const isLastAssistant = index === lastAssistantIndex;
const phase = getAssistantMessagePhase(session, message, index);
const isLastAssistant = message.id === lastAssistantId;
const phase = getAssistantMessagePhase(session, message);
const assistantContainerClass =
phase === 'thinking'
? 'border-[var(--color-accent-sky)]/20 bg-[var(--color-accent-sky)]/5'
@@ -387,94 +459,90 @@ export function ChatPane({
const showActions = !isSessionBusy && !message.pending;
return (
<div className="message-enter group py-3" data-message-id={message.id} key={message.id}>
<div className="flex gap-3">
<div
className={`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-full ${
isUser ? 'brand-gradient-bg text-white' : 'bg-[var(--color-surface-2)] text-[var(--color-text-secondary)]'
}`}
>
{isUser ? <User className="size-3.5" /> : <Bot className="size-3.5" />}
</div>
<div className="min-w-0 flex-1">
<div className="mb-1 flex items-center gap-2 text-[12px] font-medium text-[var(--color-text-secondary)]">
<span>{message.authorName}</span>
{message.isPinned && (
<Bookmark className="size-3 fill-[var(--color-accent-sky)] text-[var(--color-accent-sky)]" />
)}
{!isUser && phaseLabel && (
<span
className={`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] ${assistantBadgeClass}`}
>
{phaseLabel}
</span>
)}
{showActions && (
<div className="ml-auto">
<MessageActions
message={message}
isLastAssistant={isLastAssistant}
onCopy={() => handleCopyMessage(message.content)}
onPin={() => onPinMessage?.(message.id, !message.isPinned)}
onBranch={() => onBranchFromMessage?.(message.id)}
onRegenerate={onRegenerateMessage ? () => onRegenerateMessage(message.id) : undefined}
onEdit={onEditAndResendMessage && isUser ? () => setEditingMessageId(message.id) : undefined}
/>
</div>
)}
<div key={message.id}>
<div className="message-enter group py-3" data-message-id={message.id}>
<div className="flex gap-3">
<div
className={`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-full ${
isUser ? 'brand-gradient-bg text-white' : 'bg-[var(--color-surface-2)] text-[var(--color-text-secondary)]'
}`}
>
{isUser ? <User className="size-3.5" /> : <Bot className="size-3.5" />}
</div>
{/* Edit mode */}
{isEditing ? (
<MessageEditComposer
initialContent={message.content}
onSave={(content) => handleEditSave(message.id, content)}
onCancel={() => setEditingMessageId(undefined)}
/>
) : (
<div
className={
isUser
? 'text-[14px] leading-relaxed text-[var(--color-text-primary)]'
: `rounded-xl border px-4 py-3 text-[14px] leading-relaxed text-[var(--color-text-primary)] ${assistantContainerClass}`
}
>
{/* Attachment thumbnails */}
{isUser && message.attachments && message.attachments.length > 0 && (
<div className="mb-2 flex flex-wrap gap-2">
{message.attachments.map((att, attIdx) =>
isImageAttachment(att) ? (
<img
key={attIdx}
alt={getAttachmentDisplayName(att)}
className="max-h-48 max-w-xs rounded-lg border border-[var(--color-border)] object-cover"
src={`data:${att.mimeType};base64,${att.data}`}
/>
) : (
<div
key={attIdx}
className="flex items-center gap-1.5 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-2)] px-2 py-1 text-[11px] text-[var(--color-text-secondary)]"
>
<Paperclip className="size-3" />
{getAttachmentDisplayName(att)}
</div>
),
)}
</div>
<div className="min-w-0 flex-1">
<div className="mb-1 flex items-center gap-2 text-[12px] font-medium text-[var(--color-text-secondary)]">
<span>{message.authorName}</span>
{message.isPinned && (
<Bookmark className="size-3 fill-[var(--color-accent-sky)] text-[var(--color-accent-sky)]" />
)}
{!isUser && message.pending ? (
<div className="whitespace-pre-wrap break-words text-[14px] leading-relaxed text-[var(--color-text-primary)]">
{message.content}
</div>
) : (
<MarkdownContent content={message.content} />
{!isUser && phaseLabel && (
<span
className={`inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] ${assistantBadgeClass}`}
>
{phaseLabel}
</span>
)}
{message.pending && message.content && (
<span className="mt-1 inline-block h-4 w-[2px] animate-pulse rounded-sm bg-[var(--color-accent)]" />
{showActions && (
<div className="ml-auto">
<MessageActions
message={message}
isLastAssistant={isLastAssistant}
onCopy={() => handleCopyMessage(message.content)}
onPin={() => onPinMessage?.(message.id, !message.isPinned)}
onBranch={() => onBranchFromMessage?.(message.id)}
onRegenerate={onRegenerateMessage ? () => onRegenerateMessage(message.id) : undefined}
onEdit={onEditAndResendMessage && isUser ? () => setEditingMessageId(message.id) : undefined}
/>
</div>
)}
</div>
)}
{message.pending && !message.content && <ThinkingDots />}
{/* Edit mode */}
{isEditing ? (
<MessageEditComposer
initialContent={message.content}
onSave={(content) => handleEditSave(message.id, content)}
onCancel={() => setEditingMessageId(undefined)}
/>
) : (
<div
className={
isUser
? 'text-[14px] leading-relaxed text-[var(--color-text-primary)]'
: `rounded-xl border px-4 py-3 text-[14px] leading-relaxed text-[var(--color-text-primary)] ${assistantContainerClass}`
}
>
{/* Attachment thumbnails */}
{isUser && message.attachments && message.attachments.length > 0 && (
<div className="mb-2 flex flex-wrap gap-2">
{message.attachments.map((att, attIdx) =>
isImageAttachment(att) ? (
<img
key={attIdx}
alt={getAttachmentDisplayName(att)}
className="max-h-48 max-w-xs rounded-lg border border-[var(--color-border)] object-cover"
src={`data:${att.mimeType};base64,${att.data}`}
/>
) : (
<div
key={attIdx}
className="flex items-center gap-1.5 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-2)] px-2 py-1 text-[11px] text-[var(--color-text-secondary)]"
>
<Paperclip className="size-3" />
{getAttachmentDisplayName(att)}
</div>
),
)}
</div>
)}
<MarkdownContent content={message.content} />
{message.pending && message.content && (
<span className="mt-1 inline-block h-4 w-[2px] animate-pulse rounded-sm bg-[var(--color-accent)]" />
)}
</div>
)}
{message.pending && !message.content && <ThinkingDots />}
</div>
</div>
</div>
</div>
@@ -705,6 +773,13 @@ export function ChatPane({
onToggle={onTerminalToggle}
/>
)}
{onGitToggle && !isScratchpad && (
<InlineGitPill
isDirty={!!gitDirty}
isOpen={!!gitPanelOpen}
onToggle={onGitToggle}
/>
)}
{!isScratchpad && promptFiles.length > 0 && (
<InlinePromptPill
disabled={isComposerDisabled}
+14 -1
View File
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
Archive,
Bookmark,
Copy,
FolderOpen,
FolderPlus,
@@ -51,6 +52,7 @@ export interface CommandPaletteProps {
onOpenAppDataFolder: () => void;
onShowShortcuts: () => void;
onShowSearch: () => void;
onShowBookmarks: () => void;
}
/** Score how well `query` matches `text` (and optional `keywords`). 0 = no match. */
@@ -92,6 +94,7 @@ export function CommandPalette({
onOpenAppDataFolder,
onShowShortcuts,
onShowSearch,
onShowBookmarks,
}: CommandPaletteProps) {
const [query, setQuery] = useState('');
const [selectedIndex, setSelectedIndex] = useState(0);
@@ -234,6 +237,16 @@ export function CommandPalette({
action: onShowSearch,
});
cmds.push({
id: 'view-bookmarks',
label: 'View Bookmarks',
category: 'General',
keywords: 'pin pinned bookmark bookmarked saved',
shortcut: shortcutKeys('bookmarks'),
icon: <Bookmark className={ICON} />,
action: onShowBookmarks,
});
cmds.push({
id: 'settings',
label: 'Open Settings',
@@ -316,7 +329,7 @@ export function CommandPalette({
onSelectSession, onSelectProject, onNewSession, onCreateScratchpad,
onOpenSettings, onOpenProjectSettings, onToggleTerminal, onSetTheme,
onDuplicateSession, onPinSession, onArchiveSession, onAddProject,
onOpenAppDataFolder, onShowShortcuts, onShowSearch,
onOpenAppDataFolder, onShowShortcuts, onShowSearch, onShowBookmarks,
]);
const filteredCommands = useMemo(() => {
+10 -2
View File
@@ -16,6 +16,7 @@ import {
Loader2,
} from 'lucide-react';
import { CliInstallGuide } from '@renderer/components/settings/CliInstallGuide';
import type {
SidecarConnectionDiagnostics,
SidecarConnectionStatus,
@@ -391,8 +392,15 @@ export function CopilotStatusCard({
</div>
)}
{/* Action hint for non-ready states */}
{!isHealthy && config.actionLabel && (
{/* Installation guide for missing CLI */}
{connection.status === 'copilot-cli-missing' && (
<div className="rounded-lg border border-[var(--color-border)] bg-[var(--color-glass)] p-4">
<CliInstallGuide isRefreshing={isRefreshing} onRefresh={onRefresh} />
</div>
)}
{/* Action hint for other non-ready states */}
{!isHealthy && connection.status !== 'copilot-cli-missing' && config.actionLabel && (
<div className="flex items-start gap-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-glass)] px-3 py-2.5">
<div className="mt-0.5 shrink-0">{config.actionIcon}</div>
<p className="text-[12px] leading-relaxed text-[var(--color-text-secondary)]">{config.actionLabel}</p>
+616
View File
@@ -0,0 +1,616 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
AlertTriangle,
ArrowDownToLine,
ArrowUpFromLine,
Check,
ChevronDown,
ChevronRight,
Cloud,
FileCode2,
FileMinus2,
FilePlus2,
GitBranch,
GitCommitHorizontal,
History,
Loader2,
Plus,
RefreshCw,
Trash2,
X,
} from 'lucide-react';
import { getElectronApi } from '@renderer/lib/electronApi';
import type {
ProjectGitBranchSummary,
ProjectGitCommitLogEntry,
ProjectGitDetails,
ProjectGitDiffPreview,
ProjectGitWorkingTreeFile,
} from '@shared/domain/project';
/* ── Helpers ───────────────────────────────────────────────── */
function fileBaseName(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash >= 0 ? normalized.slice(lastSlash + 1) : normalized;
}
function fileDir(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash > 0 ? normalized.slice(0, lastSlash + 1) : '';
}
function relativeTime(iso: string): string {
const diff = Date.now() - new Date(iso).getTime();
const secs = Math.floor(diff / 1000);
if (secs < 60) return 'just now';
const mins = Math.floor(secs / 60);
if (mins < 60) return `${mins}m ago`;
const hrs = Math.floor(mins / 60);
if (hrs < 24) return `${hrs}h ago`;
const days = Math.floor(hrs / 24);
if (days === 1) return 'yesterday';
if (days < 7) return `${days}d ago`;
return new Date(iso).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
}
/* ── Section header ────────────────────────────────────────── */
function SectionHeader({
icon,
label,
count,
expanded,
onToggle,
}: {
icon: React.ReactNode;
label: string;
count?: number;
expanded: boolean;
onToggle: () => void;
}) {
return (
<button
className="flex w-full items-center gap-2 border-b border-[var(--color-border-subtle)] px-3 py-2 text-left transition-colors duration-100 hover:bg-[var(--color-surface-2)]/30"
onClick={onToggle}
type="button"
aria-expanded={expanded}
>
{expanded
? <ChevronDown className="size-2.5 text-[var(--color-text-muted)]" />
: <ChevronRight className="size-2.5 text-[var(--color-text-muted)]" />}
{icon}
<span className="font-display text-[10px] font-semibold uppercase tracking-wider text-[var(--color-text-muted)]">
{label}
</span>
{count !== undefined && count > 0 && (
<span className="rounded-full bg-[var(--color-surface-3)] px-1.5 py-0.5 text-[8px] font-semibold tabular-nums text-[var(--color-text-muted)]">
{count}
</span>
)}
</button>
);
}
/* ── File status icon ──────────────────────────────────────── */
function fileIcon(file: ProjectGitWorkingTreeFile) {
if (file.stagedStatus === 'added' || file.unstagedStatus === 'untracked') {
return <FilePlus2 className="size-3 shrink-0 text-[var(--color-status-success)]" />;
}
if (file.stagedStatus === 'deleted' || file.unstagedStatus === 'deleted') {
return <FileMinus2 className="size-3 shrink-0 text-[var(--color-status-error)]" />;
}
return <FileCode2 className="size-3 shrink-0 text-[var(--color-accent-sky)]" />;
}
/* ── Changed file row ──────────────────────────────────────── */
function ChangedFileEntry({
file,
projectId,
}: {
file: ProjectGitWorkingTreeFile;
projectId: string;
}) {
const api = getElectronApi();
const [expanded, setExpanded] = useState(false);
const [preview, setPreview] = useState<ProjectGitDiffPreview>();
const dir = fileDir(file.path);
const base = fileBaseName(file.path);
const status = file.stagedStatus ?? file.unstagedStatus ?? 'modified';
const handleToggle = useCallback(async () => {
if (expanded) {
setExpanded(false);
return;
}
setExpanded(true);
if (!preview) {
try {
const result = await api.getProjectGitFilePreview({
projectId,
file: { path: file.path, previousPath: file.previousPath },
});
if (result) setPreview(result);
} catch {
// Preview is best-effort
}
}
}, [api, expanded, file.path, file.previousPath, preview, projectId]);
return (
<div className="border-b border-[var(--color-border-subtle)] last:border-b-0">
<button
className="flex w-full items-center gap-1.5 px-3 py-[5px] text-left text-[10px] transition-colors duration-150 hover:bg-[var(--color-surface-2)]/40"
onClick={() => void handleToggle()}
type="button"
aria-expanded={expanded}
>
<ChevronRight
className={`size-2 shrink-0 text-[var(--color-text-muted)] transition-transform duration-150 ${expanded ? 'rotate-90' : ''}`}
/>
{fileIcon(file)}
<span className="min-w-0 flex-1 truncate font-mono">
{dir && <span className="text-[var(--color-text-muted)]">{dir}</span>}
<span className="text-[var(--color-text-primary)]">{base}</span>
</span>
<span className="shrink-0 rounded px-1 py-px text-[7px] font-semibold uppercase tracking-wider bg-[var(--color-surface-3)] text-[var(--color-text-muted)]">
{status}
</span>
</button>
{expanded && preview && (
<div className="border-t border-[var(--color-border-subtle)]">
<pre className="max-h-40 overflow-auto bg-[var(--color-surface-0)] px-3 py-1 font-mono text-[9px] leading-relaxed">
{preview.diff
? preview.diff.split('\n').map((line, i) => {
let cls = 'text-[var(--color-text-secondary)]';
if (line.startsWith('+') && !line.startsWith('+++')) cls = 'text-[var(--color-status-success)]';
else if (line.startsWith('-') && !line.startsWith('---')) cls = 'text-[var(--color-status-error)]';
else if (line.startsWith('@@')) cls = 'text-[var(--color-accent-sky)]';
return <div key={i} className={cls}>{line || '\u00A0'}</div>;
})
: preview.newFileContents
? preview.newFileContents.split('\n').map((line, i) => (
<div key={i} className="text-[var(--color-text-secondary)]">{line || '\u00A0'}</div>
))
: <div className="text-[var(--color-text-muted)] italic">Binary file</div>}
</pre>
</div>
)}
</div>
);
}
/* ── Branch row ────────────────────────────────────────────── */
function BranchRow({
branch,
onSwitch,
onDelete,
isSwitching,
}: {
branch: ProjectGitBranchSummary;
onSwitch: () => void;
onDelete: () => void;
isSwitching: boolean;
}) {
return (
<div className="flex items-center gap-1.5 px-3 py-[5px] text-[10px]">
<GitBranch className={`size-3 shrink-0 ${branch.isCurrent ? 'text-[var(--color-status-success)]' : 'text-[var(--color-text-muted)]'}`} />
<span className={`min-w-0 flex-1 truncate font-mono ${branch.isCurrent ? 'font-medium text-[var(--color-text-primary)]' : 'text-[var(--color-text-secondary)]'}`}>
{branch.name}
</span>
{branch.isCurrent && (
<span className="rounded px-1 py-px text-[7px] font-semibold uppercase tracking-wider bg-[var(--color-status-success)]/10 text-[var(--color-status-success)]">
current
</span>
)}
{!branch.isCurrent && (
<>
<button
className="rounded p-0.5 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={onSwitch}
type="button"
title={`Switch to ${branch.name}`}
disabled={isSwitching}
>
{isSwitching ? <Loader2 className="size-2.5 animate-spin" /> : <Check className="size-2.5" />}
</button>
<button
className="rounded p-0.5 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-status-error)]/10 hover:text-[var(--color-status-error)]"
onClick={onDelete}
type="button"
title={`Delete ${branch.name}`}
>
<Trash2 className="size-2.5" />
</button>
</>
)}
</div>
);
}
/* ── Commit log row ────────────────────────────────────────── */
function CommitRow({ commit }: { commit: ProjectGitCommitLogEntry }) {
return (
<div className="flex items-start gap-2 px-3 py-[5px] text-[10px]">
<GitCommitHorizontal className="mt-0.5 size-3 shrink-0 text-[var(--color-text-muted)]" />
<div className="min-w-0 flex-1">
<p className="truncate text-[var(--color-text-secondary)]">
{commit.subject}
</p>
<p className="flex items-center gap-1.5 text-[9px] text-[var(--color-text-muted)]">
<span className="font-mono">{commit.shortHash}</span>
<span>·</span>
<span>{commit.authorName}</span>
<span>·</span>
<span>{relativeTime(commit.committedAt)}</span>
</p>
</div>
</div>
);
}
/* ── Create branch dialog ──────────────────────────────────── */
function CreateBranchForm({
onSubmit,
onCancel,
}: {
onSubmit: (name: string) => void;
onCancel: () => void;
}) {
const [name, setName] = useState('');
return (
<div className="flex items-center gap-1.5 border-b border-[var(--color-border-subtle)] px-3 py-1.5">
<input
autoFocus
className="min-w-0 flex-1 rounded border border-[var(--color-border)] bg-[var(--color-surface-0)] px-2 py-1 font-mono text-[10px] text-[var(--color-text-primary)] placeholder:text-[var(--color-text-muted)] focus:border-[var(--color-accent)] focus:outline-none"
onChange={(e) => setName(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && name.trim()) {
e.preventDefault();
onSubmit(name.trim());
} else if (e.key === 'Escape') {
e.preventDefault();
onCancel();
}
}}
placeholder="Branch name…"
value={name}
/>
<button
className="rounded p-1 text-[var(--color-status-success)] transition-colors duration-100 hover:bg-[var(--color-status-success)]/10 disabled:opacity-40"
disabled={!name.trim()}
onClick={() => onSubmit(name.trim())}
type="button"
>
<Check className="size-3" />
</button>
<button
className="rounded p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)]"
onClick={onCancel}
type="button"
>
<X className="size-3" />
</button>
</div>
);
}
/* ── Main export ───────────────────────────────────────────── */
interface GitPanelProps {
projectId: string;
onDirtyChange?: (isDirty: boolean) => void;
}
export function GitPanel({ projectId, onDirtyChange }: GitPanelProps) {
const api = getElectronApi();
const [details, setDetails] = useState<ProjectGitDetails>();
const [loading, setLoading] = useState(true);
const [refreshing, setRefreshing] = useState(false);
const [showChanges, setShowChanges] = useState(true);
const [showBranches, setShowBranches] = useState(false);
const [showHistory, setShowHistory] = useState(false);
const [showCreateBranch, setShowCreateBranch] = useState(false);
const [switchingBranch, setSwitchingBranch] = useState<string>();
const [operationError, setOperationError] = useState<string>();
const [networkBusy, setNetworkBusy] = useState<'push' | 'pull' | 'fetch'>();
const loadDetails = useCallback(async (quiet = false) => {
if (!quiet) setLoading(true);
else setRefreshing(true);
try {
const result = await api.getProjectGitDetails({ projectId });
setDetails(result);
setOperationError(undefined);
onDirtyChange?.(result.context.isDirty ?? false);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
} finally {
setLoading(false);
setRefreshing(false);
}
}, [api, projectId]);
useEffect(() => {
void loadDetails();
}, [loadDetails]);
const ctx = details?.context;
const workingTree = details?.workingTree;
const branches = details?.branches ?? [];
const commits = details?.recentCommits ?? [];
const changedFiles = workingTree?.files ?? [];
const handlePush = useCallback(async () => {
setNetworkBusy('push');
setOperationError(undefined);
try {
await api.pushProjectGit({ projectId });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
} finally {
setNetworkBusy(undefined);
}
}, [api, loadDetails, projectId]);
const handlePull = useCallback(async () => {
setNetworkBusy('pull');
setOperationError(undefined);
try {
await api.pullProjectGit({ projectId });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
} finally {
setNetworkBusy(undefined);
}
}, [api, loadDetails, projectId]);
const handleFetch = useCallback(async () => {
setNetworkBusy('fetch');
setOperationError(undefined);
try {
await api.fetchProjectGit({ projectId });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
} finally {
setNetworkBusy(undefined);
}
}, [api, loadDetails, projectId]);
const handleSwitchBranch = useCallback(async (name: string) => {
setSwitchingBranch(name);
setOperationError(undefined);
try {
await api.switchProjectGitBranch({ projectId, name });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
} finally {
setSwitchingBranch(undefined);
}
}, [api, loadDetails, projectId]);
const handleDeleteBranch = useCallback(async (name: string) => {
setOperationError(undefined);
try {
await api.deleteProjectGitBranch({ projectId, name });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
}
}, [api, loadDetails, projectId]);
const handleCreateBranch = useCallback(async (name: string) => {
setShowCreateBranch(false);
setOperationError(undefined);
try {
await api.createProjectGitBranch({ projectId, name, checkout: true });
await loadDetails(true);
} catch (error) {
setOperationError(error instanceof Error ? error.message : String(error));
}
}, [api, loadDetails, projectId]);
if (loading) {
return (
<div className="flex items-center justify-center py-8">
<Loader2 className="size-4 animate-spin text-[var(--color-text-muted)]" aria-label="Loading git status" />
</div>
);
}
if (!ctx || ctx.status !== 'ready') {
return (
<div className="px-3 py-4 text-center text-[11px] text-[var(--color-text-muted)]">
{ctx?.status === 'not-repository'
? 'Not a git repository'
: ctx?.status === 'git-missing'
? 'Git is not installed'
: ctx?.errorMessage ?? 'Unable to read git status'}
</div>
);
}
return (
<div className="flex flex-col">
{/* Branch header + network actions */}
<div className="border-b border-[var(--color-border-subtle)] px-3 py-2">
<div className="flex items-center gap-1.5">
<GitBranch className="size-3 text-[var(--color-accent-sky)]" />
<span className="font-mono text-[11px] font-medium text-[var(--color-text-primary)]">
{ctx.branch ?? 'detached HEAD'}
</span>
{ctx.upstream && (
<span className="text-[9px] text-[var(--color-text-muted)]">
{ctx.ahead !== undefined && ctx.ahead > 0 && <span className="text-[var(--color-status-success)]">{ctx.ahead}</span>}
{ctx.behind !== undefined && ctx.behind > 0 && <span className="ml-0.5 text-[var(--color-status-warning)]">{ctx.behind}</span>}
</span>
)}
<div className="flex-1" />
{/* Network buttons */}
<button
className="rounded p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)] disabled:opacity-40"
disabled={!!networkBusy}
onClick={() => void handleFetch()}
title="Fetch"
type="button"
>
{networkBusy === 'fetch' ? <Loader2 className="size-3 animate-spin" /> : <Cloud className="size-3" />}
</button>
<button
className="rounded p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)] disabled:opacity-40"
disabled={!!networkBusy}
onClick={() => void handlePull()}
title="Pull"
type="button"
>
{networkBusy === 'pull' ? <Loader2 className="size-3 animate-spin" /> : <ArrowDownToLine className="size-3" />}
</button>
<button
className="rounded p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)] disabled:opacity-40"
disabled={!!networkBusy}
onClick={() => void handlePush()}
title="Push"
type="button"
>
{networkBusy === 'push' ? <Loader2 className="size-3 animate-spin" /> : <ArrowUpFromLine className="size-3" />}
</button>
<button
className="rounded p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={() => void loadDetails(true)}
title="Refresh"
type="button"
>
<RefreshCw className={`size-3 ${refreshing ? 'animate-spin' : ''}`} />
</button>
</div>
{ctx.isDirty && (
<div className="mt-1 text-[9px] text-[var(--color-status-warning)]">
{ctx.changedFileCount} uncommitted {ctx.changedFileCount === 1 ? 'change' : 'changes'}
</div>
)}
</div>
{/* Error */}
{operationError && (
<div className="flex items-start gap-1.5 border-b border-[var(--color-status-error)]/20 bg-[var(--color-status-error)]/5 px-3 py-1.5 text-[9px] text-[var(--color-status-error)]" role="alert">
<AlertTriangle className="mt-0.5 size-3 shrink-0" />
<span className="min-w-0 flex-1">{operationError}</span>
<button
className="shrink-0 rounded p-0.5 transition-colors duration-100 hover:bg-[var(--color-status-error)]/10"
onClick={() => setOperationError(undefined)}
type="button"
aria-label="Dismiss error"
>
<X className="size-2.5" />
</button>
</div>
)}
{/* Changed files */}
<SectionHeader
count={changedFiles.length}
expanded={showChanges}
icon={<FileCode2 className="size-3 text-[var(--color-accent-sky)]" />}
label="Changes"
onToggle={() => setShowChanges(!showChanges)}
/>
{showChanges && (
<div>
{changedFiles.length === 0 ? (
<p className="px-3 py-2 text-[10px] text-[var(--color-text-muted)]">Working tree clean</p>
) : (
changedFiles.map((file) => (
<ChangedFileEntry
file={file}
key={file.path}
projectId={projectId}
/>
))
)}
</div>
)}
{/* Branches */}
<SectionHeader
count={branches.length}
expanded={showBranches}
icon={<GitBranch className="size-3 text-[var(--color-status-success)]" />}
label="Branches"
onToggle={() => setShowBranches(!showBranches)}
/>
{showBranches && (
<div>
{/* New branch button */}
{!showCreateBranch && (
<button
className="flex w-full items-center gap-1.5 px-3 py-[5px] text-[10px] text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-2)]/40 hover:text-[var(--color-text-accent)]"
onClick={() => setShowCreateBranch(true)}
type="button"
>
<Plus className="size-3" />
New branch
</button>
)}
{showCreateBranch && (
<CreateBranchForm
onCancel={() => setShowCreateBranch(false)}
onSubmit={(name) => void handleCreateBranch(name)}
/>
)}
{branches.map((branch) => (
<BranchRow
branch={branch}
isSwitching={switchingBranch === branch.name}
key={branch.name}
onDelete={() => void handleDeleteBranch(branch.name)}
onSwitch={() => void handleSwitchBranch(branch.name)}
/>
))}
</div>
)}
{/* Commit history */}
<SectionHeader
count={commits.length}
expanded={showHistory}
icon={<History className="size-3 text-[var(--color-text-muted)]" />}
label="Recent Commits"
onToggle={() => setShowHistory(!showHistory)}
/>
{showHistory && (
<div>
{commits.length === 0 ? (
<p className="px-3 py-2 text-[10px] text-[var(--color-text-muted)]">No commit history</p>
) : (
commits.map((commit) => (
<CommitRow commit={commit} key={commit.hash} />
))
)}
</div>
)}
</div>
);
}
+93 -10
View File
@@ -8,6 +8,7 @@ import {
ChevronDown,
ChevronRight,
CircleDot,
GitBranch,
MessageSquare,
Play,
Wrench,
@@ -25,8 +26,10 @@ import {
type CollapsedTimelineEvent,
} from '@renderer/lib/runTimelineFormatting';
import type { OrchestrationMode } from '@shared/domain/pattern';
import type { ProjectGitFileReference, ProjectGitWorkingTreeSnapshot } from '@shared/domain/project';
import type { RunTimelineEventRecord, SessionRunRecord } from '@shared/domain/runTimeline';
import { FileChangePreview } from '@renderer/components/chat/FileChangePreview';
import { RunChangeSummaryCard } from '@renderer/components/chat/RunChangeSummaryCard';
/* ── Mode accent colours (shared with ActivityPanel) ───────── */
@@ -51,20 +54,37 @@ const runStatusStyles: Record<SessionRunRecord['status'], { icon: ReactNode; cla
/* ── Event node icon ───────────────────────────────────────── */
function EventIcon({ kind, status }: { kind: RunTimelineEventRecord['kind']; status: RunTimelineEventRecord['status'] }) {
const base = 'size-3.5';
const isRunning = status === 'running';
const base = 'size-2.5';
// Running events use white icons to contrast with the brand-gradient circle
if (isRunning) {
const pulse = 'animate-pulse';
switch (kind) {
case 'thinking':
return <Brain className={`${base} ${pulse} text-white`} />;
case 'approval':
return <AlertTriangle className={`${base} ${pulse} text-white`} />;
case 'message':
return <MessageSquare className={`${base} ${pulse} text-white`} />;
default:
return <Play className={`${base} text-white`} />;
}
}
switch (kind) {
case 'run-started':
return <Play className={`${base} text-[var(--color-text-muted)]`} />;
case 'thinking':
return <Brain className={`${base} ${status === 'running' ? 'text-[var(--color-accent-sky)] animate-pulse' : 'text-[var(--color-text-muted)]'}`} />;
return <Brain className={`${base} text-[var(--color-text-muted)]`} />;
case 'handoff':
return <ArrowRight className={`${base} text-[var(--color-status-warning)]`} />;
case 'tool-call':
return <Wrench className={`${base} text-[var(--color-accent-purple)]`} />;
case 'approval':
return <AlertTriangle className={`${base} ${status === 'running' ? 'text-[var(--color-status-warning)] animate-pulse' : status === 'error' ? 'text-[var(--color-status-error)]' : 'text-[var(--color-status-success)]'}`} />;
return <AlertTriangle className={`${base} ${status === 'error' ? 'text-[var(--color-status-error)]' : 'text-[var(--color-status-success)]'}`} />;
case 'message':
return <MessageSquare className={`${base} ${status === 'running' ? 'text-[var(--color-status-info)] animate-pulse' : status === 'error' ? 'text-[var(--color-status-error)]' : 'text-[var(--color-status-success)]'}`} />;
return <MessageSquare className={`${base} ${status === 'error' ? 'text-[var(--color-status-error)]' : 'text-[var(--color-status-success)]'}`} />;
case 'run-completed':
return <CheckCircle2 className={`${base} text-[var(--color-status-success)]`} />;
case 'run-cancelled':
@@ -95,7 +115,7 @@ function TimelineEventRow({
<div className="relative">
{/* Vertical connector line */}
{!isLast && (
<div className="absolute left-[7px] top-[22px] bottom-0 w-px bg-[var(--color-border)]" />
<div className="absolute left-[9px] top-[22px] bottom-0 w-px bg-[var(--color-border)]" />
)}
<button
@@ -106,7 +126,7 @@ function TimelineEventRow({
>
{/* Node */}
<div className="relative z-10 flex shrink-0 items-start pt-0.5">
<div className={`flex size-[15px] items-center justify-center rounded-full ${event.status === 'running' ? 'brand-gradient-bg' : 'bg-[var(--color-surface-2)]'}`}>
<div className={`flex size-[18px] items-center justify-center rounded-full ${event.status === 'running' ? 'brand-gradient-bg' : 'bg-[var(--color-surface-2)]'}`}>
<EventIcon kind={event.kind} status={event.status} />
</div>
</div>
@@ -179,11 +199,11 @@ function ThinkingGroupRow({
return (
<div className="group relative flex w-full gap-2.5 py-1">
{!isLast && (
<div className="absolute left-[7px] top-[22px] bottom-0 w-px bg-[var(--color-border)]" />
<div className="absolute left-[9px] top-[22px] bottom-0 w-px bg-[var(--color-border)]" />
)}
<div className="relative z-10 flex shrink-0 items-start pt-0.5">
<div className="flex size-[15px] items-center justify-center rounded-full bg-[var(--color-surface-2)]">
<Brain className="size-3.5 text-[var(--color-text-muted)]" />
<div className="flex size-[18px] items-center justify-center rounded-full bg-[var(--color-surface-2)]">
<Brain className="size-2.5 text-[var(--color-text-muted)]" />
</div>
</div>
<div className="min-w-0 flex-1">
@@ -212,6 +232,39 @@ function CollapsedEventRow({
return <TimelineEventRow event={item.event} isLast={isLast} onJumpToMessage={onJumpToMessage} />;
}
/* ── Git baseline snapshot ──────────────────────────────────── */
function RunGitBaseline({ snapshot }: { snapshot: ProjectGitWorkingTreeSnapshot }) {
const { branch, changes, changedFileCount } = snapshot;
const parts: string[] = [];
if (changes.staged > 0) parts.push(`${changes.staged} staged`);
if (changes.unstaged > 0) parts.push(`${changes.unstaged} modified`);
if (changes.untracked > 0) parts.push(`${changes.untracked} untracked`);
if (changes.conflicted > 0) parts.push(`${changes.conflicted} conflicted`);
return (
<div className="mb-1.5 flex items-center gap-1.5 text-[9px] text-[var(--color-text-muted)]">
<GitBranch className="size-2.5 shrink-0" />
{branch && <span className="font-mono text-[var(--color-text-secondary)]">{branch}</span>}
{changedFileCount > 0 ? (
<>
<span>·</span>
<span className="text-[var(--color-status-warning)]">{changedFileCount} changed</span>
{parts.length > 0 && (
<span className="text-[var(--color-text-muted)]">({parts.join(', ')})</span>
)}
</>
) : (
<>
<span>·</span>
<span className="text-[var(--color-status-success)]">clean</span>
</>
)}
</div>
);
}
/* ── Run card ──────────────────────────────────────────────── */
function RunCard({
@@ -219,11 +272,17 @@ function RunCard({
expanded,
onToggle,
onJumpToMessage,
sessionId,
onDiscard,
onOpenCommitComposer,
}: {
run: SessionRunRecord;
expanded: boolean;
onToggle: () => void;
onJumpToMessage?: (messageId: string) => void;
sessionId: string;
onDiscard?: (sessionId: string, runId: string, files?: ProjectGitFileReference[]) => Promise<unknown>;
onOpenCommitComposer?: () => void;
}) {
const accent = modeAccent[run.patternMode] ?? modeAccent.single;
const statusStyle = runStatusStyles[run.status];
@@ -277,6 +336,11 @@ function RunCard({
</div>
)}
{/* Git baseline */}
{run.preRunGitSnapshot && (
<RunGitBaseline snapshot={run.preRunGitSnapshot} />
)}
{/* Timeline events */}
<div>
{collapsedEvents.map((item, index) => (
@@ -295,6 +359,19 @@ function RunCard({
Duration: {duration}
</div>
)}
{/* Post-run git changes */}
{run.postRunGitSummary && run.status !== 'running' && onDiscard && (
<div className="mt-2">
<RunChangeSummaryCard
onDiscard={onDiscard}
onOpenCommitComposer={onOpenCommitComposer}
runId={run.requestId}
sessionId={sessionId}
summary={run.postRunGitSummary}
/>
</div>
)}
</div>
)}
</div>
@@ -315,10 +392,13 @@ function EmptyTimeline() {
interface RunTimelineProps {
runs: readonly SessionRunRecord[];
sessionId: string;
onJumpToMessage?: (messageId: string) => void;
onDiscard?: (sessionId: string, runId: string, files?: ProjectGitFileReference[]) => Promise<unknown>;
onOpenCommitComposer?: () => void;
}
export function RunTimeline({ runs, onJumpToMessage }: RunTimelineProps) {
export function RunTimeline({ runs, sessionId, onJumpToMessage, onDiscard, onOpenCommitComposer }: RunTimelineProps) {
const latestRunId = runs.length > 0 ? runs[0].id : undefined;
const [expandedRunId, setExpandedRunId] = useState<string | undefined>(latestRunId);
@@ -337,9 +417,12 @@ export function RunTimeline({ runs, onJumpToMessage }: RunTimelineProps) {
<RunCard
expanded={expandedRunId === run.id}
key={run.id}
onDiscard={onDiscard}
onJumpToMessage={onJumpToMessage}
onOpenCommitComposer={onOpenCommitComposer}
onToggle={() => setExpandedRunId(expandedRunId === run.id ? undefined : run.id)}
run={run}
sessionId={sessionId}
/>
))}
</div>
+206 -55
View File
@@ -1,5 +1,5 @@
import { useState, type ReactNode } from 'react';
import { ChevronLeft, ChevronRight, Code, Cpu, FolderOpen, Palette, Plus, Server, TriangleAlert, Workflow, Wrench } from 'lucide-react';
import { useEffect, useState, type ReactNode } from 'react';
import { ChevronLeft, ChevronRight, CircleCheck, Code, Cpu, FolderOpen, Palette, Plus, RefreshCw, Server, TriangleAlert, Workflow, Wrench } from 'lucide-react';
import { CopilotStatusCard } from '@renderer/components/CopilotStatusCard';
import { PatternEditor } from '@renderer/components/PatternEditor';
@@ -11,6 +11,7 @@ import type { DiscoveredMcpServer, DiscoveredToolingState } from '@shared/domain
import { listAcceptedDiscoveredMcpServers, listPendingDiscoveredMcpServers } from '@shared/domain/discoveredTooling';
import type { ModelDefinition } from '@shared/domain/models';
import type { PatternDefinition } from '@shared/domain/pattern';
import type { UpdateStatus, UpdateStatusState } from '@shared/contracts/ipc';
import {
normalizeLspProfileDefinition,
normalizeMcpServerDefinition,
@@ -28,6 +29,7 @@ interface SettingsPanelProps {
toolingSettings: WorkspaceToolingSettings;
discoveredUserTooling: DiscoveredToolingState;
isRefreshingCapabilities: boolean;
initialSection?: SettingsSection;
onRefreshCapabilities: () => void;
onClose: () => void;
onSavePattern: (pattern: PatternDefinition) => Promise<void>;
@@ -44,13 +46,15 @@ interface SettingsPanelProps {
onSetNotificationsEnabled: (enabled: boolean) => void;
minimizeToTray: boolean;
onSetMinimizeToTray: (enabled: boolean) => void;
gitAutoRefreshEnabled: boolean;
onSetGitAutoRefreshEnabled: (enabled: boolean) => void;
onOpenAppDataFolder: () => void;
onResetLocalWorkspace: () => Promise<void>;
onResolveUserDiscoveredTooling?: (serverIds: string[], resolution: 'accept' | 'dismiss') => void;
onGetQuota?: () => Promise<Record<string, QuotaSnapshot>>;
}
type SettingsSection = 'appearance' | 'connection' | 'patterns' | 'mcp-servers' | 'lsp-profiles' | 'troubleshooting';
export type SettingsSection = 'appearance' | 'connection' | 'patterns' | 'mcp-servers' | 'lsp-profiles' | 'troubleshooting';
interface NavItem {
id: SettingsSection;
@@ -110,6 +114,7 @@ export function SettingsPanel({
toolingSettings,
discoveredUserTooling,
isRefreshingCapabilities,
initialSection,
onRefreshCapabilities,
onClose,
onSavePattern,
@@ -126,12 +131,14 @@ export function SettingsPanel({
onSetNotificationsEnabled,
minimizeToTray,
onSetMinimizeToTray,
gitAutoRefreshEnabled,
onSetGitAutoRefreshEnabled,
onOpenAppDataFolder,
onResetLocalWorkspace,
onResolveUserDiscoveredTooling,
onGetQuota,
}: SettingsPanelProps) {
const [activeSection, setActiveSection] = useState<SettingsSection>('appearance');
const [activeSection, setActiveSection] = useState<SettingsSection>(initialSection ?? 'appearance');
const [editingPattern, setEditingPattern] = useState<PatternDefinition | null>(null);
const [editingMcpServer, setEditingMcpServer] = useState<McpServerDefinition | null>(null);
const [editingLspProfile, setEditingLspProfile] = useState<LspProfileDefinition | null>(null);
@@ -271,6 +278,8 @@ export function SettingsPanel({
onSetNotificationsEnabled={onSetNotificationsEnabled}
minimizeToTray={minimizeToTray}
onSetMinimizeToTray={onSetMinimizeToTray}
gitAutoRefreshEnabled={gitAutoRefreshEnabled}
onSetGitAutoRefreshEnabled={onSetGitAutoRefreshEnabled}
/>
)}
{activeSection === 'connection' && (
@@ -335,6 +344,8 @@ function AppearanceSection({
onSetNotificationsEnabled,
minimizeToTray,
onSetMinimizeToTray,
gitAutoRefreshEnabled,
onSetGitAutoRefreshEnabled,
}: {
theme: AppearanceTheme;
onSetTheme: (theme: AppearanceTheme) => void;
@@ -342,6 +353,8 @@ function AppearanceSection({
onSetNotificationsEnabled: (enabled: boolean) => void;
minimizeToTray: boolean;
onSetMinimizeToTray: (enabled: boolean) => void;
gitAutoRefreshEnabled: boolean;
onSetGitAutoRefreshEnabled: (enabled: boolean) => void;
}){
return (
<div>
@@ -431,6 +444,30 @@ function AppearanceSection({
</div>
<ToggleSwitch enabled={minimizeToTray} />
</button>
{/* Git */}
<div className="mt-8 mb-1">
<h3 className="font-display text-[13px] font-semibold text-[var(--color-text-primary)]">Git</h3>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">
Control how Aryx monitors your repositories
</p>
</div>
<button
className="mt-4 flex w-full items-center justify-between rounded-lg border border-[var(--color-border)] px-4 py-3 text-left transition hover:bg-[var(--color-surface-3)]/40"
onClick={() => onSetGitAutoRefreshEnabled(!gitAutoRefreshEnabled)}
type="button"
>
<div>
<span className="text-[13px] font-medium text-[var(--color-text-primary)]">
Auto-refresh git status
</span>
<p className="text-[12px] text-[var(--color-text-muted)]">
Periodically poll repository status in the background and refresh on window focus
</p>
</div>
<ToggleSwitch enabled={gitAutoRefreshEnabled} />
</button>
</div>
);
}
@@ -817,6 +854,30 @@ function TroubleshootingSection({
}) {
const [isResetting, setIsResetting] = useState(false);
const [confirmingReset, setConfirmingReset] = useState(false);
const [updateStatus, setUpdateStatus] = useState<UpdateStatus>({ state: 'idle' });
const [isCheckingManually, setIsCheckingManually] = useState(false);
useEffect(() => {
const unsubscribe = window.aryxApi.onUpdateStatus((status) => {
setUpdateStatus(status);
if (status.state !== 'checking') setIsCheckingManually(false);
});
return unsubscribe;
}, []);
async function handleCheckForUpdates() {
setIsCheckingManually(true);
try {
const status = await window.aryxApi.checkForUpdates();
setUpdateStatus(status);
} finally {
setIsCheckingManually(false);
}
}
async function handleInstallUpdate() {
await window.aryxApi.installUpdate();
}
async function handleReset() {
setIsResetting(true);
@@ -828,64 +889,154 @@ function TroubleshootingSection({
}
}
const isChecking = isCheckingManually || updateStatus.state === 'checking';
function getUpdateLabel(): string {
switch (updateStatus.state) {
case 'checking':
return 'Checking for updates…';
case 'up-to-date':
return 'Up to date';
case 'available':
return `Update available: v${updateStatus.version ?? 'unknown'}`;
case 'downloading':
return `Downloading update${updateStatus.downloadProgress ? ` (${Math.round(updateStatus.downloadProgress.percent)}%)` : '…'}`;
case 'downloaded':
return `Update ready: v${updateStatus.version ?? 'unknown'}`;
case 'error':
return 'Update check failed';
default:
return 'Check for updates';
}
}
function getUpdateDescription(): string {
switch (updateStatus.state) {
case 'checking':
return 'Contacting the update server…';
case 'up-to-date':
return 'You are running the latest version of Aryx.';
case 'available':
case 'downloading':
return 'A new version is being downloaded and will be installed automatically.';
case 'downloaded':
return 'Restart Aryx to apply the update.';
case 'error':
return updateStatus.error ?? 'Could not reach the update server. Try again later.';
default:
return 'Manually check whether a newer version of Aryx is available.';
}
}
return (
<div>
<SectionHeader
description="Diagnose issues and manage local application data"
title="Troubleshooting"
/>
<div className="space-y-2">
<TroubleshootingAction
description="Reveal the folder where Aryx stores workspace data, scratchpad files, and configuration."
icon={<FolderOpen className="size-4" />}
label="Open App Data Folder"
onClick={onOpenAppDataFolder}
<div className="flex min-h-full flex-col">
<div className="flex-1">
<SectionHeader
description="Diagnose issues and manage local application data"
title="Troubleshooting"
/>
</div>
<div className="mt-8 rounded-xl border border-[var(--color-status-error)]/20 bg-[var(--color-status-error)]/5 p-5">
<div className="flex items-start gap-3">
<TriangleAlert className="mt-0.5 size-4 shrink-0 text-[var(--color-status-error)]" />
<div className="min-w-0 flex-1">
<h4 className="text-[13px] font-semibold text-[var(--color-status-error)]">Reset Local Workspace</h4>
<p className="mt-1 text-[12px] leading-relaxed text-[var(--color-text-secondary)]">
Restore Aryx to its initial state. This permanently removes all sessions, custom patterns,
MCP server definitions, LSP profiles, and scratchpad contents. Your GitHub Copilot sign-in
is not affected.
</p>
{!confirmingReset ? (
<button
className="mt-3 rounded-lg border border-[var(--color-status-error)]/30 bg-[var(--color-status-error)]/10 px-3.5 py-1.5 text-[13px] font-medium text-[var(--color-status-error)] transition-all duration-200 hover:border-[var(--color-status-error)]/50 hover:bg-[var(--color-status-error)]/20"
onClick={() => setConfirmingReset(true)}
type="button"
>
Reset workspace
</button>
) : (
<div className="mt-3 flex items-center gap-2">
<button
className="rounded-lg bg-[var(--color-status-error)] px-3.5 py-1.5 text-[13px] font-medium text-white transition-all duration-200 hover:bg-[var(--color-status-error)] disabled:opacity-50"
disabled={isResetting}
onClick={() => void handleReset()}
type="button"
>
{isResetting ? 'Resetting…' : 'Confirm reset'}
</button>
<button
className="rounded-lg border border-[var(--color-border)] px-3.5 py-1.5 text-[13px] font-medium text-[var(--color-text-secondary)] transition-all duration-200 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
disabled={isResetting}
onClick={() => setConfirmingReset(false)}
type="button"
>
Cancel
</button>
<div className="space-y-2">
{/* Check for updates */}
{updateStatus.state === 'downloaded' ? (
<button
className="group flex w-full items-center gap-3 rounded-xl border border-[var(--color-status-success)]/20 bg-[var(--color-status-success)]/5 px-4 py-3 text-left transition-all duration-200 hover:border-[var(--color-status-success)]/40 hover:bg-[var(--color-status-success)]/10"
onClick={() => void handleInstallUpdate()}
type="button"
>
<span className="text-[var(--color-status-success)]">
<RefreshCw className="size-4" />
</span>
<div className="min-w-0 flex-1">
<span className="text-[13px] font-medium text-[var(--color-status-success)]">{getUpdateLabel()}</span>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">{getUpdateDescription()}</p>
</div>
)}
<span className="rounded-lg bg-[var(--color-status-success)]/15 px-2.5 py-1 text-[11px] font-semibold text-[var(--color-status-success)]">
Restart
</span>
</button>
) : (
<button
className={`group flex w-full items-center gap-3 rounded-xl border border-transparent px-4 py-3 text-left transition-all duration-200 hover:border-[var(--color-border)] hover:bg-[var(--color-surface-1)] ${isChecking ? 'pointer-events-none opacity-70' : ''}`}
disabled={isChecking}
onClick={() => void handleCheckForUpdates()}
type="button"
>
<span className={`transition-all duration-200 ${updateStatus.state === 'up-to-date' ? 'text-[var(--color-status-success)]' : 'text-[var(--color-text-muted)] group-hover:text-[var(--color-text-secondary)]'}`}>
{updateStatus.state === 'up-to-date'
? <CircleCheck className="size-4" />
: <RefreshCw className={`size-4 ${isChecking ? 'animate-spin' : ''}`} />}
</span>
<div className="min-w-0 flex-1">
<span className={`text-[13px] font-medium ${updateStatus.state === 'error' ? 'text-[var(--color-status-error)]' : updateStatus.state === 'up-to-date' ? 'text-[var(--color-status-success)]' : 'text-[var(--color-text-primary)]'}`}>
{getUpdateLabel()}
</span>
<p className="mt-0.5 text-[12px] text-[var(--color-text-muted)]">{getUpdateDescription()}</p>
</div>
<ChevronRight className="size-4 text-[var(--color-text-muted)] transition-all duration-200 group-hover:text-[var(--color-text-muted)]" />
</button>
)}
<TroubleshootingAction
description="Reveal the folder where Aryx stores workspace data, scratchpad files, and configuration."
icon={<FolderOpen className="size-4" />}
label="Open App Data Folder"
onClick={onOpenAppDataFolder}
/>
</div>
<div className="mt-8 rounded-xl border border-[var(--color-status-error)]/20 bg-[var(--color-status-error)]/5 p-5">
<div className="flex items-start gap-3">
<TriangleAlert className="mt-0.5 size-4 shrink-0 text-[var(--color-status-error)]" />
<div className="min-w-0 flex-1">
<h4 className="text-[13px] font-semibold text-[var(--color-status-error)]">Reset Local Workspace</h4>
<p className="mt-1 text-[12px] leading-relaxed text-[var(--color-text-secondary)]">
Restore Aryx to its initial state. This permanently removes all sessions, custom patterns,
MCP server definitions, LSP profiles, and scratchpad contents. Your GitHub Copilot sign-in
is not affected.
</p>
{!confirmingReset ? (
<button
className="mt-3 rounded-lg border border-[var(--color-status-error)]/30 bg-[var(--color-status-error)]/10 px-3.5 py-1.5 text-[13px] font-medium text-[var(--color-status-error)] transition-all duration-200 hover:border-[var(--color-status-error)]/50 hover:bg-[var(--color-status-error)]/20"
onClick={() => setConfirmingReset(true)}
type="button"
>
Reset workspace
</button>
) : (
<div className="mt-3 flex items-center gap-2">
<button
className="rounded-lg bg-[var(--color-status-error)] px-3.5 py-1.5 text-[13px] font-medium text-white transition-all duration-200 hover:bg-[var(--color-status-error)] disabled:opacity-50"
disabled={isResetting}
onClick={() => void handleReset()}
type="button"
>
{isResetting ? 'Resetting…' : 'Confirm reset'}
</button>
<button
className="rounded-lg border border-[var(--color-border)] px-3.5 py-1.5 text-[13px] font-medium text-[var(--color-text-secondary)] transition-all duration-200 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
disabled={isResetting}
onClick={() => setConfirmingReset(false)}
type="button"
>
Cancel
</button>
</div>
)}
</div>
</div>
</div>
</div>
{/* Attribution footer */}
<div className="mt-12 flex items-center justify-center gap-1.5 pb-2 text-[11px] text-[var(--color-text-muted)]">
<span>Built with</span>
<svg aria-hidden="true" className="size-3 text-[var(--color-status-error)]" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
</svg>
<span>by Dávid Kaya</span>
</div>
</div>
);
}
+118 -66
View File
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import appIconUrl from '../../../assets/icons/icon.png';
import { isMac } from '@renderer/lib/platform';
import {
AlertTriangle,
Archive,
@@ -32,7 +33,9 @@ import { isScratchpadProject, type ProjectRecord, type ProjectGitContext } from
import { listPendingDiscoveredMcpServers } from '@shared/domain/discoveredTooling';
import type { SessionRecord } from '@shared/domain/session';
import { querySessions } from '@shared/domain/sessionLibrary';
import type { UpdateStatus } from '@shared/contracts/ipc';
import type { WorkspaceState } from '@shared/domain/workspace';
import { UpdateBanner } from '@renderer/components/ui';
interface SidebarProps {
workspace: WorkspaceState;
@@ -49,6 +52,9 @@ interface SidebarProps {
onSetSessionArchived: (sessionId: string, isArchived: boolean) => void;
onDeleteSession: (sessionId: string) => void;
onRefreshGitContext: (projectId: string) => void;
updateStatus?: UpdateStatus;
onViewUpdateDetails?: () => void;
onInstallUpdate?: () => void;
}
/* ── Mode icon + accent colour mapping ─────────────────────── */
@@ -116,10 +122,27 @@ function GitContextBadge({ git }: { git: ProjectGitContext }) {
if (git.ahead) parts.push(`${git.ahead}`);
if (git.behind) parts.push(`${git.behind}`);
const tooltipLines: string[] = [branchLabel];
if (git.changes) {
const breakdown: string[] = [];
if (git.changes.staged > 0) breakdown.push(`${git.changes.staged} staged`);
if (git.changes.unstaged > 0) breakdown.push(`${git.changes.unstaged} modified`);
if (git.changes.untracked > 0) breakdown.push(`${git.changes.untracked} untracked`);
if (git.changes.conflicted > 0) breakdown.push(`${git.changes.conflicted} conflicted`);
if (breakdown.length > 0) tooltipLines.push(breakdown.join(', '));
}
if (git.ahead || git.behind) {
const sync: string[] = [];
if (git.ahead) sync.push(`${git.ahead} ahead`);
if (git.behind) sync.push(`${git.behind} behind`);
tooltipLines.push(sync.join(', '));
}
if (git.upstream) tooltipLines.push(`${git.upstream}`);
return (
<span className="flex items-center gap-1 text-[10px] text-[var(--color-text-muted)]" title={parts.join(' · ') || branchLabel}>
<span className="flex items-center gap-1 text-[10px] text-[var(--color-text-muted)]" title={tooltipLines.join('\n')}>
<GitBranch className="size-2.5 shrink-0" />
<span className="max-w-[80px] truncate">{branchLabel}</span>
<span className="max-w-[140px] truncate font-mono">{branchLabel}</span>
{git.isDirty && <Circle className="size-1.5 shrink-0 fill-amber-500 text-amber-500" />}
</span>
);
@@ -395,76 +418,93 @@ function ProjectGroup({
return (
<div>
<button
className="group flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] font-semibold text-[var(--color-text-secondary)] transition-all duration-150 hover:bg-[var(--color-surface-2)]/40 hover:text-[var(--color-text-primary)]"
className="group flex w-full flex-col gap-0.5 rounded-lg px-2 py-2 text-left transition-all duration-150 hover:bg-[var(--color-surface-2)]/40"
onClick={() => setExpanded(!expanded)}
type="button"
title={`${project.name}\n${project.path}`}
>
{expanded ? (
<ChevronDown className="size-3 shrink-0 text-[var(--color-text-muted)]" />
) : (
<ChevronRight className="size-3 shrink-0 text-[var(--color-text-muted)]" />
)}
{isScratchpad ? (
<MessageSquare className="size-3.5 shrink-0 text-[var(--color-text-muted)] transition group-hover:text-[var(--color-accent)]" />
) : (
<FolderOpen className="size-3.5 shrink-0 text-[var(--color-text-muted)] transition group-hover:text-[var(--color-accent)]" />
)}
<span className="truncate">{project.name}</span>
{/* Row 1 — project identity + hover actions */}
<div className="flex w-full items-center gap-2 text-[13px] font-semibold text-[var(--color-text-secondary)] group-hover:text-[var(--color-text-primary)]">
{expanded ? (
<ChevronDown className="size-3 shrink-0 text-[var(--color-text-muted)]" />
) : (
<ChevronRight className="size-3 shrink-0 text-[var(--color-text-muted)]" />
)}
{isScratchpad ? (
<MessageSquare className="size-3.5 shrink-0 text-[var(--color-text-muted)] transition group-hover:text-[var(--color-accent)]" />
) : (
<FolderOpen className="size-3.5 shrink-0 text-[var(--color-text-muted)] transition group-hover:text-[var(--color-accent)]" />
)}
<span className="min-w-0 flex-1 truncate">{project.name}</span>
{!isScratchpad && project.git && (
<GitContextBadge git={project.git} />
)}
{isScratchpad && (
<span className="shrink-0 rounded-full bg-[var(--color-surface-2)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-text-muted)]">
{visibleSessions.length}
</span>
)}
<div className="ml-auto flex items-center gap-1.5">
{!isScratchpad && onOpenProjectSettings && (
<span
className="flex size-5 items-center justify-center rounded text-[var(--color-text-muted)] opacity-0 transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)] group-hover:opacity-100"
onClick={(e) => {
e.stopPropagation();
onOpenProjectSettings(project.id);
}}
role="button"
title="Project settings"
>
<Settings className="size-3" />
</span>
{!isScratchpad && (onOpenProjectSettings || onRefreshGitContext) && (
<div className="flex shrink-0 items-center gap-0.5">
{onOpenProjectSettings && (
<span
className="flex size-5 items-center justify-center rounded text-[var(--color-text-muted)] opacity-0 transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)] group-hover:opacity-100"
onClick={(e) => {
e.stopPropagation();
onOpenProjectSettings(project.id);
}}
role="button"
title="Project settings"
>
<Settings className="size-3" />
</span>
)}
{onRefreshGitContext && (
<span
className="flex size-5 items-center justify-center rounded text-[var(--color-text-muted)] opacity-0 transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)] group-hover:opacity-100"
onClick={(e) => {
e.stopPropagation();
onRefreshGitContext(project.id);
}}
role="button"
title="Refresh git status"
>
<RefreshCw className="size-3" />
</span>
)}
</div>
)}
{!isScratchpad && onRefreshGitContext && (
<span
className="flex size-5 items-center justify-center rounded text-[var(--color-text-muted)] opacity-0 transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)] group-hover:opacity-100"
onClick={(e) => {
e.stopPropagation();
onRefreshGitContext(project.id);
}}
role="button"
title="Refresh git status"
>
<RefreshCw className="size-3" />
</span>
)}
{runningCount > 0 && (
<span className="flex items-center gap-1 rounded-full bg-[var(--color-accent-sky)]/10 px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-accent-sky)]">
<span className="size-1.5 rounded-full bg-[var(--color-accent-sky)] sidebar-pulse" />
{runningCount}
</span>
)}
{pendingDiscoveryCount > 0 && (
<span
className="flex cursor-pointer items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400 transition hover:bg-amber-500/20"
onClick={(e) => {
e.stopPropagation();
onOpenProjectSettings?.(project.id);
}}
role="button"
title={`${pendingDiscoveryCount} MCP server${pendingDiscoveryCount === 1 ? '' : 's'} discovered — click to review`}
>
{pendingDiscoveryCount} new
</span>
)}
<span className="rounded-full bg-[var(--color-surface-2)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-text-muted)]">
{visibleSessions.length}
</span>
</div>
{/* Row 2 — metadata strip: branch, status badges, session count */}
{!isScratchpad && (project.git || runningCount > 0 || pendingDiscoveryCount > 0 || visibleSessions.length > 0) && (
<div className="ml-[26px] flex items-center gap-2">
{project.git && <GitContextBadge git={project.git} />}
{runningCount > 0 && (
<span className="flex items-center gap-1 rounded-full bg-[var(--color-accent-sky)]/10 px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-accent-sky)]">
<span className="size-1.5 rounded-full bg-[var(--color-accent-sky)] sidebar-pulse" />
{runningCount}
</span>
)}
{pendingDiscoveryCount > 0 && (
<span
className="flex cursor-pointer items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400 transition hover:bg-amber-500/20"
onClick={(e) => {
e.stopPropagation();
onOpenProjectSettings?.(project.id);
}}
role="button"
title={`${pendingDiscoveryCount} MCP server${pendingDiscoveryCount === 1 ? '' : 's'} discovered — click to review`}
>
{pendingDiscoveryCount} new
</span>
)}
<span className="ml-auto rounded-full bg-[var(--color-surface-2)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-text-muted)]">
{visibleSessions.length}
</span>
</div>
)}
</button>
{expanded && (
@@ -522,6 +562,9 @@ export function Sidebar({
onSetSessionArchived,
onDeleteSession,
onRefreshGitContext,
updateStatus,
onViewUpdateDetails,
onInstallUpdate,
}: SidebarProps) {
const scratchpadProject = workspace.projects.find((project) => isScratchpadProject(project));
const userProjects = workspace.projects.filter((project) => !isScratchpadProject(project));
@@ -581,7 +624,7 @@ export function Sidebar({
return (
<div className="flex h-full flex-col">
{/* Header — extra top padding clears the title bar overlay zone */}
<div className="drag-region flex items-center justify-between border-b border-[var(--color-border-subtle)] px-4 pb-3 pt-3">
<div className={`drag-region flex items-center justify-between border-b border-[var(--color-border-subtle)] pb-3 pt-3 pr-4 ${isMac ? 'pl-20' : 'pl-4'}`}>
<div className="flex items-center gap-2.5">
<img alt="aryx" className="size-8 rounded-xl" src={appIconUrl} />
<div>
@@ -734,6 +777,15 @@ export function Sidebar({
)}
</div>
{/* Update notification banner */}
{updateStatus && onViewUpdateDetails && onInstallUpdate && (
<UpdateBanner
status={updateStatus}
onViewDetails={onViewUpdateDetails}
onInstallUpdate={onInstallUpdate}
/>
)}
{/* Footer */}
{userProjects.length > 0 && (
<div className="border-t border-[var(--color-border-subtle)] px-3 py-2">
+17 -103
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { RotateCcw, Minus, X } from 'lucide-react';
import { RotateCcw } from 'lucide-react';
import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import '@xterm/xterm/css/xterm.css';
@@ -44,17 +44,11 @@ const DEFAULT_HEIGHT = 280;
/* ── TerminalPanel ────────────────────────────────────────── */
interface TerminalPanelProps {
height: number;
onHeightChange: (height: number) => void;
onClose: () => void;
onMinimize: () => void;
onRunningChange?: (running: boolean) => void;
}
export function TerminalPanel({
height,
onHeightChange,
onClose,
onMinimize,
onRunningChange,
}: TerminalPanelProps) {
const api = getElectronApi();
const containerRef = useRef<HTMLDivElement>(null);
@@ -62,8 +56,6 @@ export function TerminalPanel({
const fitAddonRef = useRef<FitAddon | null>(null);
const [snapshot, setSnapshot] = useState<TerminalSnapshot>();
const [isRunning, setIsRunning] = useState(false);
const [isDragging, setIsDragging] = useState(false);
const dragStartRef = useRef<{ y: number; height: number } | null>(null);
// Create or recover terminal on mount
useEffect(() => {
@@ -74,11 +66,13 @@ export function TerminalPanel({
if (existing) {
setSnapshot(existing);
setIsRunning(true);
onRunningChange?.(true);
} else {
void api.createTerminal().then((created) => {
if (disposed) return;
setSnapshot(created);
setIsRunning(true);
onRunningChange?.(true);
});
}
});
@@ -135,6 +129,7 @@ export function TerminalPanel({
});
const offExit = api.onTerminalExit((_info: TerminalExitInfo) => {
setIsRunning(false);
onRunningChange?.(false);
terminalRef.current?.write('\r\n\x1b[90m[Process exited]\x1b[0m\r\n');
});
@@ -144,19 +139,7 @@ export function TerminalPanel({
};
}, [api]);
// Refit on height changes
useEffect(() => {
if (!fitAddonRef.current || !terminalRef.current) return;
requestAnimationFrame(() => {
fitAddonRef.current?.fit();
const terminal = terminalRef.current;
if (terminal) {
api.resizeTerminal({ cols: terminal.cols, rows: terminal.rows });
}
});
}, [height, api]);
// ResizeObserver for container width changes
// ResizeObserver for container size changes (width or height from parent)
useEffect(() => {
const container = containerRef.current;
if (!container) return;
@@ -174,100 +157,31 @@ export function TerminalPanel({
return () => observer.disconnect();
}, [api]);
// Drag-to-resize
const handleDragStart = useCallback((e: React.MouseEvent) => {
e.preventDefault();
dragStartRef.current = { y: e.clientY, height };
setIsDragging(true);
const handleDragMove = (moveEvent: MouseEvent) => {
if (!dragStartRef.current) return;
const maxHeight = window.innerHeight * MAX_HEIGHT_FRACTION;
const delta = dragStartRef.current.y - moveEvent.clientY;
const nextHeight = Math.max(MIN_HEIGHT, Math.min(maxHeight, dragStartRef.current.height + delta));
onHeightChange(nextHeight);
};
const handleDragEnd = () => {
setIsDragging(false);
dragStartRef.current = null;
document.removeEventListener('mousemove', handleDragMove);
document.removeEventListener('mouseup', handleDragEnd);
};
document.addEventListener('mousemove', handleDragMove);
document.addEventListener('mouseup', handleDragEnd);
}, [height, onHeightChange]);
const handleRestart = useCallback(() => {
void api.restartTerminal().then((restarted) => {
setSnapshot(restarted);
setIsRunning(true);
onRunningChange?.(true);
terminalRef.current?.clear();
});
}, [api]);
const handleClose = useCallback(() => {
void api.killTerminal();
onClose();
}, [api, onClose]);
return (
<div
className="flex flex-col border-t border-[var(--color-border)] bg-[var(--color-surface-0)]"
style={{ height, minHeight: MIN_HEIGHT }}
>
{/* Resize handle */}
<div
className={`h-1 shrink-0 cursor-row-resize transition-colors ${isDragging ? 'bg-[var(--color-accent)]/40' : 'hover:bg-[var(--color-surface-3)]/60'}`}
onMouseDown={handleDragStart}
role="separator"
aria-orientation="horizontal"
aria-label="Resize terminal"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'ArrowUp') {
e.preventDefault();
onHeightChange(Math.min(window.innerHeight * MAX_HEIGHT_FRACTION, height + 20));
} else if (e.key === 'ArrowDown') {
e.preventDefault();
onHeightChange(Math.max(MIN_HEIGHT, height - 20));
}
}}
/>
<div className="flex min-h-0 flex-1 flex-col">
{/* Header bar */}
<div className="flex h-7 shrink-0 items-center gap-2 border-b border-[var(--color-border)] px-3">
<span className={`size-1.5 shrink-0 rounded-full ${isRunning ? 'bg-emerald-400' : 'bg-[var(--color-text-muted)]'}`} />
<span className="min-w-0 flex-1 truncate font-mono text-[11px] text-[var(--color-text-muted)]">
{snapshot ? `${snapshot.shell}${snapshot.cwd}` : 'Terminal'}
</span>
<div className="flex items-center gap-0.5">
<button
aria-label="Restart terminal"
className="rounded p-0.5 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={handleRestart}
type="button"
>
<RotateCcw className="size-3" />
</button>
<button
aria-label="Minimize terminal"
className="rounded p-0.5 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={onMinimize}
type="button"
>
<Minus className="size-3" />
</button>
<button
aria-label="Close terminal"
className="rounded p-0.5 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-red-400"
onClick={handleClose}
type="button"
>
<X className="size-3" />
</button>
</div>
<button
aria-label="Restart terminal"
className="rounded p-0.5 text-[var(--color-text-muted)] transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={handleRestart}
type="button"
>
<RotateCcw className="size-3" />
</button>
</div>
{/* Terminal body */}
+35 -2
View File
@@ -1,7 +1,9 @@
import { CheckCircle2, Circle, FolderPlus, MessageSquarePlus, Settings, Zap } from 'lucide-react';
import { CheckCircle2, Circle, Download, FolderPlus, MessageSquarePlus, Settings, Zap } from 'lucide-react';
import { motion } from 'motion/react';
import type { SidecarConnectionStatus } from '@shared/contracts/sidecar';
import { detectedPlatform } from '@renderer/lib/platform';
import { getInstallInfoForPlatform } from '@renderer/lib/cliInstallInstructions';
import appIconUrl from '../../../assets/icons/icon.png';
interface WelcomePaneProps {
@@ -71,6 +73,34 @@ function SetupStep({ label, done, active }: SetupStepProps) {
);
}
function CliMissingCard({ onOpenSettings }: { onOpenSettings: () => void }) {
const info = getInstallInfoForPlatform(detectedPlatform);
const recommended = info.methods.find((m) => m.recommended) ?? info.methods[0];
return (
<button
type="button"
onClick={onOpenSettings}
className="group flex w-full cursor-pointer items-start gap-4 rounded-xl border border-[var(--color-border-glow)] bg-[var(--color-accent-muted)] px-5 py-4 text-left shadow-[0_0_24px_rgba(36,92,249,0.1)] backdrop-blur-sm transition-all duration-200 hover:shadow-[0_0_32px_rgba(36,92,249,0.15)]"
>
<div className="brand-gradient-bg flex size-9 shrink-0 items-center justify-center rounded-full">
<Download className="size-4 text-white" />
</div>
<div className="min-w-0 space-y-1.5">
<span className="block text-[13px] font-medium text-[var(--color-text-primary)]">
Install the Copilot CLI
</span>
<code className="block truncate rounded-md bg-[var(--color-surface-1)] px-2 py-1 font-mono text-[11px] text-[var(--color-text-secondary)]">
{recommended.command}
</code>
<span className="block text-[11px] text-[var(--color-text-muted)]">
View full instructions for {info.displayName}
</span>
</div>
</button>
);
}
export function WelcomePane({
hasProjects,
connectionStatus,
@@ -165,7 +195,10 @@ export function WelcomePane({
{/* Action cards */}
<motion.div {...fadeUp(isFirstRun && !allDone ? 0.2 : 0.16)} className="flex w-full flex-col gap-2.5">
{/* Primary CTA adapts to state */}
{!isConnected && (
{connectionStatus === 'copilot-cli-missing' && (
<CliMissingCard onOpenSettings={onOpenSettings} />
)}
{!isConnected && connectionStatus !== 'copilot-cli-missing' && (
<ActionCard
icon={<Zap className="size-4 text-white" />}
title="Connect GitHub Copilot"
@@ -0,0 +1,551 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import {
ArrowUpFromLine,
Check,
ChevronRight,
FileCode2,
FileMinus2,
FilePlus2,
GitBranch,
Loader2,
Sparkles,
X,
} from 'lucide-react';
import { getElectronApi } from '@renderer/lib/electronApi';
import type {
ProjectGitCommitMessageSuggestion,
ProjectGitConventionalCommitType,
ProjectGitDetails,
ProjectGitDiffPreview,
ProjectGitFileReference,
ProjectGitWorkingTreeFile,
} from '@shared/domain/project';
/* ── Helpers ───────────────────────────────────────────────── */
function fileBaseName(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash >= 0 ? normalized.slice(lastSlash + 1) : normalized;
}
function fileDir(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash > 0 ? normalized.slice(0, lastSlash + 1) : '';
}
function fileIcon(file: ProjectGitWorkingTreeFile) {
if (file.stagedStatus === 'added' || file.unstagedStatus === 'untracked') {
return <FilePlus2 className="size-3 shrink-0 text-[var(--color-status-success)]" />;
}
if (file.stagedStatus === 'deleted' || file.unstagedStatus === 'deleted') {
return <FileMinus2 className="size-3 shrink-0 text-[var(--color-status-error)]" />;
}
return <FileCode2 className="size-3 shrink-0 text-[var(--color-accent-sky)]" />;
}
function statusLabel(file: ProjectGitWorkingTreeFile): string {
return file.stagedStatus ?? file.unstagedStatus ?? 'modified';
}
const CONVENTIONAL_TYPES: { value: ProjectGitConventionalCommitType; label: string }[] = [
{ value: 'feat', label: 'feat' },
{ value: 'fix', label: 'fix' },
{ value: 'refactor', label: 'refactor' },
{ value: 'docs', label: 'docs' },
{ value: 'test', label: 'test' },
{ value: 'chore', label: 'chore' },
];
/* ── Diff line renderer ────────────────────────────────────── */
function DiffLine({ line }: { line: string }) {
let textClass = 'text-[var(--color-text-secondary)]';
let bgClass = '';
if (line.startsWith('+') && !line.startsWith('+++')) {
textClass = 'text-[var(--color-status-success)]';
bgClass = 'bg-[var(--color-status-success)]/[0.06]';
} else if (line.startsWith('-') && !line.startsWith('---')) {
textClass = 'text-[var(--color-status-error)]';
bgClass = 'bg-[var(--color-status-error)]/[0.06]';
} else if (line.startsWith('@@')) {
textClass = 'text-[var(--color-accent-sky)]';
} else if (line.startsWith('diff ') || line.startsWith('index ') || line.startsWith('---') || line.startsWith('+++')) {
textClass = 'text-[var(--color-text-muted)]';
}
return <div className={`${textClass} ${bgClass} -mx-3 px-3`}>{line || '\u00A0'}</div>;
}
/* ── File row with staging checkbox ────────────────────────── */
function CommitFileRow({
file,
isStaged,
onToggle,
onPreview,
preview,
previewExpanded,
}: {
file: ProjectGitWorkingTreeFile;
isStaged: boolean;
onToggle: () => void;
onPreview: () => void;
preview?: ProjectGitDiffPreview;
previewExpanded: boolean;
}) {
const dir = fileDir(file.path);
const base = fileBaseName(file.path);
const hasPreview = !!preview?.diff || !!preview?.newFileContents;
return (
<div className="border-b border-[var(--color-border-subtle)] last:border-b-0">
<div className="flex items-center gap-1 px-2.5 py-[5px] text-[10px]">
{/* Staging checkbox */}
<button
className={`flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors duration-100 ${
isStaged
? 'border-[var(--color-status-success)] bg-[var(--color-status-success)] text-white'
: 'border-[var(--color-border)] bg-transparent hover:border-[var(--color-text-muted)]'
}`}
onClick={onToggle}
type="button"
aria-label={`${isStaged ? 'Unstage' : 'Stage'} ${file.path}`}
aria-pressed={isStaged}
>
{isStaged && <Check className="size-2" />}
</button>
{/* File path + expand */}
<button
className="flex min-w-0 flex-1 items-center gap-1.5 text-left transition-colors duration-150 hover:text-[var(--color-text-primary)]"
onClick={onPreview}
type="button"
aria-expanded={previewExpanded}
>
{hasPreview || previewExpanded ? (
<ChevronRight
className={`size-2.5 shrink-0 text-[var(--color-text-muted)] transition-transform duration-150 ${previewExpanded ? 'rotate-90' : ''}`}
/>
) : (
<span className="w-2.5 shrink-0" />
)}
{fileIcon(file)}
<span className="min-w-0 flex-1 truncate font-mono">
{dir && <span className="text-[var(--color-text-muted)]">{dir}</span>}
<span className="text-[var(--color-text-primary)]">{base}</span>
</span>
<span className="shrink-0 rounded px-1 py-px text-[8px] font-semibold uppercase tracking-wider bg-[var(--color-surface-3)] text-[var(--color-text-muted)]">
{statusLabel(file)}
</span>
</button>
</div>
{/* Diff preview */}
{previewExpanded && preview && (
<div className="border-t border-[var(--color-border-subtle)]">
<pre className="max-h-52 overflow-auto bg-[var(--color-surface-0)] px-3 py-1.5 font-mono text-[10px] leading-relaxed">
{preview.diff
? preview.diff.split('\n').map((line, i) => <DiffLine key={i} line={line} />)
: preview.newFileContents
? preview.newFileContents.split('\n').map((line, i) => (
<div key={i} className="text-[var(--color-text-secondary)]">{line || '\u00A0'}</div>
))
: preview.isBinary
? <div className="text-[var(--color-text-muted)] italic">Binary file</div>
: <div className="text-[var(--color-text-muted)] italic">Loading</div>}
</pre>
</div>
)}
</div>
);
}
/* ── Main export ───────────────────────────────────────────── */
interface CommitComposerProps {
projectId: string;
sessionId: string;
runId?: string;
onClose: () => void;
}
export function CommitComposer({
projectId,
sessionId,
runId,
onClose,
}: CommitComposerProps) {
const api = getElectronApi();
const [details, setDetails] = useState<ProjectGitDetails>();
const [loading, setLoading] = useState(true);
const [commitMessage, setCommitMessage] = useState('');
const [commitType, setCommitType] = useState<ProjectGitConventionalCommitType>('feat');
const [stagedPaths, setStagedPaths] = useState<Set<string>>(new Set());
const [previews, setPreviews] = useState<Record<string, ProjectGitDiffPreview>>({});
const [expandedPath, setExpandedPath] = useState<string>();
const [committing, setCommitting] = useState(false);
const [pushAfterCommit, setPushAfterCommit] = useState(false);
const [commitError, setCommitError] = useState<string>();
const [commitSuccess, setCommitSuccess] = useState(false);
// Load git details on mount
useEffect(() => {
let cancelled = false;
async function load() {
setLoading(true);
try {
const result = await api.getProjectGitDetails({ projectId });
if (!cancelled) {
setDetails(result);
// Pre-stage files that are already in the index
if (result.workingTree) {
const preStaged = new Set<string>();
for (const file of result.workingTree.files) {
if (file.stagedStatus && file.stagedStatus !== 'unmerged') {
preStaged.add(file.path);
}
}
setStagedPaths(preStaged);
}
}
} finally {
if (!cancelled) setLoading(false);
}
}
void load();
return () => { cancelled = true; };
}, [api, projectId]);
// Load commit message suggestion
useEffect(() => {
let cancelled = false;
async function suggest() {
try {
const suggestion = await api.suggestProjectGitCommitMessage({
sessionId,
runId,
conventionalType: commitType,
});
if (!cancelled && suggestion) {
setCommitMessage(suggestion.message);
setCommitType(suggestion.type);
}
} catch {
// Suggestion is best-effort
}
}
if (!commitMessage) {
void suggest();
}
return () => { cancelled = true; };
}, [api, sessionId, runId]); // Deliberately omitting commitType/commitMessage to avoid re-triggering
const files = useMemo(
() => details?.workingTree?.files ?? [],
[details?.workingTree?.files],
);
const stagedFiles = useMemo(
() => files.filter((f) => stagedPaths.has(f.path)),
[files, stagedPaths],
);
const toggleStaged = useCallback((path: string) => {
setStagedPaths((prev) => {
const next = new Set(prev);
if (next.has(path)) {
next.delete(path);
} else {
next.add(path);
}
return next;
});
}, []);
const toggleAll = useCallback(() => {
if (stagedPaths.size === files.length) {
setStagedPaths(new Set());
} else {
setStagedPaths(new Set(files.map((f) => f.path)));
}
}, [files, stagedPaths.size]);
const handlePreview = useCallback(async (file: ProjectGitWorkingTreeFile) => {
if (expandedPath === file.path) {
setExpandedPath(undefined);
return;
}
setExpandedPath(file.path);
if (!previews[file.path]) {
try {
const preview = await api.getProjectGitFilePreview({
projectId,
file: { path: file.path, previousPath: file.previousPath },
});
if (preview) {
setPreviews((prev) => ({ ...prev, [file.path]: preview }));
}
} catch {
// Preview is best-effort
}
}
}, [api, expandedPath, previews, projectId]);
const handleSuggestMessage = useCallback(async () => {
try {
const suggestion = await api.suggestProjectGitCommitMessage({
sessionId,
runId,
conventionalType: commitType,
});
if (suggestion) {
setCommitMessage(suggestion.message);
setCommitType(suggestion.type);
}
} catch {
// Best-effort
}
}, [api, sessionId, runId, commitType]);
const handleCommit = useCallback(async () => {
if (!commitMessage.trim() || stagedFiles.length === 0) return;
setCommitting(true);
setCommitError(undefined);
try {
const filesToCommit: ProjectGitFileReference[] = stagedFiles.map((f) => ({
path: f.path,
previousPath: f.previousPath,
}));
await api.commitProjectGitChanges({
projectId,
message: commitMessage.trim(),
files: filesToCommit,
push: pushAfterCommit,
});
setCommitSuccess(true);
setTimeout(() => onClose(), 1200);
} catch (error) {
setCommitError(error instanceof Error ? error.message : String(error));
} finally {
setCommitting(false);
}
}, [api, commitMessage, onClose, projectId, pushAfterCommit, stagedFiles]);
// Keyboard: Escape to close
useEffect(() => {
const handleKey = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
e.preventDefault();
e.stopPropagation();
onClose();
}
};
window.addEventListener('keydown', handleKey, true);
return () => window.removeEventListener('keydown', handleKey, true);
}, [onClose]);
return (
<div
className="fixed inset-0 z-50 flex items-stretch justify-end"
role="dialog"
aria-modal="true"
aria-labelledby="commit-composer-title"
>
{/* Backdrop */}
<div
className="absolute inset-0 bg-black/40 backdrop-blur-[2px]"
onClick={onClose}
/>
{/* Panel */}
<div className="relative z-10 flex w-[420px] max-w-full flex-col border-l border-[var(--color-border)] bg-[var(--color-surface-1)] shadow-2xl">
{/* Header */}
<div className="flex items-center gap-2 border-b border-[var(--color-border-subtle)] px-4 py-3">
<GitBranch className="size-4 text-[var(--color-accent-sky)]" />
<h2 id="commit-composer-title" className="font-display text-sm font-semibold text-[var(--color-text-primary)]">
Commit Changes
</h2>
{details?.context.branch && (
<span className="font-mono text-[10px] text-[var(--color-text-muted)]">
on {details.context.branch}
</span>
)}
<div className="flex-1" />
<button
className="rounded-md p-1 text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
onClick={onClose}
type="button"
aria-label="Close commit composer"
>
<X className="size-4" />
</button>
</div>
{/* Loading */}
{loading && (
<div className="flex flex-1 items-center justify-center">
<Loader2 className="size-5 animate-spin text-[var(--color-text-muted)]" aria-label="Loading git details" />
</div>
)}
{/* Success state */}
{commitSuccess && (
<div className="flex flex-1 flex-col items-center justify-center gap-3 px-6">
<div className="flex size-12 items-center justify-center rounded-full bg-[var(--color-status-success)]/10">
<Check className="size-6 text-[var(--color-status-success)]" />
</div>
<p className="text-sm font-medium text-[var(--color-status-success)]">
Changes committed{pushAfterCommit ? ' and pushed' : ''}
</p>
</div>
)}
{/* Content */}
{!loading && !commitSuccess && (
<>
{/* Commit message */}
<div className="border-b border-[var(--color-border-subtle)] px-4 py-3">
{/* Type selector */}
<div className="mb-2 flex items-center gap-1">
{CONVENTIONAL_TYPES.map((ct) => (
<button
key={ct.value}
className={`rounded-md px-2 py-0.5 text-[10px] font-medium transition-colors duration-100 ${
commitType === ct.value
? 'bg-[var(--color-accent)]/15 text-[var(--color-text-accent)]'
: 'text-[var(--color-text-muted)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]'
}`}
onClick={() => setCommitType(ct.value)}
type="button"
>
{ct.label}
</button>
))}
<div className="flex-1" />
<button
className="flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[9px] font-medium text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-accent)]"
onClick={() => void handleSuggestMessage()}
type="button"
title="Suggest commit message"
>
<Sparkles className="size-3" />
Suggest
</button>
</div>
<textarea
className="w-full resize-none rounded-md border border-[var(--color-border)] bg-[var(--color-surface-0)] px-3 py-2 font-mono text-[11px] leading-relaxed text-[var(--color-text-primary)] placeholder:text-[var(--color-text-muted)] focus:border-[var(--color-accent)] focus:outline-none"
placeholder="Commit message…"
rows={3}
value={commitMessage}
onChange={(e) => setCommitMessage(e.target.value)}
/>
</div>
{/* File list */}
<div className="min-h-0 flex-1 overflow-y-auto">
{/* Select all header */}
<div className="flex items-center gap-2 border-b border-[var(--color-border-subtle)] px-2.5 py-1.5">
<button
className={`flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors duration-100 ${
stagedPaths.size === files.length && files.length > 0
? 'border-[var(--color-status-success)] bg-[var(--color-status-success)] text-white'
: 'border-[var(--color-border)] bg-transparent hover:border-[var(--color-text-muted)]'
}`}
onClick={toggleAll}
type="button"
aria-label={stagedPaths.size === files.length ? 'Unstage all' : 'Stage all'}
>
{stagedPaths.size === files.length && files.length > 0 && <Check className="size-2" />}
</button>
<span className="text-[10px] font-medium text-[var(--color-text-muted)]">
{stagedPaths.size} of {files.length} staged
</span>
</div>
{files.length === 0 ? (
<p className="px-4 py-6 text-center text-[11px] text-[var(--color-text-muted)]">
Working tree is clean nothing to commit.
</p>
) : (
files.map((file) => (
<CommitFileRow
file={file}
isStaged={stagedPaths.has(file.path)}
key={file.path}
onPreview={() => void handlePreview(file)}
onToggle={() => toggleStaged(file.path)}
preview={previews[file.path]}
previewExpanded={expandedPath === file.path}
/>
))
)}
</div>
{/* Error */}
{commitError && (
<div className="border-t border-[var(--color-status-error)]/20 bg-[var(--color-status-error)]/5 px-4 py-2 text-[10px] text-[var(--color-status-error)]" role="alert">
{commitError}
</div>
)}
{/* Footer actions */}
<div className="flex items-center gap-2 border-t border-[var(--color-border-subtle)] px-4 py-3">
{/* Push toggle */}
<label className="flex cursor-pointer items-center gap-1.5 text-[10px] text-[var(--color-text-muted)]">
<input
type="checkbox"
checked={pushAfterCommit}
onChange={(e) => setPushAfterCommit(e.target.checked)}
className="accent-[var(--color-accent)]"
/>
Push after commit
</label>
<div className="flex-1" />
<button
className="rounded-md px-3 py-1.5 text-[11px] font-medium text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)]"
onClick={onClose}
type="button"
>
Cancel
</button>
<button
className="flex items-center gap-1.5 rounded-md bg-[var(--color-accent)] px-3 py-1.5 text-[11px] font-medium text-white transition-colors duration-150 hover:bg-[var(--color-accent-hover)] disabled:cursor-not-allowed disabled:opacity-50"
disabled={committing || !commitMessage.trim() || stagedFiles.length === 0}
onClick={() => void handleCommit()}
type="button"
>
{committing ? (
<Loader2 className="size-3 animate-spin" />
) : (
<ArrowUpFromLine className="size-3" />
)}
{committing ? 'Committing…' : pushAfterCommit ? 'Commit & Push' : 'Commit'}
</button>
</div>
</>
)}
</div>
</div>
);
}
+110 -16
View File
@@ -1,5 +1,5 @@
import { useMemo, useState } from 'react';
import { ChevronDown, ChevronRight, Loader2, Minus, Search, Sparkles, TerminalSquare } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { ChevronDown, ChevronRight, GitBranch, Loader2, Minus, Search, Sparkles, TerminalSquare } from 'lucide-react';
import { ProviderIcon } from '@renderer/components/ProviderIcons';
import { PopoverToggleRow } from '@renderer/components/ui';
@@ -250,7 +250,27 @@ export function InlineToolsPill({
</button>
{open && !disabled && (
<div className="absolute bottom-full left-0 z-40 mb-1.5 w-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-1)] py-1 shadow-2xl">
<div className="absolute bottom-full left-0 z-40 mb-1.5 max-h-[28rem] w-64 overflow-y-auto rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-1)] shadow-2xl">
{/* Header: enable / disable all */}
<div className="sticky top-0 z-10 border-b border-[var(--color-border)] bg-[var(--color-surface-1)]">
<div className="flex items-center justify-end px-3 py-1.5">
<button
className="flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-medium text-[var(--color-text-muted)] transition-all duration-200 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
onClick={() => {
const allEnabled = enabledCount === totalCount;
onToggle({
enabledMcpServerIds: allEnabled ? [] : mcpServers.map((s) => s.id),
enabledLspProfileIds: allEnabled ? [] : lspProfiles.map((p) => p.id),
});
}}
type="button"
>
{enabledCount === totalCount ? 'Disable all' : 'Enable all'}
</button>
</div>
</div>
<div className="py-1">
{workspaceMcpServers.length > 0 && (
<McpServerGroup
label="Workspace MCP"
@@ -296,6 +316,7 @@ export function InlineToolsPill({
))}
</div>
)}
</div>
</div>
)}
</div>
@@ -397,9 +418,19 @@ export function InlineApprovalPill({
.filter((g) => g.tools.length > 0 || g.label.toLowerCase().includes(searchLower));
}, [groups, searchLower]);
function toggleTool(toolId: string) {
function toggleTool(toolId: string, group: ApprovalToolGroup) {
const next = new Set(effectiveAutoApproved);
if (next.has(toolId)) {
// If the group has server-level approval, expand it to individual tools
// so the user can selectively disable one tool.
if (group.serverApprovalKey && next.has(group.serverApprovalKey)) {
next.delete(group.serverApprovalKey);
for (const tool of group.tools) {
if (tool.id !== toolId) {
next.add(tool.id);
}
}
} else if (next.has(toolId)) {
next.delete(toolId);
} else {
next.add(toolId);
@@ -470,6 +501,31 @@ export function InlineApprovalPill({
return expandedGroups.has(groupId);
}
function isToolEffectivelyApproved(toolId: string, group: ApprovalToolGroup): boolean {
if (effectiveAutoApproved.has(toolId)) return true;
if (group.serverApprovalKey && effectiveAutoApproved.has(group.serverApprovalKey)) return true;
return false;
}
const allApprovedGlobal = effectiveAutoApprovedCount === totalItemCount && totalItemCount > 0;
const approveAll = useCallback(() => {
const next = new Set<string>();
for (const group of groups) {
if (group.serverApprovalKey) {
next.add(group.serverApprovalKey);
}
for (const tool of group.tools) {
next.add(tool.id);
}
}
onUpdate({ autoApprovedToolNames: [...next] });
}, [groups, onUpdate]);
const unapproveAll = useCallback(() => {
onUpdate({ autoApprovedToolNames: [] });
}, [onUpdate]);
return (
<div className="relative" ref={ref}>
<button
@@ -510,16 +566,25 @@ export function InlineApprovalPill({
}`}>
{isOverridden ? 'Session override' : 'Pattern defaults'}
</span>
{isOverridden && (
<span className="ml-auto flex items-center gap-1">
{isOverridden && (
<button
className="flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-medium text-[var(--color-text-muted)] transition-all duration-200 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
onClick={() => onUpdate({})}
type="button"
>
<RotateCcw className="size-2.5" />
Reset
</button>
)}
<button
className="flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-medium text-[var(--color-text-muted)] transition-all duration-200 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]"
onClick={() => onUpdate({})}
onClick={allApprovedGlobal ? unapproveAll : approveAll}
type="button"
>
<RotateCcw className="size-2.5" />
Reset
{allApprovedGlobal ? 'Unapprove all' : 'Approve all'}
</button>
)}
</span>
</div>
{/* Search */}
@@ -607,9 +672,9 @@ export function InlineApprovalPill({
<div key={tool.id} className={isCollapsible ? 'pl-3' : ''}>
<PopoverToggleRow
detail={detail}
enabled={effectiveAutoApproved.has(tool.id)}
enabled={isToolEffectivelyApproved(tool.id, group)}
label={tool.label}
onToggle={() => toggleTool(tool.id)}
onToggle={() => toggleTool(tool.id, group)}
/>
</div>
);
@@ -642,8 +707,8 @@ function GroupToggle({
return (
<button
aria-pressed={allApproved}
className={`relative inline-flex h-[16px] w-[28px] shrink-0 items-center rounded-full transition-colors ${
allApproved ? 'bg-[var(--color-accent)]' : someApproved ? 'bg-[var(--color-surface-3)]' : 'bg-[var(--color-surface-3)]'
className={`relative inline-flex h-[14px] w-[24px] shrink-0 items-center rounded-full transition-all duration-200 ${
allApproved ? 'brand-gradient-bg shadow-[0_0_8px_rgba(36,92,249,0.3)]' : 'bg-[var(--color-surface-3)]'
}`}
onClick={onToggle}
type="button"
@@ -652,8 +717,8 @@ function GroupToggle({
<Minus className="absolute left-1/2 size-2 -translate-x-1/2 text-[var(--color-text-primary)]" strokeWidth={3} />
) : (
<span
className={`inline-block size-[12px] rounded-full bg-white shadow transition-transform ${
allApproved ? 'translate-x-[13px]' : 'translate-x-[2px]'
className={`inline-block size-[10px] rounded-full bg-white shadow-sm transition-transform ${
allApproved ? 'translate-x-[12px]' : 'translate-x-[2px]'
}`}
/>
)}
@@ -692,3 +757,32 @@ export function InlineTerminalPill({
</button>
);
}
/* ── InlineGitPill ─────────────────────────────────────────── */
export function InlineGitPill({
isDirty,
isOpen,
onToggle,
}: {
isDirty: boolean;
isOpen: boolean;
onToggle: () => void;
}) {
return (
<button
aria-pressed={isOpen}
className={`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium transition-all duration-200 ${
isOpen
? 'bg-[var(--color-accent-muted)] text-[var(--color-text-accent)] hover:bg-[var(--color-accent)]/20'
: 'text-[var(--color-text-muted)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]'
}`}
onClick={onToggle}
type="button"
>
{isDirty && <span className="size-1.5 shrink-0 rounded-full bg-[var(--color-status-warning)]" />}
<GitBranch className="size-3" />
<span>Git</span>
</button>
);
}
@@ -8,7 +8,6 @@ import {
FileText,
Globe,
Server,
Terminal,
} from 'lucide-react';
import type { PermissionDetail } from '@shared/contracts/sidecar';
@@ -61,6 +60,37 @@ export function permissionDetailSummary(detail: PermissionDetail): string | unde
}
}
/* ── Display helpers ─────────────────────────────────────────── */
/** Recursively parse string values that contain JSON objects or arrays (display-time only). */
function deepParseJsonStrings(value: unknown): unknown {
if (typeof value === 'string') {
const trimmed = value.trim();
if (
(trimmed.startsWith('{') && trimmed.endsWith('}')) ||
(trimmed.startsWith('[') && trimmed.endsWith(']'))
) {
try {
return deepParseJsonStrings(JSON.parse(trimmed));
} catch {
return value;
}
}
return value;
}
if (Array.isArray(value)) {
return value.map(deepParseJsonStrings);
}
if (value !== null && typeof value === 'object') {
const result: Record<string, unknown> = {};
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
result[k] = deepParseJsonStrings(v);
}
return result;
}
return value;
}
/* ── Kind-specific renderers ────────────────────────────────── */
function ShellDetail({ detail }: { detail: PermissionDetail }) {
@@ -134,7 +164,7 @@ function McpDetail({ detail }: { detail: PermissionDetail }) {
)}
</div>
{detail.args && Object.keys(detail.args).length > 0 && (
<CollapsibleCode label="Arguments" text={JSON.stringify(detail.args, null, 2)} />
<CollapsibleCode label="Arguments" text={JSON.stringify(deepParseJsonStrings(detail.args), null, 2)} />
)}
</div>
);
@@ -185,7 +215,7 @@ function CustomToolDetail({ detail }: { detail: PermissionDetail }) {
<p className="text-[11px] text-[var(--color-text-secondary)]">{detail.toolDescription}</p>
)}
{detail.args && Object.keys(detail.args).length > 0 && (
<CollapsibleCode label="Arguments" text={JSON.stringify(detail.args, null, 2)} />
<CollapsibleCode label="Arguments" text={JSON.stringify(deepParseJsonStrings(detail.args), null, 2)} />
)}
</div>
);
@@ -201,13 +231,13 @@ function HookDetail({ detail }: { detail: PermissionDetail }) {
</div>
)}
{detail.args && Object.keys(detail.args).length > 0 && (
<CollapsibleCode label="Arguments" text={JSON.stringify(detail.args, null, 2)} />
<CollapsibleCode label="Arguments" text={JSON.stringify(deepParseJsonStrings(detail.args), null, 2)} />
)}
</div>
);
}
/* ── Shared primitives ──────────────────────────────────────── */
/* ── Shared primitives──────────────────────────────────────── */
function IntentionLine({ text }: { text: string }) {
return <p className="text-[11px] italic text-[var(--color-text-secondary)]">{text}</p>;
@@ -242,6 +272,47 @@ function DiffBlock({ text }: { text: string }) {
);
}
/* ── JSON syntax highlighting ───────────────────────────────── */
const jsonTokenPattern =
/("(?:[^"\\]|\\.)*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{}\[\],])/g;
function JsonHighlighted({ json }: { json: string }) {
const elements: React.ReactNode[] = [];
let lastIndex = 0;
let key = 0;
for (const match of json.matchAll(jsonTokenPattern)) {
const idx = match.index ?? 0;
if (idx > lastIndex) elements.push(json.slice(lastIndex, idx));
if (match[1] && match[2]) {
// Object key + colon
elements.push(
<span key={key++} className="text-[var(--color-text-accent)]">{match[1]}</span>,
<span key={key++} className="text-[var(--color-text-muted)]">{match[2]}</span>,
);
} else if (match[1]) {
// String value
elements.push(<span key={key++} className="text-[var(--color-status-success)]">{match[1]}</span>);
} else if (match[3]) {
// true / false / null
elements.push(<span key={key++} className="text-[var(--color-accent-sky)]">{match[3]}</span>);
} else if (match[4]) {
// Number
elements.push(<span key={key++} className="text-[var(--color-accent-sky)]">{match[4]}</span>);
} else if (match[5]) {
// Structural punctuation
elements.push(<span key={key++} className="text-[var(--color-text-muted)]">{match[5]}</span>);
}
lastIndex = idx + match[0].length;
}
if (lastIndex < json.length) elements.push(json.slice(lastIndex));
return <>{elements}</>;
}
function CollapsibleCode({
label,
text,
@@ -254,6 +325,7 @@ function CollapsibleCode({
defaultExpanded?: boolean;
}) {
const [expanded, setExpanded] = useState(defaultExpanded);
const isJson = text.trimStart().startsWith('{') || text.trimStart().startsWith('[');
return (
<div className="rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface-1)]">
@@ -272,7 +344,7 @@ function CollapsibleCode({
<div className="border-t border-[var(--color-border-subtle)] px-2.5 py-1.5">
{children ?? (
<pre className="max-h-48 overflow-auto font-mono text-[10px] leading-relaxed text-[var(--color-text-primary)]">
{text}
{isJson ? <JsonHighlighted json={text} /> : text}
</pre>
)}
</div>
@@ -0,0 +1,420 @@
import { useCallback, useMemo, useState } from 'react';
import {
AlertTriangle,
ArrowDownToLine,
Check,
ChevronRight,
FileCode2,
FileMinus2,
FilePlus2,
GitBranch,
Loader2,
RotateCcw,
Trash2,
} from 'lucide-react';
import type {
ProjectGitFileReference,
ProjectGitRunChangedFile,
ProjectGitRunChangeSummary,
} from '@shared/domain/project';
/* ── Helpers ───────────────────────────────────────────────── */
function fileBaseName(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash >= 0 ? normalized.slice(lastSlash + 1) : normalized;
}
function fileDir(path: string): string {
const normalized = path.replace(/\\/g, '/');
const lastSlash = normalized.lastIndexOf('/');
return lastSlash > 0 ? normalized.slice(0, lastSlash + 1) : '';
}
function kindLabel(kind: ProjectGitRunChangedFile['kind']): string {
switch (kind) {
case 'added': return 'added';
case 'modified': return 'modified';
case 'deleted': return 'deleted';
case 'renamed': return 'renamed';
case 'copied': return 'copied';
case 'type-changed': return 'type changed';
case 'unmerged': return 'conflict';
case 'untracked': return 'new';
case 'cleaned': return 'cleaned';
}
}
function kindIcon(kind: ProjectGitRunChangedFile['kind']) {
switch (kind) {
case 'added':
case 'untracked':
case 'copied':
return <FilePlus2 className="size-3 shrink-0 text-[var(--color-status-success)]" />;
case 'deleted':
case 'cleaned':
return <FileMinus2 className="size-3 shrink-0 text-[var(--color-status-error)]" />;
default:
return <FileCode2 className="size-3 shrink-0 text-[var(--color-accent-sky)]" />;
}
}
function originBadge(origin: ProjectGitRunChangedFile['origin']) {
if (origin === 'pre-existing') {
return (
<span className="rounded px-1 py-px text-[7px] font-semibold uppercase tracking-wider bg-[var(--color-status-warning)]/10 text-[var(--color-status-warning)]">
pre-existing
</span>
);
}
return null;
}
/* ── Mini diff-stats bar ───────────────────────────────────── */
function DiffStatsBar({ additions, deletions }: { additions: number; deletions: number }) {
const total = additions + deletions;
if (total === 0) return null;
const blocks = 5;
const addBlocks = Math.max(additions > 0 ? 1 : 0, Math.round((additions / total) * blocks));
const delBlocks = blocks - addBlocks;
return (
<span className="inline-flex gap-px" aria-label={`${additions} additions, ${deletions} deletions`}>
{Array.from({ length: addBlocks }, (_, i) => (
<span key={`a${i}`} className="size-1.5 rounded-[1px] bg-[var(--color-status-success)]" />
))}
{Array.from({ length: delBlocks }, (_, i) => (
<span key={`d${i}`} className="size-1.5 rounded-[1px] bg-[var(--color-status-error)]" />
))}
</span>
);
}
/* ── Diff line renderer ────────────────────────────────────── */
function DiffLine({ line }: { line: string }) {
let textClass = 'text-[var(--color-text-secondary)]';
let bgClass = '';
if (line.startsWith('+') && !line.startsWith('+++')) {
textClass = 'text-[var(--color-status-success)]';
bgClass = 'bg-[var(--color-status-success)]/[0.06]';
} else if (line.startsWith('-') && !line.startsWith('---')) {
textClass = 'text-[var(--color-status-error)]';
bgClass = 'bg-[var(--color-status-error)]/[0.06]';
} else if (line.startsWith('@@')) {
textClass = 'text-[var(--color-accent-sky)]';
} else if (line.startsWith('diff ') || line.startsWith('index ') || line.startsWith('---') || line.startsWith('+++')) {
textClass = 'text-[var(--color-text-muted)]';
}
return <div className={`${textClass} ${bgClass} -mx-3 px-3`}>{line || '\u00A0'}</div>;
}
/* ── Single file row ───────────────────────────────────────── */
function ChangedFileRow({
file,
isSelected,
onToggleSelect,
canSelect,
}: {
file: ProjectGitRunChangedFile;
isSelected: boolean;
onToggleSelect: () => void;
canSelect: boolean;
}) {
const [diffExpanded, setDiffExpanded] = useState(false);
const hasPreview = !!file.preview?.diff || !!file.preview?.newFileContents;
const dir = fileDir(file.path);
const base = fileBaseName(file.path);
return (
<div className="border-b border-[var(--color-border-subtle)] last:border-b-0">
<div className="flex items-center gap-1 px-2 py-[5px] text-[10px]">
{/* Select checkbox */}
{canSelect && (
<button
className={`flex size-3.5 shrink-0 items-center justify-center rounded border transition-colors duration-100 ${
isSelected
? 'border-[var(--color-accent)] bg-[var(--color-accent)] text-white'
: 'border-[var(--color-border)] bg-transparent hover:border-[var(--color-text-muted)]'
}`}
onClick={onToggleSelect}
type="button"
aria-label={`${isSelected ? 'Deselect' : 'Select'} ${file.path}`}
aria-pressed={isSelected}
>
{isSelected && <Check className="size-2" />}
</button>
)}
{/* Expand diff button */}
<button
className="flex min-w-0 flex-1 items-center gap-1.5 text-left transition-colors duration-150 hover:bg-[var(--color-surface-3)]/40 disabled:cursor-default"
disabled={!hasPreview}
onClick={hasPreview ? () => setDiffExpanded(!diffExpanded) : undefined}
type="button"
aria-expanded={hasPreview ? diffExpanded : undefined}
>
{hasPreview ? (
<ChevronRight
className={`size-2.5 shrink-0 text-[var(--color-text-muted)] transition-transform duration-150 ${diffExpanded ? 'rotate-90' : ''}`}
/>
) : (
<span className="w-2.5 shrink-0" />
)}
{kindIcon(file.kind)}
<span className="min-w-0 flex-1 truncate font-mono">
{dir && <span className="text-[var(--color-text-muted)]">{dir}</span>}
<span className="text-[var(--color-text-primary)]">{base}</span>
</span>
<span className="shrink-0 rounded px-1 py-px text-[8px] font-semibold uppercase tracking-wider bg-[var(--color-surface-3)] text-[var(--color-text-muted)]">
{kindLabel(file.kind)}
</span>
{originBadge(file.origin)}
{(file.additions > 0 || file.deletions > 0) && (
<span className="flex items-center gap-1.5 shrink-0 font-mono">
{file.additions > 0 && <span className="text-[var(--color-status-success)]">+{file.additions}</span>}
{file.deletions > 0 && <span className="text-[var(--color-status-error)]">{file.deletions}</span>}
<DiffStatsBar additions={file.additions} deletions={file.deletions} />
</span>
)}
</button>
</div>
{/* Diff preview */}
{diffExpanded && file.preview && (
<div className="border-t border-[var(--color-border-subtle)]">
<pre className="max-h-64 overflow-auto bg-[var(--color-surface-0)] px-3 py-1.5 font-mono text-[10px] leading-relaxed">
{file.preview.diff
? file.preview.diff.split('\n').map((line, i) => <DiffLine key={i} line={line} />)
: file.preview.newFileContents
? file.preview.newFileContents.split('\n').map((line, i) => (
<div key={i} className="text-[var(--color-text-secondary)]">{line || '\u00A0'}</div>
))
: file.preview.isBinary
? <div className="text-[var(--color-text-muted)] italic">Binary file</div>
: null}
</pre>
</div>
)}
</div>
);
}
/* ── Main export ───────────────────────────────────────────── */
interface RunChangeSummaryCardProps {
summary: ProjectGitRunChangeSummary;
sessionId: string;
runId: string;
onDiscard: (sessionId: string, runId: string, files?: ProjectGitFileReference[]) => Promise<unknown>;
onOpenCommitComposer?: () => void;
}
export function RunChangeSummaryCard({
summary,
sessionId,
runId,
onDiscard,
onOpenCommitComposer,
}: RunChangeSummaryCardProps) {
const [expanded, setExpanded] = useState(false);
const [selectedPaths, setSelectedPaths] = useState<Set<string>>(new Set());
const [discarding, setDiscarding] = useState(false);
const [confirmDiscard, setConfirmDiscard] = useState<'bulk' | 'selected' | undefined>();
const revertableFiles = useMemo(
() => summary.files.filter((file) => file.canRevert),
[summary.files],
);
const hasRevertable = revertableFiles.length > 0;
const toggleSelect = useCallback((path: string) => {
setSelectedPaths((prev) => {
const next = new Set(prev);
if (next.has(path)) {
next.delete(path);
} else {
next.add(path);
}
return next;
});
}, []);
const handleDiscard = useCallback(async (mode: 'bulk' | 'selected') => {
setDiscarding(true);
try {
if (mode === 'selected') {
const files: ProjectGitFileReference[] = summary.files
.filter((f) => selectedPaths.has(f.path))
.map((f) => ({ path: f.path, previousPath: f.previousPath }));
await onDiscard(sessionId, runId, files);
setSelectedPaths(new Set());
} else {
await onDiscard(sessionId, runId);
}
} finally {
setDiscarding(false);
setConfirmDiscard(undefined);
}
}, [onDiscard, sessionId, runId, selectedPaths, summary.files]);
const selectedRevertableCount = useMemo(
() => revertableFiles.filter((f) => selectedPaths.has(f.path)).length,
[revertableFiles, selectedPaths],
);
return (
<div className="overflow-hidden rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-1)]/80">
{/* Header */}
<button
className="flex w-full items-center gap-2 px-3 py-2 text-left transition-colors duration-150 hover:bg-[var(--color-surface-2)]/40"
onClick={() => setExpanded(!expanded)}
type="button"
aria-expanded={expanded}
aria-label={`${summary.fileCount} files changed by this run`}
>
<ChevronRight
className={`size-3 shrink-0 text-[var(--color-text-muted)] transition-transform duration-150 ${expanded ? 'rotate-90' : ''}`}
/>
<GitBranch className="size-3 shrink-0 text-[var(--color-accent-sky)]" />
<span className="text-[11px] font-medium text-[var(--color-text-secondary)]">
{summary.fileCount} {summary.fileCount === 1 ? 'file' : 'files'} changed
</span>
{(summary.additions > 0 || summary.deletions > 0) && (
<span className="flex items-center gap-1.5 font-mono text-[10px]">
{summary.additions > 0 && (
<span className="text-[var(--color-status-success)]">+{summary.additions}</span>
)}
{summary.deletions > 0 && (
<span className="text-[var(--color-status-error)]">{summary.deletions}</span>
)}
<DiffStatsBar additions={summary.additions} deletions={summary.deletions} />
</span>
)}
{summary.branchChanged && (
<span className="ml-auto flex items-center gap-1 text-[9px] text-[var(--color-status-warning)]">
<AlertTriangle className="size-2.5" />
branch changed
</span>
)}
</button>
{/* Expanded content */}
{expanded && (
<div className="border-t border-[var(--color-border-subtle)]">
{/* Branch info */}
{summary.branchChanged && summary.branchAtStart && summary.branchAtEnd && (
<div className="flex items-center gap-1.5 border-b border-[var(--color-border-subtle)] px-3 py-1.5 text-[9px] text-[var(--color-text-muted)]">
<GitBranch className="size-2.5" />
<span className="font-mono text-[var(--color-text-secondary)]">{summary.branchAtStart}</span>
<span></span>
<span className="font-mono text-[var(--color-text-secondary)]">{summary.branchAtEnd}</span>
</div>
)}
{/* File list */}
<div>
{summary.files.map((file) => (
<ChangedFileRow
canSelect={hasRevertable && file.canRevert}
file={file}
isSelected={selectedPaths.has(file.path)}
key={file.path}
onToggleSelect={() => toggleSelect(file.path)}
/>
))}
</div>
{/* Actions */}
{(hasRevertable || onOpenCommitComposer) && (
<div className="flex items-center gap-2 border-t border-[var(--color-border-subtle)] px-3 py-2">
{/* Commit button */}
{onOpenCommitComposer && (
<button
className="flex items-center gap-1.5 rounded-md bg-[var(--color-accent)] px-2.5 py-1 text-[10px] font-medium text-white transition-colors duration-150 hover:bg-[var(--color-accent-hover)]"
onClick={onOpenCommitComposer}
type="button"
>
<ArrowDownToLine className="size-3" />
Commit changes
</button>
)}
<div className="flex-1" />
{/* Discard actions */}
{hasRevertable && !confirmDiscard && (
<>
{selectedRevertableCount > 0 && (
<button
className="flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-[var(--color-status-error)] transition-colors duration-150 hover:bg-[var(--color-status-error)]/10"
disabled={discarding}
onClick={() => setConfirmDiscard('selected')}
type="button"
>
<Trash2 className="size-3" />
Discard {selectedRevertableCount} selected
</button>
)}
<button
className="flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium text-[var(--color-text-muted)] transition-colors duration-150 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-status-error)]"
disabled={discarding}
onClick={() => setConfirmDiscard('bulk')}
type="button"
>
<RotateCcw className="size-3" />
Discard all
</button>
</>
)}
{/* Confirmation */}
{confirmDiscard && (
<div className="flex items-center gap-1.5 rounded-md border border-[var(--color-status-error)]/30 bg-[var(--color-status-error)]/5 px-2.5 py-1" role="alert">
<AlertTriangle className="size-3 text-[var(--color-status-error)]" />
<span className="text-[10px] text-[var(--color-status-error)]">
{confirmDiscard === 'bulk'
? `Revert all ${revertableFiles.length} files to pre-run state?`
: `Revert ${selectedRevertableCount} selected files?`}
</span>
<button
className="flex items-center gap-1 rounded px-1.5 py-0.5 text-[9px] font-semibold text-[var(--color-status-error)] transition-colors duration-100 hover:bg-[var(--color-status-error)]/15"
disabled={discarding}
onClick={() => void handleDiscard(confirmDiscard)}
type="button"
>
{discarding ? <Loader2 className="size-2.5 animate-spin" /> : <Check className="size-2.5" />}
Yes
</button>
<button
className="rounded px-1.5 py-0.5 text-[9px] font-semibold text-[var(--color-text-muted)] transition-colors duration-100 hover:bg-[var(--color-surface-3)]"
onClick={() => setConfirmDiscard(undefined)}
type="button"
>
Cancel
</button>
</div>
)}
</div>
)}
</div>
)}
</div>
);
}
@@ -0,0 +1,120 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Brain, ChevronDown, ChevronRight } from 'lucide-react';
import type { ChatMessageRecord } from '@shared/domain/session';
interface ThinkingProcessProps {
messages: ChatMessageRecord[];
isActive: boolean;
turnStartedAt?: string;
}
export function ThinkingProcess({ messages, isActive, turnStartedAt }: ThinkingProcessProps) {
const [expanded, setExpanded] = useState(false);
const wasActiveRef = useRef(isActive);
// Auto-expand when the turn is active and thinking messages appear.
// Auto-collapse once the turn finishes.
useEffect(() => {
if (isActive && messages.length > 0) {
setExpanded(true);
} else if (wasActiveRef.current && !isActive) {
setExpanded(false);
}
wasActiveRef.current = isActive;
}, [isActive, messages.length]);
const toggle = useCallback(() => setExpanded((prev) => !prev), []);
const elapsed = useMemo(() => {
if (!turnStartedAt || messages.length === 0) return undefined;
const start = new Date(turnStartedAt).getTime();
const lastMessage = messages[messages.length - 1];
const end = isActive ? Date.now() : new Date(lastMessage.createdAt).getTime();
const seconds = Math.max(0, Math.round((end - start) / 1000));
if (seconds < 2) return undefined;
return seconds >= 60 ? `${Math.floor(seconds / 60)}m ${seconds % 60}s` : `${seconds}s`;
}, [turnStartedAt, messages, isActive]);
if (messages.length === 0) {
return null;
}
const stepCount = messages.length;
const summaryParts: string[] = [];
if (elapsed) summaryParts.push(`${elapsed}`);
summaryParts.push(`${stepCount} ${stepCount === 1 ? 'step' : 'steps'}`);
return (
<div className="thinking-process-enter mb-2 overflow-hidden rounded-lg border border-[var(--color-border)]/50 bg-[var(--color-surface-1)]/60">
<button
type="button"
onClick={toggle}
onKeyDown={(e) => { if (e.key === ' ') { e.preventDefault(); toggle(); } }}
aria-expanded={expanded}
className="flex w-full items-center gap-2 px-3 py-2 text-left text-[12px] text-[var(--color-text-muted)] transition-colors hover:bg-[var(--color-surface-2)]/50"
>
<Brain className="size-3.5 shrink-0 text-[var(--color-accent-purple)]" />
{isActive ? (
<span className="flex items-center gap-1.5">
<span className="text-[var(--color-text-secondary)]">Thinking</span>
<ThinkingPulse />
</span>
) : (
<span className="text-[var(--color-text-secondary)]">
Thought for {summaryParts.join(' · ')}
</span>
)}
<span className="ml-auto shrink-0">
{expanded
? <ChevronDown className="size-3 text-[var(--color-text-muted)]" />
: <ChevronRight className="size-3 text-[var(--color-text-muted)]" />}
</span>
</button>
{expanded && (
<div className="border-t border-[var(--color-border)]/30 px-3 py-2">
<div className="space-y-1.5">
{messages.map((message) => (
<ThinkingStep key={message.id} message={message} />
))}
</div>
</div>
)}
</div>
);
}
function ThinkingStep({ message }: { message: ChatMessageRecord }) {
const preview = useMemo(() => truncatePreview(message.content, 180), [message.content]);
return (
<div className="flex gap-2 text-[12px] leading-relaxed">
<span className="mt-0.5 shrink-0 text-[var(--color-text-muted)]"></span>
<div className="min-w-0">
{message.authorName && (
<span className="mr-1.5 font-medium text-[var(--color-text-secondary)]">
{message.authorName}
</span>
)}
<span className="text-[var(--color-text-muted)]">{preview}</span>
</div>
</div>
);
}
function ThinkingPulse() {
return (
<span className="inline-flex items-center gap-0.5">
<span className="thinking-dot size-1 rounded-full bg-[var(--color-accent-purple)]" />
<span className="thinking-dot size-1 rounded-full bg-[var(--color-accent-purple)]" />
<span className="thinking-dot size-1 rounded-full bg-[var(--color-accent-purple)]" />
</span>
);
}
function truncatePreview(text: string, maxLength: number): string {
const firstLine = text.split('\n')[0] ?? '';
const cleaned = firstLine.trim();
if (cleaned.length <= maxLength) return cleaned;
return `${cleaned.slice(0, maxLength)}`;
}
@@ -0,0 +1,209 @@
import { useState, useCallback } from 'react';
import { Check, Copy, ChevronRight, KeyRound, Sparkles } from 'lucide-react';
import { detectedPlatform, type DetectedPlatform } from '@renderer/lib/platform';
import {
installInstructions,
authCommand,
type PlatformInstallInfo,
type InstallMethod,
} from '@renderer/lib/cliInstallInstructions';
interface CliInstallGuideProps {
onRefresh: () => void;
isRefreshing: boolean;
}
function PlatformTab({
info,
active,
onClick,
}: {
info: PlatformInstallInfo;
active: boolean;
onClick: () => void;
}) {
return (
<button
type="button"
onClick={onClick}
className={`relative rounded-md px-3 py-1.5 text-[11px] font-semibold tracking-wide transition-all duration-200 ${
active
? 'bg-[var(--color-surface-3)] text-[var(--color-text-primary)] shadow-sm'
: 'text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]'
}`}
aria-pressed={active}
>
{info.displayName}
</button>
);
}
function CommandBlock({
method,
index,
}: {
method: InstallMethod;
index: number;
}) {
const [copied, setCopied] = useState(false);
const handleCopy = useCallback(() => {
void navigator.clipboard.writeText(method.command);
setCopied(true);
setTimeout(() => setCopied(false), 1800);
}, [method.command]);
return (
<div
className="group/cmd space-y-1.5"
style={{ animationDelay: `${index * 60}ms` }}
>
{/* Method label row */}
<div className="flex items-center gap-2">
<span className="text-[11px] font-medium text-[var(--color-text-secondary)]">
{method.label}
</span>
{method.recommended && (
<span className="inline-flex items-center gap-1 rounded-full bg-[var(--color-accent)]/10 px-2 py-0.5 text-[9px] font-bold uppercase tracking-widest text-[var(--color-accent)]">
<Sparkles className="size-2.5" />
Recommended
</span>
)}
</div>
{/* Command block */}
<div className="relative flex items-center overflow-hidden rounded-lg border border-[var(--color-border-subtle)] bg-[var(--color-surface-1)]">
<div className="flex min-w-0 flex-1 items-center gap-2 px-3 py-2">
<ChevronRight className="size-3 shrink-0 text-[var(--color-accent)]/60" />
<code className="min-w-0 select-all truncate font-mono text-[12px] leading-relaxed text-[var(--color-text-primary)]">
{method.command}
</code>
</div>
<button
type="button"
onClick={handleCopy}
className="flex shrink-0 items-center gap-1 border-l border-[var(--color-border-subtle)] px-2.5 py-2 text-[var(--color-text-muted)] transition-colors duration-150 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
title="Copy command"
aria-label={`Copy command: ${method.command}`}
>
{copied ? (
<Check className="size-3 text-[var(--color-status-success)]" />
) : (
<Copy className="size-3" />
)}
</button>
</div>
</div>
);
}
export function CliInstallGuide({ onRefresh, isRefreshing }: CliInstallGuideProps) {
const [activePlatform, setActivePlatform] = useState<DetectedPlatform>(detectedPlatform);
const activeInfo = installInstructions.find((i) => i.platform === activePlatform)!;
return (
<div className="space-y-4">
{/* Step 1: Install */}
<div className="space-y-3">
<div className="flex items-center gap-2">
<span className="flex size-5 items-center justify-center rounded-full bg-[var(--color-accent)]/15 text-[10px] font-bold text-[var(--color-accent)]">
1
</span>
<span className="text-[12px] font-semibold text-[var(--color-text-primary)]">
Install the Copilot CLI
</span>
</div>
{/* Platform tabs */}
<div className="flex items-center gap-1 rounded-lg bg-[var(--color-surface-2)] p-1">
{installInstructions.map((info) => (
<PlatformTab
key={info.platform}
active={activePlatform === info.platform}
info={info}
onClick={() => setActivePlatform(info.platform)}
/>
))}
</div>
{/* Commands for active platform */}
<div className="space-y-3">
{activeInfo.methods.map((method, i) => (
<CommandBlock key={method.label} index={i} method={method} />
))}
</div>
</div>
{/* Step 2: Authenticate */}
<div className="space-y-2">
<div className="flex items-center gap-2">
<span className="flex size-5 items-center justify-center rounded-full bg-[var(--color-accent)]/15 text-[10px] font-bold text-[var(--color-accent)]">
2
</span>
<span className="text-[12px] font-semibold text-[var(--color-text-primary)]">
Sign in to GitHub
</span>
</div>
<AuthCommandBlock />
</div>
{/* Step 3: Refresh */}
<div className="space-y-2">
<div className="flex items-center gap-2">
<span className="flex size-5 items-center justify-center rounded-full bg-[var(--color-accent)]/15 text-[10px] font-bold text-[var(--color-accent)]">
3
</span>
<span className="text-[12px] font-semibold text-[var(--color-text-primary)]">
Refresh connection
</span>
</div>
<button
type="button"
onClick={onRefresh}
disabled={isRefreshing}
className="flex w-full items-center justify-center gap-2 rounded-lg border border-[var(--color-accent)]/30 bg-[var(--color-accent)]/8 px-3 py-2 text-[12px] font-medium text-[var(--color-accent)] transition-all duration-200 hover:bg-[var(--color-accent)]/15 disabled:opacity-50"
>
{isRefreshing ? 'Checking…' : 'Check connection'}
</button>
</div>
</div>
);
}
function AuthCommandBlock() {
const [copied, setCopied] = useState(false);
const handleCopy = useCallback(() => {
void navigator.clipboard.writeText(authCommand);
setCopied(true);
setTimeout(() => setCopied(false), 1800);
}, []);
return (
<div className="relative flex items-center overflow-hidden rounded-lg border border-[var(--color-border-subtle)] bg-[var(--color-surface-1)]">
<div className="flex min-w-0 flex-1 items-center gap-2 px-3 py-2">
<KeyRound className="size-3 shrink-0 text-[var(--color-accent)]/60" />
<code className="min-w-0 select-all truncate font-mono text-[12px] leading-relaxed text-[var(--color-text-primary)]">
{authCommand}
</code>
</div>
<button
type="button"
onClick={handleCopy}
className="flex shrink-0 items-center gap-1 border-l border-[var(--color-border-subtle)] px-2.5 py-2 text-[var(--color-text-muted)] transition-colors duration-150 hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-secondary)]"
title="Copy command"
aria-label="Copy authentication command"
>
{copied ? (
<Check className="size-3 text-[var(--color-status-success)]" />
) : (
<Copy className="size-3" />
)}
</button>
</div>
);
}
+108
View File
@@ -0,0 +1,108 @@
import { useState } from 'react';
import { ArrowDownToLine, Download, RefreshCw, Sparkles, X } from 'lucide-react';
import type { UpdateStatus } from '@shared/contracts/ipc';
export interface UpdateBannerProps {
status: UpdateStatus;
onViewDetails: () => void;
onInstallUpdate: () => void;
}
export function UpdateBanner({ status, onViewDetails, onInstallUpdate }: UpdateBannerProps) {
const [dismissed, setDismissed] = useState(false);
const isActionable =
status.state === 'available' ||
status.state === 'downloading' ||
status.state === 'downloaded';
// Nothing to show
if (!isActionable) return null;
// Allow dismissal for transient states, never for downloaded
if (dismissed && status.state !== 'downloaded') return null;
const version = status.version ? `v${status.version}` : '';
if (status.state === 'downloaded') {
return (
<div className="update-banner-enter px-3 pb-2" role="alert">
<button
className="group relative flex w-full items-center gap-2.5 overflow-hidden rounded-xl border border-[var(--color-status-success)]/25 bg-[var(--color-status-success)]/[0.07] px-3 py-2.5 text-left transition-all duration-200 hover:border-[var(--color-status-success)]/40 hover:bg-[var(--color-status-success)]/[0.12]"
onClick={onInstallUpdate}
type="button"
>
{/* Subtle glow effect */}
<div className="pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100" style={{ background: 'radial-gradient(ellipse at center, rgba(52, 211, 153, 0.08), transparent 70%)' }} />
<span className="flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--color-status-success)]/15">
<Sparkles className="size-3.5 text-[var(--color-status-success)]" />
</span>
<div className="min-w-0 flex-1">
<span className="block text-[12px] font-semibold text-[var(--color-status-success)]">
Update ready {version}
</span>
<span className="block text-[10px] text-[var(--color-text-muted)]">
Restart to apply
</span>
</div>
<span className="shrink-0 rounded-lg bg-[var(--color-status-success)]/15 px-2 py-1 text-[10px] font-semibold text-[var(--color-status-success)] transition-all duration-200 group-hover:bg-[var(--color-status-success)]/25">
<RefreshCw className="inline-block size-3 mr-1 align-[-2px]" />
Restart
</span>
</button>
</div>
);
}
// available / downloading
const isDownloading = status.state === 'downloading';
const percent = status.downloadProgress ? Math.round(status.downloadProgress.percent) : 0;
return (
<div className="update-banner-enter px-3 pb-2" role="status">
<div className="relative overflow-hidden rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-2)]/60">
<button
className="group flex w-full items-center gap-2.5 px-3 py-2 text-left transition-all duration-200 hover:bg-[var(--color-surface-2)]"
onClick={onViewDetails}
type="button"
>
<span className="flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--color-accent)]/10">
{isDownloading
? <Download className="size-3 text-[var(--color-accent)] animate-pulse" />
: <ArrowDownToLine className="size-3 text-[var(--color-accent)]" />}
</span>
<div className="min-w-0 flex-1">
<span className="block text-[11px] font-medium text-[var(--color-text-primary)]">
{isDownloading
? `Downloading ${version}${percent > 0 ? ` · ${percent}%` : '…'}`
: `Update available ${version}`}
</span>
</div>
<button
className="flex size-5 shrink-0 items-center justify-center rounded text-[var(--color-text-muted)] opacity-0 transition hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)] group-hover:opacity-100"
onClick={(e) => {
e.stopPropagation();
setDismissed(true);
}}
type="button"
aria-label="Dismiss"
>
<X className="size-3" />
</button>
</button>
{/* Download progress bar */}
{isDownloading && percent > 0 && (
<div className="h-[2px] w-full bg-[var(--color-surface-3)]">
<div
className="h-full bg-[var(--color-accent)] transition-[width] duration-500 ease-out"
style={{ width: `${percent}%` }}
/>
</div>
)}
</div>
</div>
);
}
+2
View File
@@ -7,3 +7,5 @@ export { TextInput } from './TextInput';
export { TextareaInput } from './TextareaInput';
export { SelectInput } from './SelectInput';
export { InfoCallout } from './InfoCallout';
export type { UpdateBannerProps } from './UpdateBanner';
export { UpdateBanner } from './UpdateBanner';
@@ -0,0 +1,48 @@
import type { DetectedPlatform } from './platform';
export interface InstallMethod {
label: string;
command: string;
recommended?: boolean;
}
export interface PlatformInstallInfo {
platform: DetectedPlatform;
displayName: string;
methods: InstallMethod[];
}
export const installInstructions: PlatformInstallInfo[] = [
{
platform: 'macos',
displayName: 'macOS',
methods: [
{ label: 'Homebrew', command: 'brew install copilot-cli', recommended: true },
{ label: 'Install script', command: 'curl -fsSL https://gh.io/copilot-install | bash' },
{ label: 'npm', command: 'npm install -g @github/copilot' },
],
},
{
platform: 'windows',
displayName: 'Windows',
methods: [
{ label: 'WinGet', command: 'winget install GitHub.Copilot', recommended: true },
{ label: 'npm', command: 'npm install -g @github/copilot' },
],
},
{
platform: 'linux',
displayName: 'Linux',
methods: [
{ label: 'Install script', command: 'curl -fsSL https://gh.io/copilot-install | bash', recommended: true },
{ label: 'Homebrew', command: 'brew install copilot-cli' },
{ label: 'npm', command: 'npm install -g @github/copilot' },
],
},
];
export const authCommand = 'copilot auth login';
export function getInstallInfoForPlatform(platform: DetectedPlatform): PlatformInstallInfo {
return installInstructions.find((i) => i.platform === platform)!;
}
+2 -1
View File
@@ -1,4 +1,4 @@
const isMac = navigator.platform.startsWith('Mac');
import { isMac } from '@renderer/lib/platform';
/** Platform-aware modifier key label. */
export const MOD = isMac ? '⌘' : 'Ctrl';
@@ -18,6 +18,7 @@ export const shortcuts: ShortcutDefinition[] = [
// ── Navigation ──
{ id: 'command-palette', label: 'Command palette', keys: `${MOD}+K`, category: 'Navigation' },
{ id: 'search-sessions', label: 'Search sessions', keys: `${MOD}+Shift+F`, category: 'Navigation' },
{ id: 'bookmarks', label: 'View bookmarks', keys: `${MOD}+Shift+B`, category: 'Navigation' },
{ id: 'settings', label: 'Open settings', keys: `${MOD}+,`, category: 'Navigation' },
{ id: 'toggle-terminal', label: 'Toggle terminal', keys: 'Ctrl+`', category: 'Navigation' },
{ id: 'shortcut-help', label: 'Keyboard shortcuts', keys: `${MOD}+/`, category: 'Navigation' },
+10 -7
View File
@@ -5,12 +5,15 @@ export type AssistantMessagePhase = 'default' | 'thinking' | 'final';
export function getAssistantMessagePhase(
session: SessionRecord,
message: ChatMessageRecord,
index: number,
): AssistantMessagePhase {
if (message.role !== 'assistant') {
return 'default';
}
if (message.messageKind === 'thinking') {
return 'default';
}
if (message.pending) {
return 'thinking';
}
@@ -19,17 +22,17 @@ export function getAssistantMessagePhase(
return 'default';
}
const lastCompletedAssistantIndex = findLastCompletedAssistantIndex(session.messages);
return index === lastCompletedAssistantIndex ? 'final' : 'default';
const lastId = findLastCompletedAssistantId(session.messages);
return message.id === lastId ? 'final' : 'default';
}
function findLastCompletedAssistantIndex(messages: ChatMessageRecord[]): number {
function findLastCompletedAssistantId(messages: ChatMessageRecord[]): string | undefined {
for (let index = messages.length - 1; index >= 0; index -= 1) {
const message = messages[index];
if (message.role === 'assistant' && !message.pending) {
return index;
if (message.role === 'assistant' && !message.pending && message.messageKind !== 'thinking') {
return message.id;
}
}
return -1;
return undefined;
}
+8
View File
@@ -0,0 +1,8 @@
export type DetectedPlatform = 'macos' | 'windows' | 'linux';
export const isMac = navigator.platform.startsWith('Mac');
export const isWindows = navigator.platform.startsWith('Win');
export const isLinux = !isMac && !isWindows;
export const detectedPlatform: DetectedPlatform =
isMac ? 'macos' : isWindows ? 'windows' : 'linux';
+32 -1
View File
@@ -1,6 +1,6 @@
import type { PatternDefinition } from '@shared/domain/pattern';
import type { SessionEventRecord } from '@shared/domain/event';
import type { QuotaSnapshot } from '@shared/contracts/sidecar';
import type { QuotaSnapshot, WorkflowDiagnosticKind, WorkflowDiagnosticSeverity } from '@shared/contracts/sidecar';
export interface AgentActivityState {
agentId: string;
@@ -260,6 +260,22 @@ function formatHookType(hookType: string | undefined): string {
return hookTypeLabels[hookType] ?? hookType;
}
const diagnosticLabels: Record<WorkflowDiagnosticKind, string> = {
'workflow-warning': 'Workflow warning',
'workflow-error': 'Workflow error',
'executor-failed': 'Executor failed',
'subworkflow-warning': 'Subworkflow warning',
'subworkflow-error': 'Subworkflow error',
};
function formatDiagnosticLabel(
kind: WorkflowDiagnosticKind | undefined,
severity: WorkflowDiagnosticSeverity | undefined,
): string {
if (kind) return diagnosticLabels[kind] ?? kind;
return severity === 'error' ? 'Workflow error' : 'Workflow warning';
}
function formatTurnEventEntry(event: SessionEventRecord): TurnEventEntry | undefined {
switch (event.kind) {
case 'subagent':
@@ -300,6 +316,21 @@ function formatTurnEventEntry(event: SessionEventRecord): TurnEventEntry | undef
phase: event.compactionPhase,
success: event.compactionSuccess,
};
case 'workflow-diagnostic': {
const label = formatDiagnosticLabel(event.diagnosticKind, event.diagnosticSeverity);
const detailParts: string[] = [];
if (event.executorId) detailParts.push(event.executorId);
if (event.subworkflowId) detailParts.push(event.subworkflowId);
if (event.exceptionType) detailParts.push(event.exceptionType);
if (event.diagnosticMessage) detailParts.push(event.diagnosticMessage);
return {
kind: event.kind,
occurredAt: event.occurredAt,
label,
detail: detailParts.length > 0 ? detailParts.join(' · ') : undefined,
success: event.diagnosticSeverity === 'error' ? false : undefined,
};
}
default:
return undefined;
}
+26
View File
@@ -41,6 +41,8 @@ function applySessionEvent(session: SessionRecord, event: SessionEventRecord): S
return applyMessageDeltaEvent(session, event);
case 'message-complete':
return applyMessageCompleteEvent(session, event);
case 'message-reclassified':
return applyMessageReclassifiedEvent(session, event);
case 'run-updated':
return applyRunUpdatedEvent(session, event);
default:
@@ -172,6 +174,30 @@ function applyMessageCompleteEvent(session: SessionRecord, event: SessionEventRe
};
}
function applyMessageReclassifiedEvent(session: SessionRecord, event: SessionEventRecord): SessionRecord {
if (!event.messageId || !event.messageKind) {
return session;
}
const messageIndex = session.messages.findIndex((message) => message.id === event.messageId);
if (messageIndex < 0) {
return session;
}
const existing = session.messages[messageIndex];
if (existing.messageKind === event.messageKind) {
return session;
}
const nextMessages = session.messages.slice();
nextMessages[messageIndex] = { ...existing, messageKind: event.messageKind };
return {
...session,
messages: nextMessages,
updatedAt: event.occurredAt,
};
}
function applyRunUpdatedEvent(session: SessionRecord, event: SessionEventRecord): SessionRecord {
if (!event.run) {
return session;
+29 -1
View File
@@ -626,6 +626,32 @@ body {
animation: banner-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
/* ── Update banner slide-up ──────────────────────────────────── */
@keyframes update-banner-in {
from {
opacity: 0;
transform: translateY(100%);
}
}
.update-banner-enter {
animation: update-banner-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
/* ── Thinking process section ────────────────────────────────── */
@keyframes thinking-process-in {
from {
opacity: 0;
transform: translateY(-4px);
}
}
.thinking-process-enter {
animation: thinking-process-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* ── Respect reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
@@ -637,7 +663,9 @@ body {
.message-enter,
.msg-actions-enter,
.session-item-enter,
.banner-slide-enter {
.banner-slide-enter,
.update-banner-enter,
.thinking-process-enter {
animation: none;
}
}
+14
View File
@@ -6,6 +6,8 @@ export const ipcChannels = {
removeProject: 'workspace:remove-project',
resolveWorkspaceDiscoveredTooling: 'workspace:resolve-discovered-tooling',
refreshProjectGitContext: 'projects:refresh-git-context',
getProjectGitDetails: 'projects:get-git-details',
getProjectGitFilePreview: 'projects:get-git-file-preview',
rescanProjectConfigs: 'project:rescan-configs',
rescanProjectCustomization: 'project:rescan-customization',
resolveProjectDiscoveredTooling: 'project:resolve-discovered-tooling',
@@ -17,6 +19,7 @@ export const ipcChannels = {
setTerminalHeight: 'settings:set-terminal-height',
setNotificationsEnabled: 'settings:set-notifications-enabled',
setMinimizeToTray: 'settings:set-minimize-to-tray',
setGitAutoRefreshEnabled: 'settings:set-git-auto-refresh-enabled',
checkForUpdates: 'app:check-for-updates',
installUpdate: 'app:install-update',
saveMcpServer: 'tooling:mcp:save',
@@ -49,8 +52,19 @@ export const ipcChannels = {
dismissSessionPlanReview: 'sessions:dismiss-plan-review',
dismissSessionMcpAuth: 'sessions:dismiss-mcp-auth',
startSessionMcpAuth: 'sessions:start-mcp-auth',
discardSessionRunGitChanges: 'sessions:discard-run-git-changes',
suggestProjectGitCommitMessage: 'sessions:suggest-git-commit-message',
querySessions: 'sessions:query',
updateSessionModelConfig: 'sessions:update-model-config',
stageProjectGitFiles: 'git:stage-files',
unstageProjectGitFiles: 'git:unstage-files',
commitProjectGitChanges: 'git:commit',
pushProjectGit: 'git:push',
fetchProjectGit: 'git:fetch',
pullProjectGit: 'git:pull',
createProjectGitBranch: 'git:create-branch',
switchProjectGitBranch: 'git:switch-branch',
deleteProjectGitBranch: 'git:delete-branch',
selectProject: 'selection:project',
selectPattern: 'selection:pattern',
selectSession: 'selection:session',
+76 -2
View File
@@ -1,7 +1,14 @@
import type { ApprovalDecision } from '@shared/domain/approval';
import type { SidecarCapabilities, InteractionMode, MessageMode, QuotaSnapshot } from '@shared/contracts/sidecar';
import type { PatternDefinition, ReasoningEffort } from '@shared/domain/pattern';
import type { ProjectRecord } from '@shared/domain/project';
import type {
ProjectGitBranchSummary,
ProjectGitCommitMessageSuggestion,
ProjectGitDetails,
ProjectGitDiffPreview,
ProjectGitFileReference,
ProjectRecord,
} from '@shared/domain/project';
import type { QuerySessionsInput, SessionQueryResult } from '@shared/domain/sessionLibrary';
import type { SessionEventRecord } from '@shared/domain/event';
import type { TerminalExitInfo, TerminalSnapshot } from '@shared/domain/terminal';
@@ -175,7 +182,60 @@ export interface SetTerminalHeightInput {
height?: number;
}
export type UpdateStatusState = 'idle' | 'checking' | 'available' | 'downloading' | 'downloaded' | 'error';
export interface ProjectGitInput {
projectId: string;
}
export interface ProjectGitDetailsInput extends ProjectGitInput {
commitLimit?: number;
}
export interface ProjectGitFilePreviewInput extends ProjectGitInput {
file: ProjectGitFileReference;
}
export interface ProjectGitFileSelectionInput extends ProjectGitInput {
files: ProjectGitFileReference[];
}
export interface DiscardSessionRunGitChangesInput {
sessionId: string;
runId: string;
files?: ProjectGitFileReference[];
}
export interface SuggestProjectGitCommitMessageInput {
sessionId: string;
runId?: string;
conventionalType?: ProjectGitCommitMessageSuggestion['type'];
}
export interface CommitProjectGitChangesInput extends ProjectGitInput {
message: string;
files?: ProjectGitFileReference[];
push?: boolean;
}
export interface PullProjectGitInput extends ProjectGitInput {
rebase?: boolean;
}
export interface CreateProjectGitBranchInput extends ProjectGitInput {
name: string;
startPoint?: string;
checkout?: boolean;
}
export interface SwitchProjectGitBranchInput extends ProjectGitInput {
name: string;
}
export interface DeleteProjectGitBranchInput extends ProjectGitInput {
name: string;
force?: boolean;
}
export type UpdateStatusState = 'idle' | 'checking' | 'up-to-date' | 'available' | 'downloading' | 'downloaded' | 'error';
export interface UpdateDownloadProgress {
bytesPerSecond: number;
@@ -241,6 +301,7 @@ export interface ElectronApi {
setTerminalHeight(input: SetTerminalHeightInput): Promise<WorkspaceState>;
setNotificationsEnabled(enabled: boolean): Promise<WorkspaceState>;
setMinimizeToTray(enabled: boolean): Promise<WorkspaceState>;
setGitAutoRefreshEnabled(enabled: boolean): Promise<WorkspaceState>;
checkForUpdates(): Promise<UpdateStatus>;
installUpdate(): Promise<void>;
describeTerminal(): Promise<TerminalSnapshot | undefined>;
@@ -252,6 +313,19 @@ export interface ElectronApi {
openAppDataFolder(): Promise<void>;
resetLocalWorkspace(): Promise<WorkspaceState>;
getQuota(): Promise<Record<string, QuotaSnapshot>>;
getProjectGitDetails(input: ProjectGitDetailsInput): Promise<ProjectGitDetails>;
getProjectGitFilePreview(input: ProjectGitFilePreviewInput): Promise<ProjectGitDiffPreview | undefined>;
discardSessionRunGitChanges(input: DiscardSessionRunGitChangesInput): Promise<WorkspaceState>;
stageProjectGitFiles(input: ProjectGitFileSelectionInput): Promise<WorkspaceState>;
unstageProjectGitFiles(input: ProjectGitFileSelectionInput): Promise<WorkspaceState>;
suggestProjectGitCommitMessage(input: SuggestProjectGitCommitMessageInput): Promise<ProjectGitCommitMessageSuggestion>;
commitProjectGitChanges(input: CommitProjectGitChangesInput): Promise<WorkspaceState>;
pushProjectGit(input: ProjectGitInput): Promise<WorkspaceState>;
fetchProjectGit(input: ProjectGitInput): Promise<WorkspaceState>;
pullProjectGit(input: PullProjectGitInput): Promise<WorkspaceState>;
createProjectGitBranch(input: CreateProjectGitBranchInput): Promise<WorkspaceState>;
switchProjectGitBranch(input: SwitchProjectGitBranchInput): Promise<WorkspaceState>;
deleteProjectGitBranch(input: DeleteProjectGitBranchInput): Promise<WorkspaceState>;
onTerminalData(listener: (data: string) => void): () => void;
onTerminalExit(listener: (info: TerminalExitInfo) => void): () => void;
onWorkspaceUpdated(listener: (workspace: WorkspaceState) => void): () => void;
+71
View File
@@ -72,6 +72,12 @@ export interface ValidatePatternCommand {
export type InteractionMode = 'interactive' | 'plan';
export type MessageMode = 'enqueue' | 'immediate';
export interface WorkflowCheckpointResume {
workflowSessionId: string;
checkpointId: string;
storePath: string;
}
export interface RunTurnCommand {
type: 'run-turn';
requestId: string;
@@ -85,6 +91,7 @@ export interface RunTurnCommand {
messages: ChatMessageRecord[];
attachments?: ChatMessageAttachment[];
tooling?: RunTurnToolingConfig;
resumeFromCheckpoint?: WorkflowCheckpointResume;
}
export interface CancelTurnCommand {
@@ -239,6 +246,14 @@ export interface TurnCompleteEvent {
cancelled?: boolean;
}
export interface MessageReclassifiedEvent {
type: 'message-reclassified';
requestId: string;
sessionId: string;
messageId: string;
newKind: 'thinking';
}
export type AgentActivityType = 'thinking' | 'tool-calling' | 'handoff' | 'completed';
export interface ToolCallFileChangePreview {
@@ -297,6 +312,25 @@ export interface SkillInvokedEvent {
description?: string;
}
export interface AssistantIntentEvent {
type: 'assistant-intent';
requestId: string;
sessionId: string;
agentId?: string;
agentName?: string;
intent: string;
}
export interface ReasoningDeltaEvent {
type: 'reasoning-delta';
requestId: string;
sessionId: string;
agentId?: string;
agentName?: string;
reasoningId: string;
contentDelta: string;
}
export interface HookLifecycleEvent {
type: 'hook-lifecycle';
requestId: string;
@@ -357,6 +391,38 @@ export interface PendingMessagesModifiedEvent {
agentName?: string;
}
export interface WorkflowCheckpointSavedEvent {
type: 'workflow-checkpoint-saved';
requestId: string;
sessionId: string;
workflowSessionId: string;
checkpointId: string;
storePath: string;
stepNumber: number;
}
export type WorkflowDiagnosticSeverity = 'warning' | 'error';
export type WorkflowDiagnosticKind =
| 'workflow-warning'
| 'workflow-error'
| 'executor-failed'
| 'subworkflow-warning'
| 'subworkflow-error';
export interface WorkflowDiagnosticEvent {
type: 'workflow-diagnostic';
requestId: string;
sessionId: string;
severity: WorkflowDiagnosticSeverity;
diagnosticKind: WorkflowDiagnosticKind;
message: string;
agentId?: string;
agentName?: string;
executorId?: string;
subworkflowId?: string;
exceptionType?: string;
}
export interface CopilotSessionInfo {
copilotSessionId: string;
managedByAryx: boolean;
@@ -526,13 +592,18 @@ export type SidecarEvent =
| PatternValidationEvent
| TurnDeltaEvent
| TurnCompleteEvent
| MessageReclassifiedEvent
| AgentActivityEvent
| SubagentEvent
| SkillInvokedEvent
| AssistantIntentEvent
| ReasoningDeltaEvent
| HookLifecycleEvent
| SessionUsageEvent
| SessionCompactionEvent
| PendingMessagesModifiedEvent
| WorkflowCheckpointSavedEvent
| WorkflowDiagnosticEvent
| ApprovalRequestedEvent
| UserInputRequestedEvent
| McpOauthRequiredEvent
+19 -2
View File
@@ -1,6 +1,12 @@
import type { SessionRunRecord } from '@shared/domain/runTimeline';
import type { ChatMessageKind } from '@shared/domain/session';
import type { QuotaSnapshot, ToolCallFileChangePreview } from '@shared/contracts/sidecar';
import type {
QuotaSnapshot,
ToolCallFileChangePreview,
WorkflowDiagnosticKind,
WorkflowDiagnosticSeverity,
} from '@shared/contracts/sidecar';
export type SessionActivityType = 'thinking' | 'tool-calling' | 'handoff' | 'completed';
@@ -8,6 +14,7 @@ export type SessionEventKind =
| 'status'
| 'message-delta'
| 'message-complete'
| 'message-reclassified'
| 'agent-activity'
| 'run-updated'
| 'error'
@@ -17,7 +24,8 @@ export type SessionEventKind =
| 'session-usage'
| 'session-compaction'
| 'pending-messages-modified'
| 'assistant-usage';
| 'assistant-usage'
| 'workflow-diagnostic';
export type SubagentEventKind = 'started' | 'completed' | 'failed' | 'selected' | 'deselected';
@@ -27,6 +35,7 @@ export interface SessionEventRecord {
occurredAt: string;
status?: 'idle' | 'running' | 'error';
messageId?: string;
messageKind?: ChatMessageKind;
authorName?: string;
contentDelta?: string;
content?: string;
@@ -83,4 +92,12 @@ export interface SessionEventRecord {
usageDuration?: number;
usageTotalNanoAiu?: number;
usageQuotaSnapshots?: Record<string, QuotaSnapshot>;
// Workflow diagnostic fields
diagnosticSeverity?: WorkflowDiagnosticSeverity;
diagnosticKind?: WorkflowDiagnosticKind;
diagnosticMessage?: string;
executorId?: string;
subworkflowId?: string;
exceptionType?: string;
}
+116
View File
@@ -18,6 +18,122 @@ export interface ProjectGitCommitSummary {
committedAt: string;
}
export interface ProjectGitCommitLogEntry extends ProjectGitCommitSummary {
authorName: string;
refNames?: string;
}
export type ProjectGitWorkingTreeFileStatus =
| 'added'
| 'modified'
| 'deleted'
| 'renamed'
| 'copied'
| 'type-changed'
| 'unmerged'
| 'untracked';
export interface ProjectGitWorkingTreeFile {
path: string;
previousPath?: string;
stagedStatus?: ProjectGitWorkingTreeFileStatus;
unstagedStatus?: ProjectGitWorkingTreeFileStatus;
isConflicted?: boolean;
}
export interface ProjectGitFileReference {
path: string;
previousPath?: string;
}
export interface ProjectGitDiffPreview extends ProjectGitFileReference {
diff?: string;
newFileContents?: string;
isBinary?: boolean;
}
export interface ProjectGitBaselineFile extends ProjectGitFileReference {
combinedDiff?: string;
untrackedContentBase64?: string;
isBinary?: boolean;
}
export interface ProjectGitWorkingTreeSnapshot {
scannedAt: string;
repoRoot: string;
branch?: string;
changedFileCount: number;
changes: ProjectGitChangeSummary;
files: ProjectGitWorkingTreeFile[];
}
export type ProjectGitRunChangeOrigin = 'run-created' | 'pre-existing';
export type ProjectGitRunChangeKind = ProjectGitWorkingTreeFileStatus | 'cleaned';
export interface ProjectGitRunChangeCounts {
added: number;
modified: number;
deleted: number;
renamed: number;
copied: number;
typeChanged: number;
unmerged: number;
untracked: number;
cleaned: number;
}
export interface ProjectGitRunChangedFile extends ProjectGitFileReference {
kind: ProjectGitRunChangeKind;
origin: ProjectGitRunChangeOrigin;
stagedStatus?: ProjectGitWorkingTreeFileStatus;
unstagedStatus?: ProjectGitWorkingTreeFileStatus;
isConflicted?: boolean;
additions: number;
deletions: number;
canRevert: boolean;
preview?: ProjectGitDiffPreview;
}
export interface ProjectGitRunChangeSummary {
generatedAt: string;
branchAtStart?: string;
branchAtEnd?: string;
branchChanged?: boolean;
fileCount: number;
additions: number;
deletions: number;
counts: ProjectGitRunChangeCounts;
files: ProjectGitRunChangedFile[];
}
export interface ProjectGitBranchSummary {
name: string;
isCurrent: boolean;
upstream?: string;
}
export interface ProjectGitDetails {
scannedAt: string;
context: ProjectGitContext;
workingTree?: ProjectGitWorkingTreeSnapshot;
branches: ProjectGitBranchSummary[];
recentCommits: ProjectGitCommitLogEntry[];
}
export type ProjectGitConventionalCommitType =
| 'feat'
| 'fix'
| 'refactor'
| 'docs'
| 'test'
| 'chore';
export interface ProjectGitCommitMessageSuggestion {
type: ProjectGitConventionalCommitType;
subject: string;
message: string;
}
export interface ProjectGitContext {
status: ProjectGitContextStatus;
scannedAt: string;
+273 -1
View File
@@ -5,7 +5,18 @@ import type {
} from '@shared/domain/approval';
import type { ToolCallFileChangePreview } from '@shared/contracts/sidecar';
import type { PatternDefinition, ReasoningEffort } from '@shared/domain/pattern';
import type { ProjectRecord } from '@shared/domain/project';
import type {
ProjectGitBaselineFile,
ProjectGitChangeSummary,
ProjectGitDiffPreview,
ProjectGitRunChangeCounts,
ProjectGitRunChangedFile,
ProjectGitRunChangeSummary,
ProjectGitWorkingTreeFile,
ProjectGitWorkingTreeFileStatus,
ProjectGitWorkingTreeSnapshot,
ProjectRecord,
} from '@shared/domain/project';
import { createId } from '@shared/utils/ids';
export type SessionRunStatus = 'running' | 'completed' | 'cancelled' | 'error';
@@ -60,6 +71,7 @@ export interface SessionRunRecord {
requestId: string;
projectId: string;
projectPath: string;
workingDirectory?: string;
workspaceKind: SessionRunWorkspaceKind;
patternId: string;
patternName: string;
@@ -70,15 +82,21 @@ export interface SessionRunRecord {
status: SessionRunStatus;
agents: RunTimelineAgentRecord[];
events: RunTimelineEventRecord[];
preRunGitSnapshot?: ProjectGitWorkingTreeSnapshot;
preRunGitBaselineFiles?: ProjectGitBaselineFile[];
postRunGitSummary?: ProjectGitRunChangeSummary;
}
export interface CreateSessionRunRecordInput {
requestId: string;
project: Pick<ProjectRecord, 'id' | 'path'>;
workingDirectory?: string;
workspaceKind: SessionRunWorkspaceKind;
pattern: Pick<PatternDefinition, 'id' | 'name' | 'mode' | 'agents'>;
triggerMessageId: string;
startedAt: string;
preRunGitSnapshot?: ProjectGitWorkingTreeSnapshot;
preRunGitBaselineFiles?: ProjectGitBaselineFile[];
}
export interface AppendRunActivityEventInput {
@@ -122,6 +140,228 @@ function normalizeOptionalPreviewText(value: string | undefined): string | undef
return value?.trim() ? value : undefined;
}
function normalizeNonNegativeInteger(value: number | undefined): number {
if (typeof value !== 'number' || !Number.isFinite(value)) {
return 0;
}
const normalized = Math.round(value);
return normalized >= 0 ? normalized : 0;
}
function normalizeWorkingTreeFileStatus(
value: ProjectGitWorkingTreeFileStatus | undefined,
): ProjectGitWorkingTreeFileStatus | undefined {
switch (value) {
case 'added':
case 'modified':
case 'deleted':
case 'renamed':
case 'copied':
case 'type-changed':
case 'unmerged':
case 'untracked':
return value;
default:
return undefined;
}
}
function normalizeWorkingTreeChangeSummary(
summary: Partial<ProjectGitChangeSummary> | undefined,
): ProjectGitChangeSummary {
return {
staged: normalizeNonNegativeInteger(summary?.staged),
unstaged: normalizeNonNegativeInteger(summary?.unstaged),
untracked: normalizeNonNegativeInteger(summary?.untracked),
conflicted: normalizeNonNegativeInteger(summary?.conflicted),
};
}
function normalizeWorkingTreeFile(
file: ProjectGitWorkingTreeFile,
): ProjectGitWorkingTreeFile | undefined {
const path = normalizeOptionalString(file.path);
if (!path) {
return undefined;
}
return {
path,
previousPath: normalizeOptionalString(file.previousPath),
stagedStatus: normalizeWorkingTreeFileStatus(file.stagedStatus),
unstagedStatus: normalizeWorkingTreeFileStatus(file.unstagedStatus),
...(file.isConflicted ? { isConflicted: true } : {}),
};
}
function normalizeWorkingTreeSnapshot(
snapshot: ProjectGitWorkingTreeSnapshot | undefined,
): ProjectGitWorkingTreeSnapshot | undefined {
if (!snapshot) {
return undefined;
}
const scannedAt = normalizeOptionalString(snapshot.scannedAt);
const repoRoot = normalizeOptionalString(snapshot.repoRoot);
if (!scannedAt || !repoRoot) {
return undefined;
}
const files = (snapshot.files ?? []).flatMap((file) => {
const normalized = normalizeWorkingTreeFile(file);
return normalized ? [normalized] : [];
});
return {
scannedAt,
repoRoot,
branch: normalizeOptionalString(snapshot.branch),
changedFileCount: normalizeNonNegativeInteger(snapshot.changedFileCount),
changes: normalizeWorkingTreeChangeSummary(snapshot.changes),
files,
};
}
function normalizeGitDiffPreview(
preview: ProjectGitDiffPreview,
): ProjectGitDiffPreview | undefined {
const path = normalizeOptionalString(preview.path);
if (!path) {
return undefined;
}
return {
path,
previousPath: normalizeOptionalString(preview.previousPath),
diff: normalizeOptionalPreviewText(preview.diff),
newFileContents: normalizeOptionalPreviewText(preview.newFileContents),
...(preview.isBinary ? { isBinary: true } : {}),
};
}
function normalizeGitBaselineFile(
file: ProjectGitBaselineFile,
): ProjectGitBaselineFile | undefined {
const path = normalizeOptionalString(file.path);
if (!path) {
return undefined;
}
return {
path,
previousPath: normalizeOptionalString(file.previousPath),
combinedDiff: normalizeOptionalPreviewText(file.combinedDiff),
untrackedContentBase64: normalizeOptionalString(file.untrackedContentBase64),
...(file.isBinary ? { isBinary: true } : {}),
};
}
function normalizeGitBaselineFiles(
files: readonly ProjectGitBaselineFile[] | undefined,
): ProjectGitBaselineFile[] | undefined {
if (!files || files.length === 0) {
return undefined;
}
const normalized = files.flatMap((file) => {
const nextFile = normalizeGitBaselineFile(file);
return nextFile ? [nextFile] : [];
});
return normalized.length > 0 ? normalized : undefined;
}
function normalizeGitRunChangeKind(
value: ProjectGitRunChangedFile['kind'] | undefined,
): ProjectGitRunChangedFile['kind'] | undefined {
switch (value) {
case 'cleaned':
return value;
case 'added':
case 'modified':
case 'deleted':
case 'renamed':
case 'copied':
case 'type-changed':
case 'unmerged':
case 'untracked':
return value;
default:
return undefined;
}
}
function normalizeGitRunChangeCounts(
counts: Partial<ProjectGitRunChangeCounts> | undefined,
): ProjectGitRunChangeCounts {
return {
added: normalizeNonNegativeInteger(counts?.added),
modified: normalizeNonNegativeInteger(counts?.modified),
deleted: normalizeNonNegativeInteger(counts?.deleted),
renamed: normalizeNonNegativeInteger(counts?.renamed),
copied: normalizeNonNegativeInteger(counts?.copied),
typeChanged: normalizeNonNegativeInteger(counts?.typeChanged),
unmerged: normalizeNonNegativeInteger(counts?.unmerged),
untracked: normalizeNonNegativeInteger(counts?.untracked),
cleaned: normalizeNonNegativeInteger(counts?.cleaned),
};
}
function normalizeGitRunChangedFile(
file: ProjectGitRunChangedFile,
): ProjectGitRunChangedFile | undefined {
const path = normalizeOptionalString(file.path);
const kind = normalizeGitRunChangeKind(file.kind);
if (!path || !kind) {
return undefined;
}
return {
path,
previousPath: normalizeOptionalString(file.previousPath),
kind,
origin: file.origin === 'pre-existing' ? 'pre-existing' : 'run-created',
stagedStatus: normalizeWorkingTreeFileStatus(file.stagedStatus),
unstagedStatus: normalizeWorkingTreeFileStatus(file.unstagedStatus),
...(file.isConflicted ? { isConflicted: true } : {}),
additions: normalizeNonNegativeInteger(file.additions),
deletions: normalizeNonNegativeInteger(file.deletions),
canRevert: file.canRevert === true,
preview: file.preview ? normalizeGitDiffPreview(file.preview) : undefined,
};
}
function normalizeGitRunChangeSummary(
summary: ProjectGitRunChangeSummary | undefined,
): ProjectGitRunChangeSummary | undefined {
if (!summary) {
return undefined;
}
const generatedAt = normalizeOptionalString(summary.generatedAt);
if (!generatedAt) {
return undefined;
}
const files = (summary.files ?? []).flatMap((file) => {
const normalized = normalizeGitRunChangedFile(file);
return normalized ? [normalized] : [];
});
return {
generatedAt,
branchAtStart: normalizeOptionalString(summary.branchAtStart),
branchAtEnd: normalizeOptionalString(summary.branchAtEnd),
...(summary.branchChanged ? { branchChanged: true } : {}),
fileCount: normalizeNonNegativeInteger(summary.fileCount),
additions: normalizeNonNegativeInteger(summary.additions),
deletions: normalizeNonNegativeInteger(summary.deletions),
counts: normalizeGitRunChangeCounts(summary.counts),
files,
};
}
function normalizeToolCallFileChange(
change: ToolCallFileChangePreview,
): ToolCallFileChangePreview | undefined {
@@ -365,6 +605,7 @@ export function createSessionRunRecord(input: CreateSessionRunRecordInput): Sess
requestId: input.requestId,
projectId: input.project.id,
projectPath: input.project.path,
workingDirectory: normalizeOptionalString(input.workingDirectory),
workspaceKind: input.workspaceKind,
patternId: input.pattern.id,
patternName: input.pattern.name,
@@ -373,6 +614,9 @@ export function createSessionRunRecord(input: CreateSessionRunRecordInput): Sess
startedAt: input.startedAt,
status: 'running',
completedAt: undefined,
preRunGitSnapshot: normalizeWorkingTreeSnapshot(input.preRunGitSnapshot),
preRunGitBaselineFiles: normalizeGitBaselineFiles(input.preRunGitBaselineFiles),
postRunGitSummary: undefined,
agents: input.pattern.agents
.map((agent): RunTimelineAgentRecord => ({
agentId: agent.id,
@@ -408,6 +652,7 @@ export function normalizeSessionRunRecords(
const requestId = normalizeOptionalString(run.requestId);
const projectId = normalizeOptionalString(run.projectId);
const projectPath = normalizeOptionalString(run.projectPath);
const workingDirectory = normalizeOptionalString(run.workingDirectory);
const patternId = normalizeOptionalString(run.patternId);
const patternName = normalizeOptionalString(run.patternName);
const triggerMessageId = normalizeOptionalString(run.triggerMessageId);
@@ -422,6 +667,7 @@ export function normalizeSessionRunRecords(
requestId,
projectId,
projectPath,
workingDirectory,
workspaceKind: run.workspaceKind === 'scratchpad' ? 'scratchpad' : 'project',
patternId,
patternName,
@@ -430,6 +676,9 @@ export function normalizeSessionRunRecords(
startedAt,
completedAt: normalizeOptionalString(run.completedAt),
status: run.status === 'error' ? 'error' : run.status === 'running' ? 'running' : run.status === 'cancelled' ? 'cancelled' : 'completed',
preRunGitSnapshot: normalizeWorkingTreeSnapshot(run.preRunGitSnapshot),
preRunGitBaselineFiles: normalizeGitBaselineFiles(run.preRunGitBaselineFiles),
postRunGitSummary: normalizeGitRunChangeSummary(run.postRunGitSummary),
agents: run.agents.flatMap((agent) => {
const normalized = normalizeRunTimelineAgent(agent);
return normalized ? [normalized] : [];
@@ -677,3 +926,26 @@ export function failSessionRunRecord(
error,
});
}
export function setSessionRunGitSummary(
run: SessionRunRecord,
summary: ProjectGitRunChangeSummary | undefined,
): SessionRunRecord {
const normalizedSummary = normalizeGitRunChangeSummary(summary);
if (normalizedSummary === undefined && run.postRunGitSummary === undefined) {
return run;
}
if (
normalizedSummary !== undefined
&& run.postRunGitSummary !== undefined
&& JSON.stringify(normalizedSummary) === JSON.stringify(run.postRunGitSummary)
) {
return run;
}
return {
...run,
postRunGitSummary: normalizedSummary,
};
}
+2
View File
@@ -18,6 +18,7 @@ import type { ChatMessageAttachment } from '@shared/domain/attachment';
import type { InteractionMode } from '@shared/contracts/sidecar';
export type ChatRole = 'system' | 'user' | 'assistant';
export type ChatMessageKind = 'response' | 'thinking';
export type SessionStatus = 'idle' | 'running' | 'error';
export type SessionTitleSource = 'auto' | 'manual';
export type SessionBranchOriginAction = 'branch' | 'regenerate' | 'edit-and-resend';
@@ -33,6 +34,7 @@ export interface ChatMessageRecord {
authorName: string;
content: string;
createdAt: string;
messageKind?: ChatMessageKind;
isPinned?: boolean;
pending?: boolean;
attachments?: ChatMessageAttachment[];
+38
View File
@@ -395,6 +395,44 @@ export function editAndResendSessionRecord(
};
}
// ── Pinned messages ──
export interface PinnedMessageHit {
session: SessionRecord;
projectName: string;
message: ChatMessageRecord;
/** Truncated preview of the message content. */
snippet: string;
}
function extractMessageSnippet(content: string, maxLength = 120): string {
const collapsed = content.replace(/\n+/g, ' ').trim();
if (collapsed.length <= maxLength) return collapsed;
return collapsed.slice(0, maxLength) + '…';
}
export function listPinnedMessages(workspace: WorkspaceState): PinnedMessageHit[] {
const projectNames = new Map<string, string>(
workspace.projects.map((p) => [p.id, isScratchpadProject(p) ? 'Scratchpad' : p.name]),
);
return workspace.sessions
.filter((session) => !session.isArchived)
.flatMap((session) =>
session.messages
.filter((message) => message.isPinned && message.content)
.map((message) => ({
session,
projectName: projectNames.get(session.projectId) ?? 'Unknown',
message,
snippet: extractMessageSnippet(message.content),
})),
)
.sort((a, b) => b.message.createdAt.localeCompare(a.message.createdAt));
}
// ── Session query ──
export function querySessions(workspace: WorkspaceState, input: QuerySessionsInput): SessionQueryResult[] {
const projectsById = new Map<string, ProjectRecord>(workspace.projects.map((project) => [project.id, project]));
const patternsById = new Map<string, PatternDefinition>(workspace.patterns.map((pattern) => [pattern.id, pattern]));
+30
View File
@@ -66,6 +66,7 @@ export interface WorkspaceSettings {
terminalHeight?: number;
notificationsEnabled?: boolean;
minimizeToTray?: boolean;
gitAutoRefreshEnabled?: boolean;
}
export interface SessionToolingSelection {
@@ -209,6 +210,7 @@ export function normalizeWorkspaceSettings(settings?: Partial<WorkspaceSettings>
...(terminalHeight !== undefined ? { terminalHeight } : {}),
...(settings?.notificationsEnabled !== undefined ? { notificationsEnabled: settings.notificationsEnabled } : {}),
...(settings?.minimizeToTray !== undefined ? { minimizeToTray: settings.minimizeToTray } : {}),
...(settings?.gitAutoRefreshEnabled !== undefined ? { gitAutoRefreshEnabled: settings.gitAutoRefreshEnabled } : {}),
};
}
@@ -395,6 +397,34 @@ function resolveApprovalToolGroupKey(
return { id: 'other', label: 'Other', kind: 'mixed' };
}
/**
* Count how many tools are effectively auto-approved across all groups.
*
* This must use per-group counting (not unique-tool-ID deduplication) to stay
* consistent with the total-item formula used in InlineApprovalPill, which
* counts each group occurrence independently. Without this, shared tool names
* across MCP servers produce a numerator smaller than the denominator even when
* everything is approved.
*/
export function countApprovedToolsInGroups(
groups: ReadonlyArray<ApprovalToolGroup>,
approved: ReadonlySet<string>,
): number {
let count = 0;
for (const group of groups) {
if (group.serverApprovalKey && approved.has(group.serverApprovalKey)) {
// Server-level approval covers all tools. Servers with 0 tools still
// count as 1 (matching the totalItemCount formula).
count += Math.max(group.tools.length, 1);
} else {
for (const tool of group.tools) {
if (approved.has(tool.id)) count += 1;
}
}
}
return count;
}
export function validateMcpServerDefinition(server: McpServerDefinition): string | undefined {
if (!server.name.trim()) {
return 'MCP server name is required.';
+370
View File
@@ -0,0 +1,370 @@
import { describe, expect, mock, test } from 'bun:test';
import type { RunTurnCommand } from '@shared/contracts/sidecar';
import type { PatternDefinition } from '@shared/domain/pattern';
import type {
ProjectGitRunChangeSummary,
ProjectGitWorkingTreeSnapshot,
ProjectRecord,
} from '@shared/domain/project';
import { SCRATCHPAD_PROJECT_ID } from '@shared/domain/project';
import type { SessionRecord } from '@shared/domain/session';
import { createWorkspaceSeed, type WorkspaceState } from '@shared/domain/workspace';
const TIMESTAMP = '2026-03-31T00:00:00.000Z';
mock.module('electron', () => {
const electronMock = {
app: {
isPackaged: false,
getAppPath: () => 'C:\\workspace\\personal\\repositories\\aryx',
getPath: () => 'C:\\workspace\\personal\\repositories\\aryx\\tests\\fixtures',
},
dialog: {
showOpenDialog: async () => ({ canceled: true, filePaths: [] }),
},
shell: {
openPath: async () => '',
},
};
return {
...electronMock,
default: electronMock,
};
});
mock.module('keytar', () => ({
default: {
getPassword: async () => null,
setPassword: async () => undefined,
deletePassword: async () => false,
},
}));
const { AryxAppService } = await import('@main/AryxAppService');
function createProject(overrides?: Partial<ProjectRecord>): ProjectRecord {
return {
id: 'project-alpha',
name: 'alpha',
path: 'C:\\workspace\\alpha',
addedAt: TIMESTAMP,
git: {
status: 'ready',
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
isDirty: false,
changedFileCount: 0,
changes: {
staged: 0,
unstaged: 0,
untracked: 0,
conflicted: 0,
},
},
...overrides,
};
}
function createSession(projectId: string, patternId: string, overrides?: Partial<SessionRecord>): SessionRecord {
return {
id: 'session-alpha',
projectId,
patternId,
title: 'Alpha session',
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
status: 'idle',
messages: [],
runs: [],
...overrides,
};
}
function createFixture(overrides?: {
project?: Partial<ProjectRecord>;
session?: Partial<SessionRecord>;
}): {
workspace: WorkspaceState;
pattern: PatternDefinition;
project: ProjectRecord;
session: SessionRecord;
} {
const workspace = createWorkspaceSeed();
const pattern = workspace.patterns.find((candidate) => candidate.mode === 'single');
if (!pattern) {
throw new Error('Expected the workspace seed to include a single-agent pattern.');
}
const project = createProject(overrides?.project);
const session = createSession(project.id, pattern.id, overrides?.session);
workspace.projects = [project];
workspace.sessions = [session];
workspace.selectedProjectId = project.id;
workspace.selectedPatternId = pattern.id;
workspace.selectedSessionId = session.id;
return { workspace, pattern, project, session };
}
function createSnapshot(): ProjectGitWorkingTreeSnapshot {
return {
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
changedFileCount: 2,
changes: {
staged: 1,
unstaged: 1,
untracked: 0,
conflicted: 0,
},
files: [
{
path: 'src\\auth.ts',
stagedStatus: 'modified',
},
{
path: 'tests\\auth.test.ts',
unstagedStatus: 'modified',
},
],
};
}
function createRunSummary(): ProjectGitRunChangeSummary {
return {
generatedAt: TIMESTAMP,
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 4,
deletions: 1,
counts: {
added: 1,
modified: 0,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 0,
},
files: [
{
path: 'src\\generated.ts',
kind: 'added',
origin: 'run-created',
additions: 4,
deletions: 1,
canRevert: true,
preview: {
path: 'src\\generated.ts',
diff: '@@ -0,0 +1,4 @@\n+export const generated = true;\n',
},
},
],
};
}
function createService(
workspace: WorkspaceState,
pattern: PatternDefinition,
options?: {
snapshot?: ProjectGitWorkingTreeSnapshot;
runSummary?: ProjectGitRunChangeSummary;
onCaptureSnapshot?: (projectPath: string, scannedAt: string) => void;
onComputeRunSummary?: (projectPath: string) => void;
onScheduleRefresh?: (projectId?: string) => void;
runTurn?: (command: RunTurnCommand) => Promise<[]>;
},
): InstanceType<typeof AryxAppService> {
const service = new AryxAppService();
const internals = service as unknown as Record<string, unknown>;
internals.loadWorkspace = async () => {
internals.workspace = workspace;
return workspace;
};
internals.persistAndBroadcast = async (nextWorkspace: WorkspaceState) => nextWorkspace;
internals.buildEffectivePattern = async () => pattern;
internals.awaitFinalResponseApproval = async () => undefined;
internals.finalizeTurn = () => undefined;
internals.emitSessionEvent = () => undefined;
internals.pruneUnavailableApprovalTools = async () => false;
internals.pruneUnavailableSessionToolingSelections = () => false;
internals.scheduleProjectGitRefresh = (projectId?: string) => {
options?.onScheduleRefresh?.(projectId);
};
(
service as unknown as {
sidecar: {
runTurn: (command: RunTurnCommand) => Promise<[]>;
resolveApproval: () => Promise<void>;
resolveUserInput: () => Promise<void>;
};
gitService: {
captureWorkingTreeSnapshot: (
projectPath: string,
scannedAt: string,
) => Promise<ProjectGitWorkingTreeSnapshot | undefined>;
captureWorkingTreeBaseline: () => Promise<[]>;
computeRunChangeSummary: (projectPath: string) => Promise<ProjectGitRunChangeSummary | undefined>;
};
}
).sidecar = {
runTurn: async (command) => options?.runTurn ? options.runTurn(command) : [],
resolveApproval: async () => undefined,
resolveUserInput: async () => undefined,
};
(
service as unknown as {
gitService: {
captureWorkingTreeSnapshot: (
projectPath: string,
scannedAt: string,
) => Promise<ProjectGitWorkingTreeSnapshot | undefined>;
captureWorkingTreeBaseline: () => Promise<[]>;
computeRunChangeSummary: (projectPath: string) => Promise<ProjectGitRunChangeSummary | undefined>;
};
}
).gitService = {
captureWorkingTreeSnapshot: async (projectPath, scannedAt) => {
options?.onCaptureSnapshot?.(projectPath, scannedAt);
return options?.snapshot;
},
captureWorkingTreeBaseline: async () => [],
computeRunChangeSummary: async (projectPath) => {
options?.onComputeRunSummary?.(projectPath);
return options?.runSummary;
},
};
return service;
}
describe('AryxAppService git refresh integration', () => {
test('sendSessionMessage stores a pre-run git snapshot on the created run', async () => {
const { workspace, pattern, session } = createFixture();
const snapshot = createSnapshot();
const capturedProjectPaths: string[] = [];
const service = createService(workspace, pattern, {
snapshot,
onCaptureSnapshot: (projectPath) => {
capturedProjectPaths.push(projectPath);
},
});
await service.sendSessionMessage(session.id, 'Implement auth hardening.');
expect(capturedProjectPaths).toEqual(['C:\\workspace\\alpha']);
expect(workspace.sessions[0]?.runs[0]?.preRunGitSnapshot).toEqual(snapshot);
});
test('sendSessionMessage schedules a git refresh after a successful project turn', async () => {
const { workspace, pattern, project, session } = createFixture();
const scheduledProjectIds: Array<string | undefined> = [];
const service = createService(workspace, pattern, {
snapshot: createSnapshot(),
onScheduleRefresh: (projectId) => {
scheduledProjectIds.push(projectId);
},
});
await service.sendSessionMessage(session.id, 'Implement auth hardening.');
expect(scheduledProjectIds).toEqual([project.id]);
});
test('sendSessionMessage stores a post-run git summary on the completed run', async () => {
const { workspace, pattern, session, project } = createFixture();
const computedProjectPaths: string[] = [];
const service = createService(workspace, pattern, {
snapshot: createSnapshot(),
runSummary: createRunSummary(),
onComputeRunSummary: (projectPath) => {
computedProjectPaths.push(projectPath);
},
});
await service.sendSessionMessage(session.id, 'Implement auth hardening.');
expect(computedProjectPaths).toEqual([project.path]);
expect(workspace.sessions[0]?.runs[0]?.postRunGitSummary).toEqual(createRunSummary());
});
test('sendSessionMessage schedules a git refresh after a failed project turn', async () => {
const { workspace, pattern, project, session } = createFixture();
const scheduledProjectIds: Array<string | undefined> = [];
const service = createService(workspace, pattern, {
snapshot: createSnapshot(),
onScheduleRefresh: (projectId) => {
scheduledProjectIds.push(projectId);
},
runTurn: async () => {
throw new Error('boom');
},
});
await service.sendSessionMessage(session.id, 'Implement auth hardening.');
expect(scheduledProjectIds).toEqual([project.id]);
expect(session.status).toBe('error');
expect(session.lastError).toBe('boom');
expect(session.runs[0]?.status).toBe('error');
});
test('scratchpad turns skip git snapshot capture and refresh scheduling', async () => {
const { workspace, pattern, session } = createFixture({
project: {
id: SCRATCHPAD_PROJECT_ID,
name: 'Scratchpad',
path: 'C:\\workspace\\scratchpad',
git: undefined,
},
session: {
projectId: SCRATCHPAD_PROJECT_ID,
},
});
let didCaptureSnapshot = false;
const scheduledProjectIds: Array<string | undefined> = [];
const service = createService(workspace, pattern, {
snapshot: createSnapshot(),
onCaptureSnapshot: () => {
didCaptureSnapshot = true;
},
onScheduleRefresh: (projectId) => {
scheduledProjectIds.push(projectId);
},
});
await service.sendSessionMessage(session.id, 'Draft a quick note.');
expect(didCaptureSnapshot).toBe(false);
expect(scheduledProjectIds).toEqual([]);
expect(workspace.sessions[0]?.runs[0]?.preRunGitSnapshot).toBeUndefined();
});
test('setGitAutoRefreshEnabled persists the setting and returns updated workspace', async () => {
const { workspace, pattern } = createFixture();
const service = createService(workspace, pattern);
expect(service.isGitAutoRefreshEnabled()).toBe(true);
const result = await service.setGitAutoRefreshEnabled(false);
expect(result.settings.gitAutoRefreshEnabled).toBe(false);
expect(service.isGitAutoRefreshEnabled()).toBe(false);
});
test('isGitAutoRefreshEnabled defaults to true when setting is undefined', async () => {
const { workspace, pattern } = createFixture();
const service = createService(workspace, pattern);
expect(workspace.settings.gitAutoRefreshEnabled).toBeUndefined();
expect(service.isGitAutoRefreshEnabled()).toBe(true);
});
});
@@ -0,0 +1,297 @@
import { describe, expect, mock, test } from 'bun:test';
import type { RunTurnCommand, WorkflowCheckpointSavedEvent, WorkflowCheckpointResume } from '@shared/contracts/sidecar';
import { SCRATCHPAD_PROJECT_ID } from '@shared/domain/project';
import type { ChatMessageRecord, SessionRecord } from '@shared/domain/session';
import {
createSessionRunRecord,
type RunTimelineEventRecord,
type SessionRunRecord,
} from '@shared/domain/runTimeline';
mock.module('electron', () => {
const electronMock = {
app: {
isPackaged: false,
getAppPath: () => 'C:\\workspace\\personal\\repositories\\aryx',
getPath: () => 'C:\\workspace\\personal\\repositories\\aryx\\tests\\fixtures',
},
dialog: {
showOpenDialog: async () => ({ canceled: true, filePaths: [] }),
},
shell: {
openPath: async () => '',
},
};
return {
...electronMock,
default: electronMock,
};
});
mock.module('keytar', () => ({
default: {
getPassword: async () => null,
setPassword: async () => undefined,
deletePassword: async () => false,
},
}));
const { AryxAppService } = await import('@main/AryxAppService');
describe('AryxAppService workflow checkpointing', () => {
test('records workflow checkpoint recovery snapshots from turn-scoped events', async () => {
const service = new AryxAppService();
const { session, run } = createRunningSession();
const checkpointEvent: WorkflowCheckpointSavedEvent = {
type: 'workflow-checkpoint-saved',
requestId: run.requestId,
sessionId: session.id,
workflowSessionId: run.requestId,
checkpointId: 'checkpoint-1',
storePath: 'C:\\Users\\tester\\AppData\\Local\\Aryx\\workflow-checkpoints\\session-1\\turn-1',
stepNumber: 2,
};
const internals = service as unknown as {
workflowCheckpointRecoveries: Map<string, unknown>;
handleTurnScopedEvent: (
workspace: { sessions: SessionRecord[] },
sessionId: string,
event: WorkflowCheckpointSavedEvent,
) => void | Promise<void>;
};
await internals.handleTurnScopedEvent({ sessions: [session] }, session.id, checkpointEvent);
expect(internals.workflowCheckpointRecoveries.get(run.requestId)).toEqual({
workflowSessionId: run.requestId,
checkpointId: 'checkpoint-1',
storePath: checkpointEvent.storePath,
stepNumber: 2,
sessionMessages: session.messages,
runEvents: run.events,
});
});
test('retries a checkpointed turn with resume metadata after sidecar exit', async () => {
const service = new AryxAppService();
const { session, run } = createRunningSession();
const workspace = { sessions: [session] };
const checkpointRecovery = {
workflowSessionId: run.requestId,
checkpointId: 'checkpoint-7',
storePath: 'C:\\Users\\tester\\AppData\\Local\\Aryx\\workflow-checkpoints\\session-1\\turn-1',
stepNumber: 7,
sessionMessages: structuredClone(session.messages),
runEvents: structuredClone(run.events),
};
const invocations: RunTurnCommand[] = [];
session.messages.push({
id: 'msg-partial',
role: 'assistant',
authorName: 'Primary',
content: 'Partial output after the checkpoint.',
createdAt: '2026-04-01T12:00:05.000Z',
pending: true,
});
run.events = [
...run.events,
{
id: 'run-event-extra',
kind: 'message',
occurredAt: '2026-04-01T12:00:05.000Z',
status: 'running',
messageId: 'msg-partial',
content: 'Partial output after the checkpoint.',
} satisfies RunTimelineEventRecord,
];
session.pendingUserInput = {
id: 'user-input-1',
status: 'pending',
requestedAt: '2026-04-01T12:00:05.000Z',
question: 'Need more detail?',
choices: ['Yes', 'No'],
allowFreeform: true,
};
(
service as unknown as {
workflowCheckpointRecoveries: Map<string, unknown>;
sidecar: {
runTurn: (
command: RunTurnCommand,
) => Promise<ChatMessageRecord[]>;
};
persistAndBroadcast: (workspace: unknown) => Promise<void>;
emitRunUpdated: (sessionId: string, occurredAt: string, run: SessionRunRecord) => void;
runSidecarTurnWithCheckpointRecovery: (
workspace: unknown,
session: SessionRecord,
requestId: string,
createCommand: (resumeFromCheckpoint?: WorkflowCheckpointResume) => RunTurnCommand,
onDelta: () => Promise<void>,
onActivity: () => Promise<void>,
onApproval: () => Promise<void>,
onUserInput: () => Promise<void>,
onMcpOAuthRequired: () => Promise<void>,
onExitPlanMode: () => Promise<void>,
onMessageReclassified: () => Promise<void>,
onTurnScopedEvent: () => Promise<void>,
) => Promise<ChatMessageRecord[]>;
}
).workflowCheckpointRecoveries.set(run.requestId, checkpointRecovery);
(
service as unknown as {
sidecar: {
runTurn: (command: RunTurnCommand) => Promise<ChatMessageRecord[]>;
};
}
).sidecar = {
runTurn: async (command: RunTurnCommand) => {
invocations.push(structuredClone(command));
if (invocations.length === 1) {
throw new Error('The .NET sidecar exited unexpectedly with code 1.');
}
return [];
},
};
(
service as unknown as {
persistAndBroadcast: (workspace: unknown) => Promise<void>;
emitRunUpdated: (sessionId: string, occurredAt: string, run: SessionRunRecord) => void;
}
).persistAndBroadcast = async () => undefined;
(
service as unknown as {
emitRunUpdated: (sessionId: string, occurredAt: string, run: SessionRunRecord) => void;
}
).emitRunUpdated = () => undefined;
const result = await (
service as unknown as {
runSidecarTurnWithCheckpointRecovery: (
workspace: unknown,
session: SessionRecord,
requestId: string,
createCommand: (resumeFromCheckpoint?: WorkflowCheckpointResume) => RunTurnCommand,
onDelta: () => Promise<void>,
onActivity: () => Promise<void>,
onApproval: () => Promise<void>,
onUserInput: () => Promise<void>,
onMcpOAuthRequired: () => Promise<void>,
onExitPlanMode: () => Promise<void>,
onMessageReclassified: () => Promise<void>,
onTurnScopedEvent: () => Promise<void>,
) => Promise<ChatMessageRecord[]>;
}
).runSidecarTurnWithCheckpointRecovery(
workspace,
session,
run.requestId,
(resumeFromCheckpoint?: WorkflowCheckpointResume): RunTurnCommand => ({
type: 'run-turn',
requestId: run.requestId,
sessionId: session.id,
projectPath: 'C:\\scratchpad',
workspaceKind: 'scratchpad',
mode: 'interactive',
messageMode: 'enqueue',
pattern: createPattern(),
messages: session.messages,
resumeFromCheckpoint,
}),
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
);
expect(result).toEqual([]);
expect(invocations).toHaveLength(2);
expect(invocations[0]?.resumeFromCheckpoint).toBeUndefined();
expect(invocations[1]?.resumeFromCheckpoint).toEqual({
workflowSessionId: run.requestId,
checkpointId: 'checkpoint-7',
storePath: checkpointRecovery.storePath,
});
expect(invocations[1]?.messages).toEqual(checkpointRecovery.sessionMessages);
expect(session.messages).toEqual(checkpointRecovery.sessionMessages);
expect(session.pendingUserInput).toBeUndefined();
expect(session.runs[0]?.events).toEqual(checkpointRecovery.runEvents);
});
});
function createRunningSession(): { session: SessionRecord; run: SessionRunRecord } {
const pattern = createPattern();
const run = createSessionRunRecord({
requestId: 'turn-1',
project: {
id: SCRATCHPAD_PROJECT_ID,
path: 'C:\\scratchpad',
},
workingDirectory: 'C:\\scratchpad',
workspaceKind: 'scratchpad',
pattern,
triggerMessageId: 'msg-user-1',
startedAt: '2026-04-01T12:00:00.000Z',
});
const session: SessionRecord = {
id: 'session-1',
projectId: SCRATCHPAD_PROJECT_ID,
patternId: pattern.id,
title: 'Checkpoint session',
createdAt: '2026-04-01T12:00:00.000Z',
updatedAt: '2026-04-01T12:00:00.000Z',
status: 'running',
messages: [
{
id: 'msg-user-1',
role: 'user',
authorName: 'You',
content: 'Continue the workflow.',
createdAt: '2026-04-01T12:00:00.000Z',
},
{
id: 'msg-assistant-1',
role: 'assistant',
authorName: 'Primary',
content: 'Working on it.',
createdAt: '2026-04-01T12:00:01.000Z',
pending: true,
},
],
runs: [run],
};
return { session, run };
}
function createPattern() {
return {
id: 'pattern-handoff',
name: 'Checkpointing flow',
description: '',
mode: 'handoff' as const,
availability: 'available' as const,
maxIterations: 4,
agents: [
{
id: 'agent-1',
name: 'Primary',
description: '',
instructions: 'Help with the request.',
model: 'gpt-5.4',
},
],
createdAt: '2026-04-01T00:00:00.000Z',
updatedAt: '2026-04-01T00:00:00.000Z',
};
}
@@ -0,0 +1,82 @@
import { describe, expect, mock, test } from 'bun:test';
import type { SessionEventRecord } from '@shared/domain/event';
import type { WorkflowDiagnosticEvent } from '@shared/contracts/sidecar';
mock.module('electron', () => {
const electronMock = {
app: {
isPackaged: false,
getAppPath: () => 'C:\\workspace\\personal\\repositories\\aryx',
getPath: () => 'C:\\workspace\\personal\\repositories\\aryx\\tests\\fixtures',
},
dialog: {
showOpenDialog: async () => ({ canceled: true, filePaths: [] }),
},
shell: {
openPath: async () => '',
},
};
return {
...electronMock,
default: electronMock,
};
});
mock.module('keytar', () => ({
default: {
getPassword: async () => null,
setPassword: async () => undefined,
deletePassword: async () => false,
},
}));
const { AryxAppService } = await import('@main/AryxAppService');
describe('AryxAppService workflow diagnostics', () => {
test('maps turn-scoped workflow diagnostics to session events', async () => {
const service = new AryxAppService();
const captured: SessionEventRecord[] = [];
const workflowDiagnostic: WorkflowDiagnosticEvent = {
type: 'workflow-diagnostic',
requestId: 'turn-1',
sessionId: 'session-1',
severity: 'error',
diagnosticKind: 'executor-failed',
message: 'Tool crashed.',
agentId: 'agent-1',
agentName: 'Primary',
executorId: 'agent-1',
exceptionType: 'InvalidOperationException',
};
const internals = service as unknown as {
emitSessionEvent: (event: SessionEventRecord) => void;
handleTurnScopedEvent: (
workspace: unknown,
sessionId: string,
event: WorkflowDiagnosticEvent,
) => void | Promise<void>;
};
internals.emitSessionEvent = (event) => {
captured.push(event);
};
await internals.handleTurnScopedEvent({}, 'session-1', workflowDiagnostic);
expect(captured).toHaveLength(1);
expect(captured[0]).toMatchObject({
sessionId: 'session-1',
kind: 'workflow-diagnostic',
agentId: 'agent-1',
agentName: 'Primary',
diagnosticSeverity: 'error',
diagnosticKind: 'executor-failed',
diagnosticMessage: 'Tool crashed.',
executorId: 'agent-1',
exceptionType: 'InvalidOperationException',
});
expect(captured[0]?.occurredAt).toEqual(expect.any(String));
});
});
+27 -5
View File
@@ -10,6 +10,8 @@ class FakeUpdater extends EventEmitter {
autoInstallOnAppQuit = true;
forceDevUpdateConfig = false;
checkForUpdatesCalls = 0;
quitAndInstallCalls = 0;
@@ -62,17 +64,21 @@ class FakeScheduler implements AutoUpdateScheduler {
}
describe('AutoUpdateService', () => {
test('does not schedule checks for unpackaged apps', async () => {
test('schedules checks for unpackaged apps using dev update config', async () => {
const updater = new FakeUpdater();
const scheduler = new FakeScheduler();
const service = new AutoUpdateService({ isPackaged: false, scheduler, updater });
service.start();
expect(scheduler.timeouts).toHaveLength(0);
expect(scheduler.intervals).toHaveLength(0);
expect(await service.checkForUpdates()).toEqual({ state: 'idle' });
expect(updater.checkForUpdatesCalls).toBe(0);
expect(updater.forceDevUpdateConfig).toBe(true);
expect(scheduler.timeouts).toEqual([{ callback: expect.any(Function), delayMs: 10_000 }]);
expect(scheduler.intervals).toEqual([{ callback: expect.any(Function), delayMs: 4 * 60 * 60 * 1000 }]);
await scheduler.runTimeout();
await Promise.resolve();
expect(updater.checkForUpdatesCalls).toBe(1);
});
test('configures auto download and schedules startup and periodic checks', async () => {
@@ -148,6 +154,22 @@ describe('AutoUpdateService', () => {
]);
});
test('transitions to up-to-date when no update is available', () => {
const updater = new FakeUpdater();
const service = new AutoUpdateService({ isPackaged: true, updater });
const statuses: UpdateStatus[] = [];
service.onStatus((status) => statuses.push(status));
updater.emit('checking-for-update');
updater.emit('update-not-available', {});
expect(statuses).toEqual([
{ state: 'checking' },
{ state: 'up-to-date' },
]);
expect(service.getStatus()).toEqual({ state: 'up-to-date' });
});
test('reports updater errors and only installs once an update is downloaded', () => {
const updater = new FakeUpdater();
const service = new AutoUpdateService({ isPackaged: true, updater });
@@ -0,0 +1,100 @@
import { describe, expect, test } from 'bun:test';
import type { ProjectGitRunChangeSummary } from '@shared/domain/project';
import { buildProjectGitCommitMessageSuggestion } from '@main/git/gitCommitMessageSuggestion';
const baseSummary: ProjectGitRunChangeSummary = {
generatedAt: '2026-03-31T00:00:00.000Z',
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 5,
deletions: 2,
counts: {
added: 0,
modified: 1,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 0,
},
files: [
{
path: 'src\\auth.ts',
kind: 'modified',
origin: 'run-created',
additions: 5,
deletions: 2,
canRevert: true,
},
],
};
describe('buildProjectGitCommitMessageSuggestion', () => {
test('infers a fix commit from the triggering user prompt', () => {
const suggestion = buildProjectGitCommitMessageSuggestion({
session: {
title: 'Auth hardening',
messages: [
{
id: 'msg-user-1',
role: 'user',
authorName: 'You',
content: 'Fix auth hardening for git integration.',
createdAt: '2026-03-31T00:00:00.000Z',
},
],
},
run: {
triggerMessageId: 'msg-user-1',
},
summary: baseSummary,
});
expect(suggestion).toEqual({
type: 'fix',
subject: 'auth hardening for git integration',
message: 'fix: auth hardening for git integration',
});
});
test('infers docs commits from documentation-only changes', () => {
const suggestion = buildProjectGitCommitMessageSuggestion({
session: {
title: 'Docs touch-up',
messages: [
{
id: 'msg-user-1',
role: 'user',
authorName: 'You',
content: '',
createdAt: '2026-03-31T00:00:00.000Z',
},
],
},
run: {
triggerMessageId: 'msg-user-1',
},
summary: {
...baseSummary,
files: [
{
path: 'README.md',
kind: 'modified',
origin: 'run-created',
additions: 1,
deletions: 0,
canRevert: true,
},
],
},
});
expect(suggestion.type).toBe('docs');
expect(suggestion.message).toBe('docs: update readme');
});
});
+268
View File
@@ -0,0 +1,268 @@
import { describe, expect, test } from 'bun:test';
import type { ProjectGitBaselineFile, ProjectGitWorkingTreeSnapshot } from '@shared/domain/project';
import { buildProjectGitRunChangeSummary } from '@main/git/gitRunChangeSummary';
const TIMESTAMP = '2026-03-31T00:00:00.000Z';
function createPreRunSnapshot(): ProjectGitWorkingTreeSnapshot {
return {
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
changedFileCount: 2,
changes: {
staged: 0,
unstaged: 1,
untracked: 1,
conflicted: 0,
},
files: [
{
path: 'src\\auth.ts',
unstagedStatus: 'modified',
},
{
path: 'legacy.tmp',
unstagedStatus: 'untracked',
},
],
};
}
function createPostRunSnapshot(): ProjectGitWorkingTreeSnapshot {
return {
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
changedFileCount: 2,
changes: {
staged: 0,
unstaged: 1,
untracked: 1,
conflicted: 0,
},
files: [
{
path: 'src\\auth.ts',
unstagedStatus: 'modified',
},
{
path: 'notes.txt',
unstagedStatus: 'untracked',
},
],
};
}
function createPreRunBaselines(): ProjectGitBaselineFile[] {
return [
{
path: 'src\\auth.ts',
combinedDiff: 'diff --git a/src/auth.ts b/src/auth.ts\n@@ -1 +1 @@\n-old\n+before\n',
},
{
path: 'legacy.tmp',
untrackedContentBase64: Buffer.from('legacy\n', 'utf8').toString('base64'),
},
];
}
function createPostRunBaselines(): ProjectGitBaselineFile[] {
return [
{
path: 'src\\auth.ts',
combinedDiff: 'diff --git a/src/auth.ts b/src/auth.ts\n@@ -1 +1 @@\n-old\n+after\n',
},
{
path: 'notes.txt',
untrackedContentBase64: Buffer.from('fresh notes\n', 'utf8').toString('base64'),
},
];
}
describe('buildProjectGitRunChangeSummary', () => {
test('classifies run-created, pre-existing, and cleaned files', () => {
const summary = buildProjectGitRunChangeSummary({
generatedAt: TIMESTAMP,
preRunSnapshot: createPreRunSnapshot(),
preRunBaselineFiles: createPreRunBaselines(),
postRunSnapshot: createPostRunSnapshot(),
postRunBaselineFiles: createPostRunBaselines(),
});
expect(summary).toMatchObject({
generatedAt: TIMESTAMP,
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 3,
additions: 1,
deletions: 1,
counts: {
added: 0,
modified: 1,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 1,
cleaned: 1,
},
});
expect(summary?.files).toEqual([
{
path: 'notes.txt',
previousPath: undefined,
kind: 'untracked',
origin: 'run-created',
stagedStatus: undefined,
unstagedStatus: 'untracked',
additions: 0,
deletions: 0,
canRevert: true,
preview: {
path: 'notes.txt',
previousPath: undefined,
newFileContents: 'fresh notes\n',
},
},
{
path: 'legacy.tmp',
previousPath: undefined,
kind: 'cleaned',
origin: 'pre-existing',
stagedStatus: undefined,
unstagedStatus: 'untracked',
additions: 0,
deletions: 0,
canRevert: true,
preview: {
path: 'legacy.tmp',
previousPath: undefined,
newFileContents: 'legacy\n',
},
},
{
path: 'src\\auth.ts',
previousPath: undefined,
kind: 'modified',
origin: 'pre-existing',
stagedStatus: undefined,
unstagedStatus: 'modified',
additions: 1,
deletions: 1,
canRevert: true,
preview: {
path: 'src\\auth.ts',
previousPath: undefined,
diff: 'diff --git a/src/auth.ts b/src/auth.ts\n@@ -1 +1 @@\n-old\n+after\n',
},
},
]);
});
test('returns undefined when nothing changed across the run', () => {
const snapshot = createPreRunSnapshot();
const baselines = createPreRunBaselines();
expect(buildProjectGitRunChangeSummary({
generatedAt: TIMESTAMP,
preRunSnapshot: snapshot,
preRunBaselineFiles: baselines,
postRunSnapshot: snapshot,
postRunBaselineFiles: baselines,
})).toBeUndefined();
});
test('marks pre-existing files as non-revertable when the baseline capture has no restore data', () => {
const summary = buildProjectGitRunChangeSummary({
generatedAt: TIMESTAMP,
preRunSnapshot: createPreRunSnapshot(),
preRunBaselineFiles: [
{
path: 'src\\auth.ts',
},
],
postRunSnapshot: createPostRunSnapshot(),
postRunBaselineFiles: createPostRunBaselines(),
});
expect(summary?.files.find((file) => file.path === 'src\\auth.ts')).toMatchObject({
path: 'src\\auth.ts',
origin: 'pre-existing',
canRevert: false,
});
expect(summary?.files.find((file) => file.path === 'legacy.tmp')).toMatchObject({
path: 'legacy.tmp',
kind: 'cleaned',
canRevert: false,
});
});
test('preserves empty untracked file previews', () => {
const summary = buildProjectGitRunChangeSummary({
generatedAt: TIMESTAMP,
preRunSnapshot: {
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
changedFileCount: 1,
changes: {
staged: 0,
unstaged: 0,
untracked: 1,
conflicted: 0,
},
files: [
{
path: 'empty.txt',
unstagedStatus: 'untracked',
},
],
},
preRunBaselineFiles: [
{
path: 'empty.txt',
untrackedContentBase64: '',
},
],
postRunSnapshot: {
scannedAt: TIMESTAMP,
repoRoot: 'C:\\workspace\\alpha',
branch: 'main',
changedFileCount: 0,
changes: {
staged: 0,
unstaged: 0,
untracked: 0,
conflicted: 0,
},
files: [],
},
postRunBaselineFiles: [],
});
expect(summary?.files).toEqual([
{
path: 'empty.txt',
previousPath: undefined,
kind: 'cleaned',
origin: 'pre-existing',
stagedStatus: undefined,
unstagedStatus: 'untracked',
additions: 0,
deletions: 0,
canRevert: true,
preview: {
path: 'empty.txt',
previousPath: undefined,
newFileContents: '',
},
},
]);
});
});
+386
View File
@@ -1,3 +1,7 @@
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { describe, expect, test } from 'bun:test';
import { GitService } from '@main/git/gitService';
@@ -121,4 +125,386 @@ describe('GitService', () => {
head: undefined,
});
});
test('captures a structured pre-run working tree snapshot', async () => {
const service = createService({
'rev-parse --show-toplevel': 'C:\\workspace\\repo\n',
'status --porcelain=1 --untracked-files=all': 'R src\\old.ts -> src\\new.ts\n M src\\app.ts\n?? notes.txt\nUU conflict.txt\n',
'branch --show-current': 'feature/git-context\n',
});
await expect(service.captureWorkingTreeSnapshot('C:\\workspace\\repo', '2026-03-23T19:00:00.000Z')).resolves.toEqual({
scannedAt: '2026-03-23T19:00:00.000Z',
repoRoot: 'C:\\workspace\\repo',
branch: 'feature/git-context',
changedFileCount: 4,
changes: {
staged: 1,
unstaged: 1,
untracked: 1,
conflicted: 1,
},
files: [
{
path: 'src\\new.ts',
previousPath: 'src\\old.ts',
stagedStatus: 'renamed',
unstagedStatus: undefined,
},
{
path: 'src\\app.ts',
stagedStatus: undefined,
unstagedStatus: 'modified',
},
{
path: 'notes.txt',
unstagedStatus: 'untracked',
},
{
path: 'conflict.txt',
stagedStatus: 'unmerged',
unstagedStatus: 'unmerged',
isConflicted: true,
},
],
});
});
test('returns no working tree snapshot outside a git repository', async () => {
const service = createService({
'rev-parse --show-toplevel': createGitError('fatal: not a git repository', {
stderr: 'fatal: not a git repository (or any of the parent directories): .git',
}),
});
await expect(service.captureWorkingTreeSnapshot('C:\\workspace\\not-a-repo', '2026-03-23T19:00:00.000Z')).resolves.toBeUndefined();
});
test('captures baseline data for tracked diffs and untracked files', async () => {
const tempDirectory = await mkdtemp(join(tmpdir(), 'aryx-git-service-'));
try {
await writeFile(join(tempDirectory, 'notes.txt'), 'fresh notes\n', 'utf8');
const service = createService({
'diff --binary --no-ext-diff --no-renames HEAD -- src\\app.ts': 'diff --git a/src/app.ts b/src/app.ts\n@@ -1 +1 @@\n-old\n+new\n',
});
await expect(service.captureWorkingTreeBaseline(tempDirectory, {
scannedAt: '2026-03-23T19:00:00.000Z',
repoRoot: tempDirectory,
branch: 'main',
changedFileCount: 2,
changes: {
staged: 0,
unstaged: 1,
untracked: 1,
conflicted: 0,
},
files: [
{
path: 'src\\app.ts',
unstagedStatus: 'modified',
},
{
path: 'notes.txt',
unstagedStatus: 'untracked',
},
],
})).resolves.toEqual([
{
path: 'src\\app.ts',
previousPath: undefined,
combinedDiff: 'diff --git a/src/app.ts b/src/app.ts\n@@ -1 +1 @@\n-old\n+new\n',
},
{
path: 'notes.txt',
previousPath: undefined,
untrackedContentBase64: Buffer.from('fresh notes\n', 'utf8').toString('base64'),
},
]);
} finally {
await rm(tempDirectory, { force: true, recursive: true });
}
});
test('describes git details with branches and recent commits', async () => {
const service = createService({
'rev-parse --show-toplevel': 'C:\\workspace\\repo\n',
'status --porcelain=1 --untracked-files=all': ' M src\\app.ts\n',
'branch --show-current': 'main\n',
'rev-parse --abbrev-ref --symbolic-full-name @{upstream}': 'origin/main\n',
'rev-list --left-right --count @{upstream}...HEAD': '0\t2\n',
'log -1 --format=%H%n%h%n%s%n%cI': '0123456789abcdef\n0123456\nAdd git detail plumbing\n2026-03-23T18:00:00+01:00\n',
'for-each-ref --format=%(refname:short)%00%(HEAD)%00%(upstream:short) refs/heads': 'main\0*\0origin/main\nfeature/refactor\0 \0origin/feature/refactor\n',
'log -n15 --format=%H%x00%h%x00%an%x00%s%x00%cI%x00%D%x1e': '0123456789abcdef\x00123456\x00Alice\x00Add git detail plumbing\x002026-03-23T18:00:00+01:00\x00HEAD -> main, origin/main\x1e',
});
await expect(service.describeProjectGitDetails('C:\\workspace\\repo', '2026-03-23T19:00:00.000Z', 15)).resolves.toMatchObject({
scannedAt: '2026-03-23T19:00:00.000Z',
context: {
status: 'ready',
branch: 'main',
upstream: 'origin/main',
ahead: 2,
behind: 0,
},
workingTree: {
changedFileCount: 1,
},
branches: [
{ name: 'main', isCurrent: true, upstream: 'origin/main' },
{ name: 'feature/refactor', isCurrent: false, upstream: 'origin/feature/refactor' },
],
recentCommits: [
{
hash: '0123456789abcdef',
shortHash: '123456',
authorName: 'Alice',
subject: 'Add git detail plumbing',
committedAt: '2026-03-23T18:00:00+01:00',
refNames: 'HEAD -> main, origin/main',
},
],
});
});
test('dispatches commit workflow and branch commands to git', async () => {
const executedCommands: string[] = [];
const service = new GitService(async (_projectPath, args) => {
executedCommands.push(args.join(' '));
if (args.join(' ') === 'commit -m feat: update auth') {
return '';
}
if (args.join(' ') === 'log -1 --format=%H%n%h%n%s%n%cI') {
return 'fedcba9876543210\nfedcba9\nfeat: update auth\n2026-03-23T18:00:00+01:00\n';
}
return '';
});
await service.stageFiles('C:\\workspace\\repo', [{ path: 'src\\auth.ts' }]);
await service.unstageFiles('C:\\workspace\\repo', [{ path: 'src\\auth.ts' }]);
await expect(service.commit('C:\\workspace\\repo', 'feat: update auth')).resolves.toEqual({
hash: 'fedcba9876543210',
shortHash: 'fedcba9',
subject: 'feat: update auth',
committedAt: '2026-03-23T18:00:00+01:00',
});
await service.push('C:\\workspace\\repo');
await service.fetch('C:\\workspace\\repo');
await service.pull('C:\\workspace\\repo', true);
await service.createBranch('C:\\workspace\\repo', 'feature/git-panel', undefined, true);
await service.switchBranch('C:\\workspace\\repo', 'main');
await service.deleteBranch('C:\\workspace\\repo', 'feature/git-panel', true);
expect(executedCommands).toEqual([
'add -- src\\auth.ts',
'restore --staged -- src\\auth.ts',
'commit -m feat: update auth',
'log -1 --format=%H%n%h%n%s%n%cI',
'push',
'fetch --all --prune',
'pull --rebase',
'switch -c feature/git-panel',
'switch main',
'branch -D feature/git-panel',
]);
});
test('discards run-created untracked files from the working tree', async () => {
const tempDirectory = await mkdtemp(join(tmpdir(), 'aryx-git-discard-'));
try {
await writeFile(join(tempDirectory, 'notes.txt'), 'fresh notes\n', 'utf8');
const executedCommands: string[] = [];
const service = new GitService(async (_projectPath, args) => {
executedCommands.push(args.join(' '));
return '';
});
await service.discardRunChanges(tempDirectory, {
summary: {
generatedAt: '2026-03-31T00:00:00.000Z',
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 0,
deletions: 0,
counts: {
added: 0,
modified: 0,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 1,
cleaned: 0,
},
files: [
{
path: 'notes.txt',
kind: 'untracked',
origin: 'run-created',
additions: 0,
deletions: 0,
canRevert: true,
},
],
},
});
expect(executedCommands).toEqual([
'rm --cached --force --ignore-unmatch -- notes.txt',
]);
await expect(Bun.file(join(tempDirectory, 'notes.txt')).exists()).resolves.toBe(false);
} finally {
await rm(tempDirectory, { force: true, recursive: true });
}
});
test('restores cleaned pre-existing untracked files from the captured baseline', async () => {
const tempDirectory = await mkdtemp(join(tmpdir(), 'aryx-git-restore-'));
try {
const executedCommands: string[] = [];
const service = new GitService(async (_projectPath, args) => {
executedCommands.push(args.join(' '));
return '';
});
await service.discardRunChanges(tempDirectory, {
summary: {
generatedAt: '2026-03-31T00:00:00.000Z',
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 0,
deletions: 0,
counts: {
added: 0,
modified: 0,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 1,
},
files: [
{
path: 'legacy.txt',
kind: 'cleaned',
origin: 'pre-existing',
additions: 0,
deletions: 0,
canRevert: true,
},
],
},
preRunBaselineFiles: [
{
path: 'legacy.txt',
untrackedContentBase64: Buffer.from('legacy\n', 'utf8').toString('base64'),
},
],
});
expect(executedCommands).toEqual([
'restore --source=HEAD --staged --worktree -- legacy.txt',
]);
await expect(Bun.file(join(tempDirectory, 'legacy.txt')).text()).resolves.toBe('legacy\n');
} finally {
await rm(tempDirectory, { force: true, recursive: true });
}
});
test('restores cleaned pre-existing empty untracked files from the captured baseline', async () => {
const tempDirectory = await mkdtemp(join(tmpdir(), 'aryx-git-restore-empty-'));
try {
const service = new GitService(async () => '');
await service.discardRunChanges(tempDirectory, {
summary: {
generatedAt: '2026-03-31T00:00:00.000Z',
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 0,
deletions: 0,
counts: {
added: 0,
modified: 0,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 1,
},
files: [
{
path: 'empty.txt',
kind: 'cleaned',
origin: 'pre-existing',
additions: 0,
deletions: 0,
canRevert: true,
},
],
},
preRunBaselineFiles: [
{
path: 'empty.txt',
untrackedContentBase64: '',
},
],
});
await expect(Bun.file(join(tempDirectory, 'empty.txt')).text()).resolves.toBe('');
} finally {
await rm(tempDirectory, { force: true, recursive: true });
}
});
test('rejects restoring pre-existing files when no restorable baseline was captured', async () => {
const service = new GitService(async () => '');
await expect(service.discardRunChanges('C:\\workspace\\repo', {
summary: {
generatedAt: '2026-03-31T00:00:00.000Z',
branchAtStart: 'main',
branchAtEnd: 'main',
fileCount: 1,
additions: 0,
deletions: 0,
counts: {
added: 0,
modified: 1,
deleted: 0,
renamed: 0,
copied: 0,
typeChanged: 0,
unmerged: 0,
untracked: 0,
cleaned: 0,
},
files: [
{
path: 'src\\auth.ts',
kind: 'modified',
origin: 'pre-existing',
additions: 0,
deletions: 0,
canRevert: false,
},
],
},
preRunBaselineFiles: [
{
path: 'src\\auth.ts',
},
],
})).rejects.toThrow('no restorable baseline was captured');
});
});
+2
View File
@@ -19,6 +19,7 @@ describe('run turn pending helpers', () => {
onUserInput: () => undefined,
onExitPlanMode: () => undefined,
onMcpOAuthRequired: () => undefined,
onMessageReclassified: () => undefined,
onTurnScopedEvent: () => undefined,
errored: false,
};
@@ -45,6 +46,7 @@ describe('run turn pending helpers', () => {
onUserInput: () => undefined,
onExitPlanMode: () => undefined,
onMcpOAuthRequired: () => undefined,
onMessageReclassified: () => undefined,
onTurnScopedEvent: () => undefined,
errored: false,
};
+194 -1
View File
@@ -2,7 +2,12 @@ import { EventEmitter } from 'node:events';
import { describe, expect, mock, test } from 'bun:test';
import type { SidecarCapabilities } from '@shared/contracts/sidecar';
import type {
RunTurnCommand,
SidecarCapabilities,
WorkflowCheckpointSavedEvent,
WorkflowDiagnosticEvent,
} from '@shared/contracts/sidecar';
class FakeReadableStream extends EventEmitter {
setEncoding(_encoding: BufferEncoding): void {}
@@ -142,4 +147,192 @@ describe('SidecarClient', () => {
spawnedProcesses[1]!.completeExit();
await finalDispose;
});
test('routes workflow diagnostic events through the turn-scoped callback', async () => {
spawnedProcesses.length = 0;
const client = new SidecarClient();
const diagnostics: WorkflowDiagnosticEvent[] = [];
const command: RunTurnCommand = {
type: 'run-turn',
requestId: 'turn-1',
sessionId: 'session-1',
projectPath: 'C:\\workspace\\project',
pattern: {
id: 'pattern-1',
name: 'Single Agent',
description: '',
mode: 'single',
availability: 'available',
maxIterations: 1,
agents: [
{
id: 'agent-1',
name: 'Primary',
description: '',
instructions: 'Help with the request.',
model: 'gpt-5.4',
},
],
createdAt: '2026-04-01T00:00:00.000Z',
updatedAt: '2026-04-01T00:00:00.000Z',
},
messages: [],
};
const turn = client.runTurn(
command,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async (event) => {
if (event.type === 'workflow-diagnostic') {
diagnostics.push(event);
}
},
);
await Promise.resolve();
expect(spawnedProcesses).toHaveLength(1);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'workflow-diagnostic',
requestId: command.requestId,
sessionId: command.sessionId,
severity: 'error',
diagnosticKind: 'executor-failed',
message: 'Tool crashed.',
agentId: 'agent-1',
agentName: 'Primary',
executorId: 'agent-1',
exceptionType: 'InvalidOperationException',
} satisfies WorkflowDiagnosticEvent)}\n`,
);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'turn-complete',
requestId: command.requestId,
sessionId: command.sessionId,
messages: [],
cancelled: false,
})}\n`,
);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'command-complete',
requestId: command.requestId,
})}\n`,
);
await expect(turn).resolves.toEqual([]);
expect(diagnostics).toEqual([
expect.objectContaining({
type: 'workflow-diagnostic',
severity: 'error',
diagnosticKind: 'executor-failed',
message: 'Tool crashed.',
executorId: 'agent-1',
}),
]);
const dispose = client.dispose();
spawnedProcesses[0]!.completeExit();
await dispose;
});
test('routes workflow checkpoint events through the turn-scoped callback', async () => {
spawnedProcesses.length = 0;
const client = new SidecarClient();
const checkpoints: WorkflowCheckpointSavedEvent[] = [];
const command: RunTurnCommand = {
type: 'run-turn',
requestId: 'turn-1',
sessionId: 'session-1',
projectPath: 'C:\\workspace\\project',
pattern: {
id: 'pattern-1',
name: 'Handoff',
description: '',
mode: 'handoff',
availability: 'available',
maxIterations: 1,
agents: [
{
id: 'agent-1',
name: 'Primary',
description: '',
instructions: 'Help with the request.',
model: 'gpt-5.4',
},
],
createdAt: '2026-04-01T00:00:00.000Z',
updatedAt: '2026-04-01T00:00:00.000Z',
},
messages: [],
};
const turn = client.runTurn(
command,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async () => undefined,
async (event) => {
if (event.type === 'workflow-checkpoint-saved') {
checkpoints.push(event);
}
},
);
await Promise.resolve();
expect(spawnedProcesses).toHaveLength(1);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'workflow-checkpoint-saved',
requestId: command.requestId,
sessionId: command.sessionId,
workflowSessionId: 'turn-1',
checkpointId: 'checkpoint-1',
storePath: 'C:\\Users\\tester\\AppData\\Local\\Aryx\\workflow-checkpoints\\session-1\\turn-1',
stepNumber: 2,
} satisfies WorkflowCheckpointSavedEvent)}\n`,
);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'turn-complete',
requestId: command.requestId,
sessionId: command.sessionId,
messages: [],
cancelled: false,
})}\n`,
);
spawnedProcesses[0]!.emitStdout(
`${JSON.stringify({
type: 'command-complete',
requestId: command.requestId,
})}\n`,
);
await expect(turn).resolves.toEqual([]);
expect(checkpoints).toEqual([
expect.objectContaining({
type: 'workflow-checkpoint-saved',
workflowSessionId: 'turn-1',
checkpointId: 'checkpoint-1',
stepNumber: 2,
}),
]);
const dispose = client.dispose();
spawnedProcesses[0]!.completeExit();
await dispose;
});
});
+60 -5
View File
@@ -33,7 +33,7 @@ describe('assistant message phase', () => {
},
], 'running');
expect(getAssistantMessagePhase(session, session.messages[0], 0)).toBe('thinking');
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('thinking');
});
test('marks the last completed assistant message as final when the session is idle', () => {
@@ -54,8 +54,8 @@ describe('assistant message phase', () => {
},
]);
expect(getAssistantMessagePhase(session, session.messages[0], 0)).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[1], 1)).toBe('final');
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[1])).toBe('final');
});
test('does not mark completed assistant messages as final while the session is still running', () => {
@@ -69,7 +69,7 @@ describe('assistant message phase', () => {
},
], 'running');
expect(getAssistantMessagePhase(session, session.messages[0], 0)).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('default');
});
test('ignores non-assistant messages', () => {
@@ -83,6 +83,61 @@ describe('assistant message phase', () => {
},
]);
expect(getAssistantMessagePhase(session, session.messages[0], 0)).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('default');
});
test('returns default for thinking-kind messages regardless of other state', () => {
const session = createSession([
{
id: 'msg-1',
role: 'assistant',
authorName: 'Primary Agent',
content: 'Let me search...',
createdAt: '2026-03-23T00:00:00.000Z',
messageKind: 'thinking',
},
{
id: 'msg-2',
role: 'assistant',
authorName: 'Primary Agent',
content: 'Here is the result.',
createdAt: '2026-03-23T00:00:01.000Z',
},
]);
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[1])).toBe('final');
});
test('skips thinking messages when determining the last completed assistant', () => {
const session = createSession([
{
id: 'msg-1',
role: 'assistant',
authorName: 'Primary Agent',
content: 'Let me search...',
createdAt: '2026-03-23T00:00:00.000Z',
messageKind: 'thinking',
},
{
id: 'msg-2',
role: 'assistant',
authorName: 'Primary Agent',
content: 'More searching...',
createdAt: '2026-03-23T00:00:01.000Z',
messageKind: 'thinking',
},
{
id: 'msg-3',
role: 'assistant',
authorName: 'Primary Agent',
content: 'Final answer.',
createdAt: '2026-03-23T00:00:02.000Z',
},
]);
expect(getAssistantMessagePhase(session, session.messages[0])).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[1])).toBe('default');
expect(getAssistantMessagePhase(session, session.messages[2])).toBe('final');
});
});
+77
View File
@@ -3,6 +3,7 @@ import { describe, expect, test } from 'bun:test';
import {
applySessionEventActivity,
applyAssistantUsageEvent,
applyTurnEventLog,
buildAgentActivityRows,
formatAgentActivityLabel,
formatDuration,
@@ -527,3 +528,79 @@ describe('usage formatting helpers', () => {
expect(formatDuration(150_000)).toBe('2.5m');
});
});
describe('workflow diagnostic turn events', () => {
function makeDiagnosticEvent(overrides: Partial<SessionEventRecord> = {}): SessionEventRecord {
return {
sessionId: 'session-1',
kind: 'workflow-diagnostic',
occurredAt: '2026-03-23T00:00:00.000Z',
diagnosticSeverity: 'error',
diagnosticKind: 'executor-failed',
diagnosticMessage: 'Tool crashed.',
...overrides,
};
}
test('formats executor-failed with full metadata', () => {
const result = applyTurnEventLog({}, makeDiagnosticEvent({
executorId: 'Primary',
exceptionType: 'InvalidOperationException',
}));
const entries = result['session-1']!;
expect(entries).toHaveLength(1);
expect(entries[0].label).toBe('Executor failed');
expect(entries[0].detail).toBe('Primary · InvalidOperationException · Tool crashed.');
expect(entries[0].success).toBe(false);
});
test('formats workflow-warning with message only', () => {
const result = applyTurnEventLog({}, makeDiagnosticEvent({
diagnosticSeverity: 'warning',
diagnosticKind: 'workflow-warning',
diagnosticMessage: 'Token budget is nearly exhausted.',
executorId: undefined,
exceptionType: undefined,
}));
const entries = result['session-1']!;
expect(entries[0].label).toBe('Workflow warning');
expect(entries[0].detail).toBe('Token budget is nearly exhausted.');
expect(entries[0].success).toBeUndefined();
});
test('formats subworkflow-error with subworkflow ID', () => {
const result = applyTurnEventLog({}, makeDiagnosticEvent({
diagnosticKind: 'subworkflow-error',
subworkflowId: 'subworkflow-review',
exceptionType: 'InvalidOperationException',
diagnosticMessage: 'Reviewer agent failed.',
}));
const entries = result['session-1']!;
expect(entries[0].label).toBe('Subworkflow error');
expect(entries[0].detail).toBe('subworkflow-review · InvalidOperationException · Reviewer agent failed.');
});
test('formats workflow-error without optional fields', () => {
const result = applyTurnEventLog({}, makeDiagnosticEvent({
diagnosticKind: 'workflow-error',
diagnosticMessage: 'Workflow terminated unexpectedly.',
executorId: undefined,
subworkflowId: undefined,
exceptionType: undefined,
}));
const entries = result['session-1']!;
expect(entries[0].label).toBe('Workflow error');
expect(entries[0].detail).toBe('Workflow terminated unexpectedly.');
expect(entries[0].success).toBe(false);
});
test('falls back to severity when diagnosticKind is missing', () => {
const result = applyTurnEventLog({}, makeDiagnosticEvent({
diagnosticKind: undefined,
diagnosticSeverity: 'warning',
diagnosticMessage: 'Something odd happened.',
}));
const entries = result['session-1']!;
expect(entries[0].label).toBe('Workflow warning');
});
});
+69
View File
@@ -281,4 +281,73 @@ describe('session workspace helpers', () => {
} satisfies SessionEventRecord),
).toBe(workspace);
});
test('reclassifies a message as thinking when message-reclassified event arrives', () => {
const workspace = applySessionEventWorkspace(createWorkspace(), {
sessionId: 'session-1',
kind: 'message-delta',
occurredAt: '2026-03-23T00:00:01.000Z',
messageId: 'assistant-1',
authorName: 'Primary Agent',
contentDelta: 'Let me search...',
content: 'Let me search...',
} satisfies SessionEventRecord);
const reclassified = applySessionEventWorkspace(workspace, {
sessionId: 'session-1',
kind: 'message-reclassified',
occurredAt: '2026-03-23T00:00:02.000Z',
messageId: 'assistant-1',
messageKind: 'thinking',
} satisfies SessionEventRecord);
expect(reclassified?.sessions[0].messages[0]).toMatchObject({
id: 'assistant-1',
messageKind: 'thinking',
});
});
test('ignores message-reclassified for an already reclassified message', () => {
let workspace = applySessionEventWorkspace(createWorkspace(), {
sessionId: 'session-1',
kind: 'message-delta',
occurredAt: '2026-03-23T00:00:01.000Z',
messageId: 'assistant-1',
authorName: 'Primary Agent',
contentDelta: 'Let me search...',
content: 'Let me search...',
} satisfies SessionEventRecord);
workspace = applySessionEventWorkspace(workspace, {
sessionId: 'session-1',
kind: 'message-reclassified',
occurredAt: '2026-03-23T00:00:02.000Z',
messageId: 'assistant-1',
messageKind: 'thinking',
} satisfies SessionEventRecord);
const duplicate = applySessionEventWorkspace(workspace, {
sessionId: 'session-1',
kind: 'message-reclassified',
occurredAt: '2026-03-23T00:00:03.000Z',
messageId: 'assistant-1',
messageKind: 'thinking',
} satisfies SessionEventRecord);
// Should return the same reference (no change)
expect(duplicate).toBe(workspace);
});
test('ignores message-reclassified for unknown message ids', () => {
const workspace = createWorkspace();
const result = applySessionEventWorkspace(workspace, {
sessionId: 'session-1',
kind: 'message-reclassified',
occurredAt: '2026-03-23T00:00:01.000Z',
messageId: 'nonexistent',
messageKind: 'thinking',
} satisfies SessionEventRecord);
expect(result).toBe(workspace);
});
});
+15
View File
@@ -55,22 +55,37 @@ describe('run timeline helpers', () => {
const run = createSessionRunRecord({
requestId: 'turn-1',
project: createProject(),
workingDirectory: 'C:\\workspace\\alpha\\packages\\app',
workspaceKind: 'project',
pattern: createPattern(),
triggerMessageId: 'msg-user-1',
startedAt: '2026-03-23T00:00:01.000Z',
preRunGitBaselineFiles: [
{
path: 'src\\alpha.ts',
combinedDiff: '@@ -1 +1 @@\n-old\n+new\n',
},
],
});
expect(run).toMatchObject({
requestId: 'turn-1',
projectId: 'project-1',
projectPath: 'C:\\workspace\\alpha',
workingDirectory: 'C:\\workspace\\alpha\\packages\\app',
patternId: 'pattern-sequential',
patternName: 'Sequential Trio Review',
patternMode: 'sequential',
triggerMessageId: 'msg-user-1',
status: 'running',
});
expect(run.preRunGitBaselineFiles).toEqual([
{
path: 'src\\alpha.ts',
previousPath: undefined,
combinedDiff: '@@ -1 +1 @@\n-old\n+new\n',
},
]);
expect(run.agents).toEqual([
{
agentId: 'agent-writer',
+99
View File
@@ -2,6 +2,7 @@ import { describe, expect, test } from 'bun:test';
import {
buildMcpServerApprovalKey,
countApprovedToolsInGroups,
groupApprovalToolsByProvider,
listApprovalToolDefinitions,
listApprovalToolNames,
@@ -658,3 +659,101 @@ describe('probed tools', () => {
expect(names).toContain('mcp_server:Probed Keys');
});
});
describe('countApprovedToolsInGroups', () => {
const TS = '2026-03-28T00:00:00.000Z';
function makeTooling(
mcpServers: McpServerDefinition[] = [],
lspProfiles: LspProfileDefinition[] = [],
): WorkspaceToolingSettings {
return { mcpServers, lspProfiles };
}
function makeMcpServer(id: string, name: string, tools: string[]): McpServerDefinition {
return { id, name, transport: 'local', command: 'node', args: [], tools, createdAt: TS, updatedAt: TS };
}
test('counts all tools approved when all server keys are set', () => {
const tooling = makeTooling([
makeMcpServer('git', 'Git MCP', ['git.status', 'git.diff']),
makeMcpServer('fs', 'Filesystem', ['fs.read']),
]);
const tools = listApprovalToolDefinitions(tooling);
const groups = groupApprovalToolsByProvider(tools, tooling);
const mcpGroups = groups.filter((g) => g.kind === 'mcp');
const approved = new Set(['mcp_server:Git MCP', 'mcp_server:Filesystem']);
const mcpTotal = mcpGroups.reduce(
(sum, g) => sum + Math.max(g.tools.length, g.serverApprovalKey ? 1 : 0), 0,
);
const count = countApprovedToolsInGroups(mcpGroups, approved);
expect(count).toBe(mcpTotal);
});
test('counts shared tool names per group, not as unique IDs', () => {
const tooling = makeTooling([
makeMcpServer('git-a', 'Git A', ['git.status', 'git.diff']),
makeMcpServer('git-b', 'Git B', ['git.status', 'git.diff']),
]);
const tools = listApprovalToolDefinitions(tooling);
const groups = groupApprovalToolsByProvider(tools, tooling);
const mcpGroups = groups.filter((g) => g.kind === 'mcp');
expect(mcpGroups.length).toBe(2);
// Both servers share the same tool names — MCP total should be 4 (2 per group)
const mcpTotal = mcpGroups.reduce(
(sum, g) => sum + Math.max(g.tools.length, g.serverApprovalKey ? 1 : 0), 0,
);
expect(mcpTotal).toBe(4);
// Approve all via server keys — count must match total
const approved = new Set(['mcp_server:Git A', 'mcp_server:Git B']);
const count = countApprovedToolsInGroups(mcpGroups, approved);
expect(count).toBe(mcpTotal);
});
test('counts individual tool approvals per group when no server key', () => {
const tooling = makeTooling([
makeMcpServer('git-a', 'Git A', ['git.status']),
makeMcpServer('git-b', 'Git B', ['git.status']),
]);
const tools = listApprovalToolDefinitions(tooling);
const groups = groupApprovalToolsByProvider(tools, tooling);
// Approve only the individual tool ID (shared across both groups)
const approved = new Set(['git.status']);
const mcpGroups = groups.filter((g) => g.kind === 'mcp');
expect(mcpGroups.length).toBe(2);
// Each group has the same tool → count should be 2 (once per group)
const mcpCount = countApprovedToolsInGroups(mcpGroups, approved);
expect(mcpCount).toBe(2);
});
test('counts empty server with approved key as 1', () => {
const tooling = makeTooling([makeMcpServer('empty', 'Empty Server', [])]);
const tools = listApprovalToolDefinitions(tooling);
const groups = groupApprovalToolsByProvider(tools, tooling);
const approved = new Set(['mcp_server:Empty Server']);
const mcpGroups = groups.filter((g) => g.kind === 'mcp');
expect(mcpGroups.length).toBe(1);
expect(mcpGroups[0].tools.length).toBe(0);
const count = countApprovedToolsInGroups(mcpGroups, approved);
expect(count).toBe(1);
});
test('returns 0 when nothing is approved', () => {
const tooling = makeTooling([
makeMcpServer('git', 'Git MCP', ['git.status']),
]);
const tools = listApprovalToolDefinitions(tooling);
const groups = groupApprovalToolsByProvider(tools, tooling);
const approved = new Set<string>();
const count = countApprovedToolsInGroups(groups, approved);
expect(count).toBe(0);
});
});
+1
View File
@@ -2,6 +2,7 @@ import { defineConfig } from 'astro/config';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
site: 'https://aryx.app',
vite: {
plugins: [tailwindcss()],
},
+72
View File
@@ -9,6 +9,10 @@
"astro": "^5.7.10",
"tailwindcss": "^4.1.4",
},
"devDependencies": {
"@resvg/resvg-js": "^2.6.2",
"satori": "^0.26.0",
},
},
},
"packages": {
@@ -148,6 +152,32 @@
"@oslojs/encoding": ["@oslojs/encoding@1.1.0", "", {}, "sha512-70wQhgYmndg4GCPxPPxPGevRKqTIJ2Nh4OkiMWmDAVYsTQ+Ta7Sq+rPevXyXGdzr30/qZBnyOalCszoMxlyldQ=="],
"@resvg/resvg-js": ["@resvg/resvg-js@2.6.2", "", { "optionalDependencies": { "@resvg/resvg-js-android-arm-eabi": "2.6.2", "@resvg/resvg-js-android-arm64": "2.6.2", "@resvg/resvg-js-darwin-arm64": "2.6.2", "@resvg/resvg-js-darwin-x64": "2.6.2", "@resvg/resvg-js-linux-arm-gnueabihf": "2.6.2", "@resvg/resvg-js-linux-arm64-gnu": "2.6.2", "@resvg/resvg-js-linux-arm64-musl": "2.6.2", "@resvg/resvg-js-linux-x64-gnu": "2.6.2", "@resvg/resvg-js-linux-x64-musl": "2.6.2", "@resvg/resvg-js-win32-arm64-msvc": "2.6.2", "@resvg/resvg-js-win32-ia32-msvc": "2.6.2", "@resvg/resvg-js-win32-x64-msvc": "2.6.2" } }, "sha512-xBaJish5OeGmniDj9cW5PRa/PtmuVU3ziqrbr5xJj901ZDN4TosrVaNZpEiLZAxdfnhAe7uQ7QFWfjPe9d9K2Q=="],
"@resvg/resvg-js-android-arm-eabi": ["@resvg/resvg-js-android-arm-eabi@2.6.2", "", { "os": "android", "cpu": "arm" }, "sha512-FrJibrAk6v29eabIPgcTUMPXiEz8ssrAk7TXxsiZzww9UTQ1Z5KAbFJs+Z0Ez+VZTYgnE5IQJqBcoSiMebtPHA=="],
"@resvg/resvg-js-android-arm64": ["@resvg/resvg-js-android-arm64@2.6.2", "", { "os": "android", "cpu": "arm64" }, "sha512-VcOKezEhm2VqzXpcIJoITuvUS/fcjIw5NA/w3tjzWyzmvoCdd+QXIqy3FBGulWdClvp4g+IfUemigrkLThSjAQ=="],
"@resvg/resvg-js-darwin-arm64": ["@resvg/resvg-js-darwin-arm64@2.6.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-nmok2LnAd6nLUKI16aEB9ydMC6Lidiiq2m1nEBDR1LaaP7FGs4AJ90qDraxX+CWlVuRlvNjyYJTNv8qFjtL9+A=="],
"@resvg/resvg-js-darwin-x64": ["@resvg/resvg-js-darwin-x64@2.6.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-GInyZLjgWDfsVT6+SHxQVRwNzV0AuA1uqGsOAW+0th56J7Nh6bHHKXHBWzUrihxMetcFDmQMAX1tZ1fZDYSRsw=="],
"@resvg/resvg-js-linux-arm-gnueabihf": ["@resvg/resvg-js-linux-arm-gnueabihf@2.6.2", "", { "os": "linux", "cpu": "arm" }, "sha512-YIV3u/R9zJbpqTTNwTZM5/ocWetDKGsro0SWp70eGEM9eV2MerWyBRZnQIgzU3YBnSBQ1RcxRZvY/UxwESfZIw=="],
"@resvg/resvg-js-linux-arm64-gnu": ["@resvg/resvg-js-linux-arm64-gnu@2.6.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-zc2BlJSim7YR4FZDQ8OUoJg5holYzdiYMeobb9pJuGDidGL9KZUv7SbiD4E8oZogtYY42UZEap7dqkkYuA91pg=="],
"@resvg/resvg-js-linux-arm64-musl": ["@resvg/resvg-js-linux-arm64-musl@2.6.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-3h3dLPWNgSsD4lQBJPb4f+kvdOSJHa5PjTYVsWHxLUzH4IFTJUAnmuWpw4KqyQ3NA5QCyhw4TWgxk3jRkQxEKg=="],
"@resvg/resvg-js-linux-x64-gnu": ["@resvg/resvg-js-linux-x64-gnu@2.6.2", "", { "os": "linux", "cpu": "x64" }, "sha512-IVUe+ckIerA7xMZ50duAZzwf1U7khQe2E0QpUxu5MBJNao5RqC0zwV/Zm965vw6D3gGFUl7j4m+oJjubBVoftw=="],
"@resvg/resvg-js-linux-x64-musl": ["@resvg/resvg-js-linux-x64-musl@2.6.2", "", { "os": "linux", "cpu": "x64" }, "sha512-UOf83vqTzoYQO9SZ0fPl2ZIFtNIz/Rr/y+7X8XRX1ZnBYsQ/tTb+cj9TE+KHOdmlTFBxhYzVkP2lRByCzqi4jQ=="],
"@resvg/resvg-js-win32-arm64-msvc": ["@resvg/resvg-js-win32-arm64-msvc@2.6.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-7C/RSgCa+7vqZ7qAbItfiaAWhyRSoD4l4BQAbVDqRRsRgY+S+hgS3in0Rxr7IorKUpGE69X48q6/nOAuTJQxeQ=="],
"@resvg/resvg-js-win32-ia32-msvc": ["@resvg/resvg-js-win32-ia32-msvc@2.6.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-har4aPAlvjnLcil40AC77YDIk6loMawuJwFINEM7n0pZviwMkMvjb2W5ZirsNOZY4aDbo5tLx0wNMREp5Brk+w=="],
"@resvg/resvg-js-win32-x64-msvc": ["@resvg/resvg-js-win32-x64-msvc@2.6.2", "", { "os": "win32", "cpu": "x64" }, "sha512-ZXtYhtUr5SSaBrUDq7DiyjOFJqBVL/dOBN7N/qmi/pO0IgiWW/f/ue3nbvu9joWE5aAKDoIzy/CxsY0suwGosQ=="],
"@rollup/pluginutils": ["@rollup/pluginutils@5.3.0", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q=="],
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.60.0", "", { "os": "android", "cpu": "arm" }, "sha512-WOhNW9K8bR3kf4zLxbfg6Pxu2ybOUbB2AjMDHSQx86LIF4rH4Ft7vmMwNt0loO0eonglSNy4cpD3MKXXKQu0/A=="],
@@ -214,6 +244,8 @@
"@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.0.2", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="],
"@shuding/opentype.js": ["@shuding/opentype.js@1.4.0-beta.0", "", { "dependencies": { "fflate": "^0.7.3", "string.prototype.codepointat": "^0.2.1" }, "bin": { "ot": "bin/ot" } }, "sha512-3NgmNyH3l/Hv6EvsWJbsvpcpUba6R8IREQ83nH83cyakCw7uM1arZKNfHwv1Wz6jgqrF/j4x5ELvR6PnK9nTcA=="],
"@tailwindcss/node": ["@tailwindcss/node@4.2.2", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.19.0", "jiti": "^2.6.1", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.2.2" } }, "sha512-pXS+wJ2gZpVXqFaUEjojq7jzMpTGf8rU6ipJz5ovJV6PUGmlJ+jvIwGrzdHdQ80Sg+wmQxUFuoW1UAAwHNEdFA=="],
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.2.2", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.2.2", "@tailwindcss/oxide-darwin-arm64": "4.2.2", "@tailwindcss/oxide-darwin-x64": "4.2.2", "@tailwindcss/oxide-freebsd-x64": "4.2.2", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.2.2", "@tailwindcss/oxide-linux-arm64-gnu": "4.2.2", "@tailwindcss/oxide-linux-arm64-musl": "4.2.2", "@tailwindcss/oxide-linux-x64-gnu": "4.2.2", "@tailwindcss/oxide-linux-x64-musl": "4.2.2", "@tailwindcss/oxide-wasm32-wasi": "4.2.2", "@tailwindcss/oxide-win32-arm64-msvc": "4.2.2", "@tailwindcss/oxide-win32-x64-msvc": "4.2.2" } }, "sha512-qEUA07+E5kehxYp9BVMpq9E8vnJuBHfJEC0vPC5e7iL/hw7HR61aDKoVoKzrG+QKp56vhNZe4qwkRmMC0zDLvg=="],
@@ -284,12 +316,16 @@
"base-64": ["base-64@1.0.0", "", {}, "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="],
"base64-js": ["base64-js@0.0.8", "", {}, "sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw=="],
"boolbase": ["boolbase@1.0.0", "", {}, "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="],
"boxen": ["boxen@8.0.1", "", { "dependencies": { "ansi-align": "^3.0.1", "camelcase": "^8.0.0", "chalk": "^5.3.0", "cli-boxes": "^3.0.0", "string-width": "^7.2.0", "type-fest": "^4.21.0", "widest-line": "^5.0.0", "wrap-ansi": "^9.0.0" } }, "sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw=="],
"camelcase": ["camelcase@8.0.0", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],
"camelize": ["camelize@1.0.1", "", {}, "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ=="],
"ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
"chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
@@ -308,6 +344,8 @@
"clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
"color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
"comma-separated-tokens": ["comma-separated-tokens@2.0.3", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
"commander": ["commander@11.1.0", "", {}, "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ=="],
@@ -320,8 +358,18 @@
"crossws": ["crossws@0.3.5", "", { "dependencies": { "uncrypto": "^0.1.3" } }, "sha512-ojKiDvcmByhwa8YYqbQI/hg7MEU0NC03+pSdEq4ZUnZR9xXpwk7E43SMNGkn+JxJGPFtNvQ48+vV2p+P1ml5PA=="],
"css-background-parser": ["css-background-parser@0.1.0", "", {}, "sha512-2EZLisiZQ+7m4wwur/qiYJRniHX4K5Tc9w93MT3AS0WS1u5kaZ4FKXlOTBhOjc+CgEgPiGY+fX1yWD8UwpEqUA=="],
"css-box-shadow": ["css-box-shadow@1.0.0-3", "", {}, "sha512-9jaqR6e7Ohds+aWwmhe6wILJ99xYQbfmK9QQB9CcMjDbTxPZjwEmUQpU91OG05Xgm8BahT5fW+svbsQGjS/zPg=="],
"css-color-keywords": ["css-color-keywords@1.0.0", "", {}, "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg=="],
"css-gradient-parser": ["css-gradient-parser@0.0.17", "", {}, "sha512-w2Xy9UMMwlKtou0vlRnXvWglPAceXCTtcmVSo8ZBUvqCV5aXEFP/PC6d+I464810I9FT++UACwTD5511bmGPUg=="],
"css-select": ["css-select@5.2.2", "", { "dependencies": { "boolbase": "^1.0.0", "css-what": "^6.1.0", "domhandler": "^5.0.2", "domutils": "^3.0.1", "nth-check": "^2.0.1" } }, "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw=="],
"css-to-react-native": ["css-to-react-native@3.2.0", "", { "dependencies": { "camelize": "^1.0.0", "css-color-keywords": "^1.0.0", "postcss-value-parser": "^4.0.2" } }, "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ=="],
"css-tree": ["css-tree@3.2.1", "", { "dependencies": { "mdn-data": "2.27.1", "source-map-js": "^1.2.1" } }, "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA=="],
"css-what": ["css-what@6.2.2", "", {}, "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA=="],
@@ -364,6 +412,8 @@
"emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="],
"emoji-regex-xs": ["emoji-regex-xs@2.0.1", "", {}, "sha512-1QFuh8l7LqUcKe24LsPUNzjrzJQ7pgRwp1QMcZ5MX6mFplk2zQ08NVCM84++1cveaUUYtcCYHmeFEuNg16sU4g=="],
"enhanced-resolve": ["enhanced-resolve@5.20.1", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-Qohcme7V1inbAfvjItgw0EaxVX5q2rdVEZHRBrEQdRZTssLDGsL8Lwrznl8oQ/6kuTJONLaDcGjkNP247XEhcA=="],
"entities": ["entities@6.0.1", "", {}, "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g=="],
@@ -372,6 +422,8 @@
"esbuild": ["esbuild@0.27.4", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.4", "@esbuild/android-arm": "0.27.4", "@esbuild/android-arm64": "0.27.4", "@esbuild/android-x64": "0.27.4", "@esbuild/darwin-arm64": "0.27.4", "@esbuild/darwin-x64": "0.27.4", "@esbuild/freebsd-arm64": "0.27.4", "@esbuild/freebsd-x64": "0.27.4", "@esbuild/linux-arm": "0.27.4", "@esbuild/linux-arm64": "0.27.4", "@esbuild/linux-ia32": "0.27.4", "@esbuild/linux-loong64": "0.27.4", "@esbuild/linux-mips64el": "0.27.4", "@esbuild/linux-ppc64": "0.27.4", "@esbuild/linux-riscv64": "0.27.4", "@esbuild/linux-s390x": "0.27.4", "@esbuild/linux-x64": "0.27.4", "@esbuild/netbsd-arm64": "0.27.4", "@esbuild/netbsd-x64": "0.27.4", "@esbuild/openbsd-arm64": "0.27.4", "@esbuild/openbsd-x64": "0.27.4", "@esbuild/openharmony-arm64": "0.27.4", "@esbuild/sunos-x64": "0.27.4", "@esbuild/win32-arm64": "0.27.4", "@esbuild/win32-ia32": "0.27.4", "@esbuild/win32-x64": "0.27.4" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ=="],
"escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="],
"escape-string-regexp": ["escape-string-regexp@5.0.0", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
"estree-walker": ["estree-walker@3.0.3", "", { "dependencies": { "@types/estree": "^1.0.0" } }, "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g=="],
@@ -382,6 +434,8 @@
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
"fflate": ["fflate@0.7.4", "", {}, "sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw=="],
"flattie": ["flattie@1.1.1", "", {}, "sha512-9UbaD6XdAL97+k/n+N7JwX46K/M6Zc6KcFYskrYL8wbBV/Uyk0CTAMY0VT+qiK5PM7AIc9aTWYtq65U7T+aCNQ=="],
"fontace": ["fontace@0.4.1", "", { "dependencies": { "fontkitten": "^1.0.2" } }, "sha512-lDMvbAzSnHmbYMTEld5qdtvNH2/pWpICOqpean9IgC7vUbUJc3k+k5Dokp85CegamqQpFbXf0rAVkbzpyTA8aw=="],
@@ -418,6 +472,8 @@
"hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="],
"hex-rgb": ["hex-rgb@4.3.0", "", {}, "sha512-Ox1pJVrDCyGHMG9CFg1tmrRUMRPRsAWYc/PinY0XzJU4K7y7vjNoLKIQ7BR5UJMCxNN8EM1MNDmHWA/B3aZUuw=="],
"html-escaper": ["html-escaper@3.0.3", "", {}, "sha512-RuMffC89BOWQoY0WKGpIhn5gX3iI54O6nRA0yC124NYVtzjmFWBIiFd8M0x+ZdX0P9R4lADg1mgP8C7PxGOWuQ=="],
"html-void-elements": ["html-void-elements@3.0.0", "", {}, "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="],
@@ -468,6 +524,8 @@
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.32.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q=="],
"linebreak": ["linebreak@1.1.0", "", { "dependencies": { "base64-js": "0.0.8", "unicode-trie": "^2.0.0" } }, "sha512-MHp03UImeVhB7XZtjd0E4n6+3xr5Dq/9xI/5FptGk5FrbDR3zagPa2DS6U8ks/3HjbKWG9Q1M2ufOzxV2qLYSQ=="],
"longest-streak": ["longest-streak@3.1.0", "", {}, "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g=="],
"lru-cache": ["lru-cache@11.2.7", "", {}, "sha512-aY/R+aEsRelme17KGQa/1ZSIpLpNYYrhcrepKTZgE+W3WM16YMCaPwOHLHsmopZHELU0Ojin1lPVxKR0MihncA=="],
@@ -596,6 +654,10 @@
"package-manager-detector": ["package-manager-detector@1.6.0", "", {}, "sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA=="],
"pako": ["pako@0.2.9", "", {}, "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="],
"parse-css-color": ["parse-css-color@0.2.1", "", { "dependencies": { "color-name": "^1.1.4", "hex-rgb": "^4.1.0" } }, "sha512-bwS/GGIFV3b6KS4uwpzCFj4w297Yl3uqnSgIPsoQkx7GMLROXfMnWvxfNkL0oh8HVhZA4hvJoEoEIqonfJ3BWg=="],
"parse-latin": ["parse-latin@7.0.0", "", { "dependencies": { "@types/nlcst": "^2.0.0", "@types/unist": "^3.0.0", "nlcst-to-string": "^4.0.0", "unist-util-modify-children": "^4.0.0", "unist-util-visit-children": "^3.0.0", "vfile": "^6.0.0" } }, "sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ=="],
"parse5": ["parse5@7.3.0", "", { "dependencies": { "entities": "^6.0.0" } }, "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw=="],
@@ -608,6 +670,8 @@
"postcss": ["postcss@8.5.8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
"postcss-value-parser": ["postcss-value-parser@4.2.0", "", {}, "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="],
"prismjs": ["prismjs@1.30.0", "", {}, "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw=="],
"prompts": ["prompts@2.4.2", "", { "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" } }, "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q=="],
@@ -652,6 +716,8 @@
"rollup": ["rollup@4.60.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.60.0", "@rollup/rollup-android-arm64": "4.60.0", "@rollup/rollup-darwin-arm64": "4.60.0", "@rollup/rollup-darwin-x64": "4.60.0", "@rollup/rollup-freebsd-arm64": "4.60.0", "@rollup/rollup-freebsd-x64": "4.60.0", "@rollup/rollup-linux-arm-gnueabihf": "4.60.0", "@rollup/rollup-linux-arm-musleabihf": "4.60.0", "@rollup/rollup-linux-arm64-gnu": "4.60.0", "@rollup/rollup-linux-arm64-musl": "4.60.0", "@rollup/rollup-linux-loong64-gnu": "4.60.0", "@rollup/rollup-linux-loong64-musl": "4.60.0", "@rollup/rollup-linux-ppc64-gnu": "4.60.0", "@rollup/rollup-linux-ppc64-musl": "4.60.0", "@rollup/rollup-linux-riscv64-gnu": "4.60.0", "@rollup/rollup-linux-riscv64-musl": "4.60.0", "@rollup/rollup-linux-s390x-gnu": "4.60.0", "@rollup/rollup-linux-x64-gnu": "4.60.0", "@rollup/rollup-linux-x64-musl": "4.60.0", "@rollup/rollup-openbsd-x64": "4.60.0", "@rollup/rollup-openharmony-arm64": "4.60.0", "@rollup/rollup-win32-arm64-msvc": "4.60.0", "@rollup/rollup-win32-ia32-msvc": "4.60.0", "@rollup/rollup-win32-x64-gnu": "4.60.0", "@rollup/rollup-win32-x64-msvc": "4.60.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-yqjxruMGBQJ2gG4HtjZtAfXArHomazDHoFwFFmZZl0r7Pdo7qCIXKqKHZc8yeoMgzJJ+pO6pEEHa+V7uzWlrAQ=="],
"satori": ["satori@0.26.0", "", { "dependencies": { "@shuding/opentype.js": "1.4.0-beta.0", "css-background-parser": "^0.1.0", "css-box-shadow": "1.0.0-3", "css-gradient-parser": "^0.0.17", "css-to-react-native": "^3.0.0", "emoji-regex-xs": "^2.0.1", "escape-html": "^1.0.3", "linebreak": "^1.1.0", "parse-css-color": "^0.2.1", "postcss-value-parser": "^4.2.0", "yoga-layout": "^3.2.1" } }, "sha512-tkMFrfIs3l2mQ2JEcyW0ADTy3zGggFRFzi6Ef8YozQSFsFKEqaSO1Y8F9wJg4//PJGQauMalHGTUEkPrFwhVPA=="],
"sax": ["sax@1.6.0", "", {}, "sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA=="],
"semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
@@ -670,6 +736,8 @@
"string-width": ["string-width@7.2.0", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
"string.prototype.codepointat": ["string.prototype.codepointat@0.2.1", "", {}, "sha512-2cBVCj6I4IOvEnjgO/hWqXjqBGsY+zwPmHl12Srk9IXSZ56Jwwmy+66XO5Iut/oQVR7t5ihYdLB0GMa4alEUcg=="],
"stringify-entities": ["stringify-entities@4.0.4", "", { "dependencies": { "character-entities-html4": "^2.0.0", "character-entities-legacy": "^3.0.0" } }, "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg=="],
"strip-ansi": ["strip-ansi@7.2.0", "", { "dependencies": { "ansi-regex": "^6.2.2" } }, "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w=="],
@@ -704,6 +772,8 @@
"uncrypto": ["uncrypto@0.1.3", "", {}, "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q=="],
"unicode-trie": ["unicode-trie@2.0.0", "", { "dependencies": { "pako": "^0.2.5", "tiny-inflate": "^1.0.0" } }, "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ=="],
"unified": ["unified@11.0.5", "", { "dependencies": { "@types/unist": "^3.0.0", "bail": "^2.0.0", "devlop": "^1.0.0", "extend": "^3.0.0", "is-plain-obj": "^4.0.0", "trough": "^2.0.0", "vfile": "^6.0.0" } }, "sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA=="],
"unifont": ["unifont@0.7.4", "", { "dependencies": { "css-tree": "^3.1.0", "ofetch": "^1.5.1", "ohash": "^2.0.11" } }, "sha512-oHeis4/xl42HUIeHuNZRGEvxj5AaIKR+bHPNegRq5LV1gdc3jundpONbjglKpihmJf+dswygdMJn3eftGIMemg=="],
@@ -758,6 +828,8 @@
"yoctocolors": ["yoctocolors@2.1.2", "", {}, "sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug=="],
"yoga-layout": ["yoga-layout@3.2.1", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="],
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
"zod-to-json-schema": ["zod-to-json-schema@3.25.1", "", { "peerDependencies": { "zod": "^3.25 || ^4" } }, "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA=="],
+6 -1
View File
@@ -5,12 +5,17 @@
"type": "module",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"generate:og": "bun run scripts/generate-og.ts",
"build": "bun run generate:og && astro build",
"preview": "astro preview"
},
"dependencies": {
"astro": "^5.7.10",
"@tailwindcss/vite": "^4.1.4",
"tailwindcss": "^4.1.4"
},
"devDependencies": {
"@resvg/resvg-js": "^2.6.2",
"satori": "^0.26.0"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 KiB

After

Width:  |  Height:  |  Size: 383 KiB

+313
View File
@@ -0,0 +1,313 @@
import satori from 'satori';
import { Resvg } from '@resvg/resvg-js';
import { readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
const scriptDir = import.meta.dir ?? fileURLToPath(new URL('.', import.meta.url));
const websiteDir = join(scriptDir, '..');
const fontUrls = {
instrumentSerif:
'https://fonts.gstatic.com/s/instrumentserif/v5/jizBRFtNs2ka5fXjeivQ4LroWlx-2zI.ttf',
outfit400:
'https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4TC1C4E.ttf',
outfit300:
'https://fonts.gstatic.com/s/outfit/v15/QGYyz_MVcBeNP4NjuGObqx1XmO1I4W61C4E.ttf',
};
const colors = {
deep: '#08080a',
border: '#2a2a34',
warm50: '#ede9e2',
warm300: '#a09a90',
brand: '#245CF9',
brandBright: '#248CFD',
accent: '#8A29E6',
};
type SatoriNode = string | SatoriElement;
interface SatoriElement {
type: string;
props: Record<string, unknown> & { children?: SatoriNode | SatoriNode[] };
}
function toDataUri(filePath: string, mime: string): string {
return `data:${mime};base64,${readFileSync(filePath).toString('base64')}`;
}
function orb(
top: number | undefined,
bottom: number | undefined,
left: number | undefined,
right: number | undefined,
size: number,
color: string,
opacity: number,
spread = 0.7,
): SatoriElement {
return {
type: 'div',
props: {
style: {
position: 'absolute',
...(top !== undefined && { top }),
...(bottom !== undefined && { bottom }),
...(left !== undefined && { left }),
...(right !== undefined && { right }),
width: size,
height: size,
borderRadius: '50%',
background: `radial-gradient(circle, ${color.replace(')', `,${opacity})`).replace('rgb', 'rgba')} 0%, ${color.replace(')', ',0.02)').replace('rgb', 'rgba')} ${spread * 100}%, transparent 100%)`,
},
},
};
}
function dot(top: number, left: number, size: number, color: string): SatoriElement {
return {
type: 'div',
props: {
style: {
position: 'absolute',
top,
left,
width: size,
height: size,
borderRadius: '50%',
backgroundColor: color,
},
},
};
}
async function generate() {
console.log('Generating OG image…');
const [instrumentSerif, outfit400, outfit300] = await Promise.all(
Object.values(fontUrls).map((url) => fetch(url).then((r) => r.arrayBuffer())),
);
const logoUri = toDataUri(join(websiteDir, 'public', 'images', 'logo.png'), 'image/png');
const element: SatoriElement = {
type: 'div',
props: {
style: {
display: 'flex',
width: 1200,
height: 630,
backgroundColor: colors.deep,
position: 'relative',
overflow: 'hidden',
},
children: [
// ── Background ambient glows (subtle, behind everything) ──
orb(-120, undefined, 60, undefined, 500, 'rgb(36,92,249)', 0.07, 0.65),
orb(undefined, -80, undefined, 200, 450, 'rgb(138,41,230)', 0.05, 0.6),
// ── Top gradient accent bar ──
{
type: 'div',
props: {
style: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
height: 4,
background: `linear-gradient(90deg, ${colors.brand}, ${colors.accent})`,
},
},
},
// ── Main content ──
{
type: 'div',
props: {
style: {
display: 'flex',
flexDirection: 'row' as const,
width: '100%',
height: '100%',
padding: '0 80px',
alignItems: 'center',
},
children: [
// Left column — text
{
type: 'div',
props: {
style: {
display: 'flex',
flexDirection: 'column' as const,
flex: 1,
justifyContent: 'center',
},
children: [
// Logo
{
type: 'img',
props: {
src: logoUri,
width: 56,
height: 56,
style: { borderRadius: 14 },
},
},
// Product name
{
type: 'div',
props: {
style: {
fontFamily: 'Instrument Serif',
fontSize: 76,
color: colors.warm50,
marginTop: 24,
lineHeight: 1,
letterSpacing: -1,
},
children: 'Aryx',
},
},
// Tagline
{
type: 'div',
props: {
style: {
display: 'flex',
flexWrap: 'wrap' as const,
fontFamily: 'Outfit',
fontSize: 26,
fontWeight: 300,
color: colors.warm300,
marginTop: 18,
lineHeight: 1.45,
},
children: [
'Your control room for ',
{
type: 'span',
props: {
style: { color: colors.brand },
children: 'Copilot-powered',
},
},
' work',
],
},
},
// Badge pill
{
type: 'div',
props: {
style: {
display: 'flex',
alignItems: 'center',
gap: 8,
marginTop: 30,
fontFamily: 'Outfit',
fontSize: 14,
color: colors.brand,
border: '1px solid rgba(36,92,249,0.2)',
background: 'rgba(36,92,249,0.06)',
borderRadius: 100,
padding: '7px 16px',
alignSelf: 'flex-start',
},
children: [
{
type: 'div',
props: {
style: {
width: 6,
height: 6,
borderRadius: '50%',
backgroundColor: colors.brand,
},
},
},
'Desktop AI Workspace',
],
},
},
],
},
},
],
},
},
// ── Decorative orbs (right side) ──
// Large blue orb
orb(40, undefined, undefined, 40, 380, 'rgb(36,92,249)', 0.22, 0.55),
// Large purple orb (overlapping)
orb(undefined, 20, undefined, -40, 340, 'rgb(138,41,230)', 0.18, 0.5),
// Bright blue accent orb
orb(180, undefined, undefined, 220, 140, 'rgb(36,140,253)', 0.3, 0.5),
// ── Thin ring ──
{
type: 'div',
props: {
style: {
position: 'absolute',
top: 100,
right: 80,
width: 240,
height: 240,
borderRadius: '50%',
border: '1px solid rgba(36,92,249,0.12)',
},
},
},
// Smaller ring
{
type: 'div',
props: {
style: {
position: 'absolute',
bottom: 80,
right: 160,
width: 160,
height: 160,
borderRadius: '50%',
border: '1px solid rgba(138,41,230,0.10)',
},
},
},
// ── Accent dots ──
dot(140, 820, 8, 'rgba(36,92,249,0.4)'),
dot(340, 950, 6, 'rgba(138,41,230,0.35)'),
dot(480, 780, 5, 'rgba(36,140,253,0.3)'),
dot(200, 1050, 4, 'rgba(36,92,249,0.25)'),
dot(100, 1100, 7, 'rgba(138,41,230,0.2)'),
],
},
};
const svg = await satori(element, {
width: 1200,
height: 630,
fonts: [
{ name: 'Instrument Serif', data: instrumentSerif, weight: 400, style: 'normal' as const },
{ name: 'Outfit', data: outfit400, weight: 400, style: 'normal' as const },
{ name: 'Outfit', data: outfit300, weight: 300, style: 'normal' as const },
],
});
const resvg = new Resvg(svg, { fitTo: { mode: 'width', value: 1200 } });
const png = resvg.render().asPng();
const outputPath = join(websiteDir, 'public', 'images', 'og.png');
writeFileSync(outputPath, png);
const sizeKb = (png.length / 1024).toFixed(1);
console.log(`✓ OG image generated → public/images/og.png (${sizeKb} KB)`);
}
generate().catch((err) => {
console.error('Failed to generate OG image:', err);
process.exit(1);
});
+94 -1
View File
@@ -23,11 +23,15 @@ const {
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content="/images/logo.png" />
<meta property="og:image" content={`${Astro.site}images/og.png`} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:url" content={Astro.url.href} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta name="twitter:image" content={`${Astro.site}images/og.png`} />
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
@@ -38,6 +42,15 @@ const {
/>
<title>{title}</title>
<!-- Theme init (FOUC prevention) -->
<script is:inline>
(function () {
var saved = localStorage.getItem('theme');
var theme = saved || (matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark');
if (theme === 'light') document.documentElement.setAttribute('data-theme', 'light');
})();
</script>
</head>
<body class="min-h-screen bg-deep font-body text-warm-100 antialiased">
<!-- Navigation -->
@@ -59,6 +72,19 @@ const {
<a href="#get-started" class="text-sm text-warm-400 transition hover:text-warm-50"
>Get Started</a
>
<button
class="theme-toggle"
id="theme-toggle-desktop"
type="button"
aria-label="Switch to light theme"
>
<svg class="icon-sun" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
</svg>
<svg class="icon-moon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
</svg>
</button>
<a
href="https://github.com/davidkaya/aryx"
target="_blank"
@@ -104,6 +130,19 @@ const {
rel="noopener noreferrer"
class="text-sm text-warm-400 transition hover:text-warm-50">GitHub</a
>
<button
class="theme-toggle self-start"
id="theme-toggle-mobile"
type="button"
aria-label="Switch to light theme"
>
<svg class="icon-sun" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
</svg>
<svg class="icon-moon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
</svg>
</button>
</div>
</div>
</nav>
@@ -159,6 +198,10 @@ const {
</svg>
<span>by Dávid Kaya.</span>
</div>
<p class="mt-4 text-center text-[11px] leading-relaxed text-warm-700">
GitHub and GitHub Copilot are trademarks of Microsoft Corporation.<br />
Aryx is an independent project, not affiliated with or endorsed by Microsoft or GitHub.
</p>
</div>
</footer>
@@ -177,5 +220,55 @@ const {
);
document.querySelectorAll('[data-reveal]').forEach((el) => observer.observe(el));
</script>
<!-- Theme toggle + screenshot swap -->
<script>
function getTheme() {
return document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
}
function applyTheme(theme) {
if (theme === 'light') {
document.documentElement.setAttribute('data-theme', 'light');
} else {
document.documentElement.removeAttribute('data-theme');
}
localStorage.setItem('theme', theme);
// Update meta theme-color
var meta = document.querySelector('meta[name="theme-color"]');
if (meta) meta.setAttribute('content', theme === 'light' ? '#f6f4f1' : '#08080a');
// Update aria-labels
var label = theme === 'light' ? 'Switch to dark theme' : 'Switch to light theme';
document.querySelectorAll('.theme-toggle').forEach(function (btn) {
btn.setAttribute('aria-label', label);
});
// Swap themed images
document.querySelectorAll('[data-src-dark]').forEach(function (img) {
img.setAttribute('src', theme === 'light' ? img.getAttribute('data-src-light') : img.getAttribute('data-src-dark'));
});
}
function toggleTheme() {
applyTheme(getTheme() === 'light' ? 'dark' : 'light');
}
// Bind toggle buttons
document.querySelectorAll('.theme-toggle').forEach(function (btn) {
btn.addEventListener('click', toggleTheme);
});
// Apply on load (screenshots + aria)
applyTheme(getTheme());
// Listen for system preference changes
matchMedia('(prefers-color-scheme: light)').addEventListener('change', function (e) {
if (!localStorage.getItem('theme')) {
applyTheme(e.matches ? 'light' : 'dark');
}
});
</script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More