Commit Graph
455 Commits
Author SHA1 Message Date
Chris Scott 9cbe7870b2 fix(sidebar): wire new-session and new-schedule actions to every page
AssistantRedirect never registered a listener for the sidebar's
new-session event, so the desktop sidebar CTA on /assistant was a
no-op; the Schedules pages had the same gap for new-schedule.

Make useSidebarAction the single source of truth for action keys and
event dispatch, and warn when an action is dispatched with no mounted
handler so an unhandled CTA fails loudly instead of silently. Wire the
missing listeners to the existing per-page handlers.
2026-08-25 10:22:51 -04:00
Chris Scott 098816f7cc refactor(sandbox): pin shell shim to sandbox agent bash without rewriting commands 2026-08-23 14:02:31 -04:00
Chris Scott 681181ef4c feat(sandbox): show unwrapped sandboxed bash commands in message UI 2026-08-23 12:38:33 -04:00
Chris Scott cadc283738 fix(sandbox): plan bash against factory directory and attest runtime tmpfs; align permission reply API 2026-08-22 19:31:39 -04:00
Chris Scott aab80f9d65 refactor(sandbox): remove OpenCode version allowlist gating under enforcement 2026-08-22 13:03:07 -04:00
Chris Scott ae117d6a78 feat(sandbox): route host-shell surfaces into microVM via shell wrapper 2026-08-14 18:26:21 -04:00
Chris Scott aa3fb48a62 feat(sandbox): add KVM-backed agent sandboxing via microsandbox 2026-08-13 16:14:16 -04:00
f7b47e6345 fix(repos): parse and preserve custom-user SSH remotes (#337)
* fix(repos): parse and preserve custom-user SSH remotes

SSH remotes with a non-git user (e.g. company@company.ghe.com:orga/repo.git)
were misparsed as GitHub shorthand and stored as
https://github.com/company@company.ghe.com:orga/repo. The scp-style matcher
hardcoded the git@ user, so custom-user remotes fell through to the
owner/repo shorthand branch.

SSH URL parsing is now unified in shared/utils/repo.ts and applied across
backend and frontend: any user@host:path remote is detected, preserved, and
deduplicated correctly. The compare key also converges the scp-with-port and
ssh:// spellings, strips embedded credentials, and fails closed on malformed
host segments.

* fix: apply CodeRabbit auto-fixes

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
2026-08-10 20:41:04 -04:00
Chris Scott cfe2031c04 fix(schedules): submit scheduled runs via prompt_async with SSE monitoring (#335)
* fix(schedules): submit scheduled runs via prompt_async with SSE monitoring

* fix(session): use session directory for SSE and queries when it differs from repo path
2026-08-10 10:42:35 -04:00
Chris Scott 1666d0de8f fix(session): keep cached session agent/model stable during message refetch (#333) 2026-08-07 18:16:45 -04:00
Chris Scott 46888b9723 fix(frontend): show feedback and restrict types for prompt file uploads 2026-08-03 11:15:46 -04:00
Chris Scott ba8994eb61 Simplify OpenCode upgrade to always restart and refresh version 2026-07-30 23:30:15 -04:00
Alexander DrewekeandChris Scott eac09090c6 Fix question prompt not rendering for active session (#325)
* Fix question prompt not rendering for active session

currentQuestion was the first pending question globally across all
sessions. When another session had the first question in the flat list,
the QuestionPrompt would not render for the session being viewed even
though it had its own pending question.

Add getForSession() to the questions context and use it in
SessionDetail to look up questions scoped to the current session.

* test(frontend): cover session-scoped question prompt resolution

The SessionDetail useQuestions mocks did not expose getForSession, so
every page test threw on the new session-scoped lookup. Add it to each
mock and lock in the behaviour with regression coverage: the context
helper resolves questions per session while another session owns the
global current question, and SessionDetail renders the prompt for the
session being viewed.

---------

Co-authored-by: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
2026-07-28 19:32:45 -04:00
Chris Scott 29f154a9c3 fix(oauth,settings): forward upstream oauth error contract and persist recovered config (#331)
* fix(oauth): forward upstream error categories to clients

The route boundary collapsed every upstream OAuth failure into a single
generic message, leaving all six mappings in the frontend's mapOAuthError
unreachable. Classify the failure and forward the matched category so
clients surface specific guidance.

Hoist the category list into @opencode-manager/shared as the single source
of truth for both sides; the frontend map is now typed
Record<OAuthErrorCategory, string> so a missing message fails typecheck.

* fix(oauth): match upstream provider auth errors by type instead of substrings

The previous mapping matched invented substrings ("invalid code", "expired",
"access denied", ...) that opencode never emits, so every real failure fell
through to the generic message and left the frontend map unreachable. It also
returned 500 for what upstream reports as 400.

opencode serialises these failures as a structured contract: ProviderAuthError
({ name, data }) or InvalidRequestError ({ _tag, message }) at HTTP 400. Model
both shapes in shared, discriminate on name/_tag, and forward the exact code
plus upstream detail so clients can map errors precisely.

Pin the contract to upstream with a compile-time conformance assertion against
@opencode-ai/sdk's generated ProviderOauthAuthorizeErrors[400] and
ProviderOauthCallbackErrors[400], added as a type-only devDependency. Any
added, removed, renamed, or retyped upstream variant now fails typecheck.

Also stop discarding the structured error at the frontend boundary, where
handleApiError rewrapped FetchError in a bare Error and dropped the code that
fetchWrapper had already parsed.

Verified against a live opencode 1.18.7 server: callback without a pending
authorization returns 400 ProviderAuthOauthMissing and is now forwarded as
such. Tests are pinned to captured responses, including the multiline message
BadRequest carries.

* fix(settings): persist recovered OpenCode config and accept provider api/npm fields

Applying a default config with auto-removed fields wrote the stripped content
to disk but left the stored record holding the rejected fields, so the database
and the on-disk config disagreed until the next write. Persist the applied
content and return 409 when the config disappears mid-recovery.

Add the provider-level api, npm, whitelist, and blacklist fields so valid
opencode provider configs survive a parse round-trip instead of being stripped.
2026-07-28 12:17:24 -04:00
Chris Scott a73ac19bbc feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard (#326)
* feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard

* refactor: remove retry-clone flow and share destructive-confirm dialog

Backend drops POST /:id/retry-clone and the supporting retryCloneRepo service
and claimRepoForRetry query; failed clones now delete the repo row rather than
lingering in error state. Frontend extracts ConfirmDestructiveDialog shared by
Delete/Discard/UnsavedChanges dialogs, memoizes CodeEditor rows, fixes scroll
jump while typing away from the active match, and aligns the responsive
breakpoint to 768px.
2026-07-27 16:46:12 -04:00
Alexander DrewekeandChris Scott f8e361c0b8 feat(repo): add graphical folder picker for adding local repositories (#324)
* feat(repo): add graphical folder picker for adding local repositories

Previously, adding a local repository or scanning a folder in the
"Add Repository" dialog required typing an absolute filesystem path by
hand. This adds a navigable directory browser so users can select a
folder graphically instead.

Backend
- New shared Zod schemas (DirectoryEntry, BrowseDirectoryResponse,
  BrowseDirectoryRequest) exported via shared/types and shared/schemas.
- New env var REPO_BROWSE_ROOT plus getBrowseRootPath() helper. It is
  intentionally NOT defaulted to WORKSPACE_PATH: folder browsing is
  opt-in and only works when an administrator explicitly configures a
  root directory.
- New filesystem service (browseDirectory) that lists only directories
  (hidden entries filtered), flags Git repositories, and confines all
  access to the configured root:
    - 501 when REPO_BROWSE_ROOT is not configured
    - 403 on path traversal outside the root
    - 404 for missing directories, 400 when the target is a file
- New authenticated route GET /api/filesystem/browse, registered under
  the protected API group.

Frontend
- New api client browseDirectory() (uses fetchWrapper, so auth cookies
  are sent).
- New DirectoryPickerDialog: navigate into subfolders, go up a level,
  Git repos marked with an icon, and a "Select This Folder" action.
  Retries are disabled so a configuration error is not polled
  repeatedly.
- When browsing is disabled (501), the dialog shows a clear, actionable
  message telling the user to set REPO_BROWSE_ROOT and to enter the
  path manually in the meantime, instead of a generic error.
- AddRepoDialog gains a "Browse" button next to both the Local and
  Folder path inputs; the chosen path is written back into the active
  field.

Tests
- Service and route tests covering listing, Git-repo detection, hidden
  filtering, parent navigation, and the 400/403/404/501 error paths.

Security note: because there is no default root, the picker is inert
until REPO_BROWSE_ROOT is set, and it can never escape that root.

* fix(fs): reject symlink escapes in directory browse

Canonicalize root and requested path with fs.realpath() and gate on
path.relative() so symlinks inside REPO_BROWSE_ROOT pointing outside
are rejected with 403 before fs.stat/fs.readdir follow them. Handles
root '/' correctly. Adds regression test for symlink escape.

* fix(ui): make directory picker fill dialog height

Replace grid content-start packing with explicit grid-rows tracks so
the directory list grows to fill the dialog and scrolls while the
header, path, and footer stay fixed. Drops the ineffective flex-1
from the grid child on the scroll container.

---------

Co-authored-by: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com>
2026-07-26 21:12:13 -04:00
Chris Scott 8d5102dc90 fix(source-control): invalidate branches cache after fetch and pull 2026-07-24 09:17:59 -04:00
Chris Scott f20d8ffb71 fix(frontend): add crypto.randomUUID fallback for non-secure contexts (#318)
Introduce a shared randomId() helper in frontend/src/lib/utils that uses
crypto.randomUUID when available and falls back to a unique id for
non-secure contexts (e.g. HTTP origins where Web Crypto is unavailable).
Replace the inline id generator in PromptInput and the direct
crypto.randomUUID call in GitSettings ensureCredentialId with this shared
helper so git credential save no longer throws in non-secure contexts.

- utils: add randomId() with crypto.randomUUID fallback
- PromptInput: replace local generateId with randomId for image attachment ids
- GitSettings: use randomId in ensureCredentialId
- Add unit tests for randomId covering both code paths
2026-07-23 22:51:41 -04:00
Chris Scott 8a8bdc18b0 fix(session): handle 404 with not-found fallbacks and add SSE-gated message polling (#316) 2026-07-23 09:40:12 -04:00
Chris Scott 632ce132bb fix(frontend): stabilize ScheduleJobDialog render loop and improve accessibility (#315)
Resolve a "Maximum update depth exceeded" render loop in ScheduleJobDialog
while prompt templates are loading, and add accessibility labels across the
frontend. Also unregister the service worker in dev to avoid stale caches.

- ScheduleJobDialog: use a stable EMPTY_TEMPLATES constant and split template
  matching into its own effect keyed on [templates, job, open] instead of
  running inside the init effect that depends on templates
- Add ScheduleJobDialog.loading.test.tsx regression test for the loading state
- serviceWorker: unregister existing registrations and clear caches in DEV so
  stale workers do not serve outdated assets locally
- App: replace shell div with semantic <main>
- SettingsDialog: add sr-only DialogTitle for screen readers
- Add aria-labels to icon-only buttons in back-button, combobox, header,
  GlobalSchedules, and Repos
- index.html: add mobile-web-app-capable meta
2026-07-22 22:09:18 -04:00
Chris Scott 59fd516b75 fix(session): unify prompt sends on prompt_async and suppress stale network banners
Remove the long-lived synchronous POST to /session/{id}/message that produced
spurious "Connection Failed" banners on transient network blips; route every
send (normal, streaming-queue follow-up, message refresh) through prompt_async,
whose failure genuinely means not-delivered. Suppress network-kind banners
while SSE is disconnected or reconnecting (the header already shows that state);
session-kind banners still appear and reconcile clears confirmed prompts after
reconnect.
2026-07-20 23:45:46 -04:00
Chris Scott 446d425e2e chore: clean up test suite per audit recommendations (#299)
Executes recommendations from a comprehensive test suite audit.
Removes dead, redundant, and trivial tests; rewrites SessionDetail
polling test to exercise real gating; trims duplicated assertions;
adds missing assertion in assistant-loading tests.

13 files changed, 233 insertions(+), 462 deletions(-)
2026-06-30 19:24:53 -04:00
Chris Scott a9b6f7ce46 feat: add session pinning for pinned/recent session groups (#301)
* feat: add session pinning for pinned/recent session groups

* refactor: extract buildSessionKey, deduplicate SessionCard rendering, clean up pins on delete
2026-06-30 19:22:26 -04:00
Chris Scott 217f5bd989 feat: add server restart coordination and health status tracking (#300)
* feat: add server restart coordination and health status tracking

* refactor: consolidate server restart logic, extract hooks, remove dead code
2026-06-30 18:20:54 -04:00
Chris Scott 68cd6b5a0b feat: add schedule permission config and workspace tracking (#297)
* feat: add schedule permission config and workspace tracking

Adds permission configuration for scheduled jobs (migration 016) and
workspace ID tracking on schedule runs (migration 017). Includes
service logic, UI controls, schema updates, and full test coverage.

* refactor: convert permission ruleset to object format, exclude active schedule worktrees from sibling repos

* refine: reduce destructive bash patterns to host-level commands only
2026-06-30 12:03:35 -04:00
Chris Scott 59258625c0 feat: add schedule worktree isolation for running jobs in isolated worktrees (#295)
* feat: add schedule worktree isolation for running jobs in isolated worktrees

* feat: schedule worktree isolation for running jobs in isolated worktrees

* feat: show worktree/branch artifact counts in clear history confirmation

* feat: validate and select base branches for schedule worktrees
2026-06-29 11:15:39 -04:00
Chris Scott 6c13d78563 fix: reconcile confirmed prompt on message fetch to clear stale send errors (#296)
* fix: reconcile confirmed prompt on message fetch to clear stale send errors

* refactor: extract reconcileConfirmedPrompt into dedicated module
2026-06-28 20:28:34 -04:00
Chris Scott 29a1e8f808 refactor: simplify RenameRepoDialog styling and remove unused props 2026-06-28 15:07:42 -04:00
Chris Scott 6a4e8734f9 feat: add repo rename capability with custom name field (#294)
* feat: add repo rename capability with custom name field

Add a custom name field to repos, allowing users to set a display name
independent of the repo URL or path. Includes a migration, PATCH endpoint,
rename dialog, and display name consolidation.

- DB migration 014 adds name column to repos table
- PATCH /api/repos/:id endpoint with Zod validation
- RenameRepoDialog component with clear/reset support
- RepoRowActions gains Rename action in both dropdown and inline modes
- getRepoDisplayName() consolidated to accept a repo object and prefer name
- All repo name display call sites updated to use the new API

* fix: add DialogTitle to RenameRepoDialog for a11y compliance

* refactor: extract getRepoDisplayName to shared utils, fix schedule cache invalidation on rename
2026-06-28 14:49:00 -04:00
Chris Scott 01e50a7019 feat: add bundle-based OCM mirror sync (#289)
* feat: add bundle-based OCM mirror sync

* feat: add OpenCode model editor and HEAD-safe bundle import

* fix: consolidate discovery-cache, batch bundle refs, remove dead code (#290)

* fix: consolidate discovery-cache, batch bundle refs, remove dead code

* refactor: consolidate discovery cache into generic discoverCached, extract spawnGit helper

* feat: extract project-id-resolver, add CLI full-fallback prompt, wire lint into root scripts

- Extract shared project-id-resolver for origin URL matching (replaces local-repo duplicates)
- Add promptYesNo / confirmFullFallback to ocm CLI before slow full mirror
- Backend: consolidate opencode-workspaces routes with project-id-resolver
- Frontend: fix schedules prompt/global page navigation
- CLI: add eslint config, lint/lint:fix scripts, fix no-fallthrough in ocm.ts
- Root: wire CLI into build, test, typecheck, lint, lint:fix chains
- Fix test lint issues (_code, const, require→import)

* fix: replace polynomial regex with linear-time string ops in gitRemoteParts

* feat: add divergence guards for push/pull, streaming bundle upload, server-side ancestry check

- Backend: GET /:repoId/mirror/head (head+branch+dirty) and GET /:repoId/mirror/contains/:sha (ancestry check)
- CLI: checkPushDivergence warns before overwriting server commits; checkPullDivergence warns before discarding local commits; both require confirm or --force
- Bundle upload now streams from disk instead of buffering entire file in memory
- Version visible in --help and default (no-arg) output
- Version bump 0.1.5 → 0.2.0

* fix: show connecting message before fetching repos in default command

* fix: update default command messages to reflect actual matching behavior
2026-06-28 11:57:38 -04:00
Chris Scott bb1df259b6 fix: filter source control commits by branch (#286) 2026-06-27 09:36:03 -04:00
Chris Scott 8d93f2f1f9 fix: follow up prompt preservation changes (#292)
* fix: remove unused disabled prop, throttle SW update checks, precache icon

* fix: retract transient send error and restored prompt once server confirms send

When a long-running prompt request drops (gateway timeout or network error)
while the agent is actually working, the send error banner and the restored
prompt text were left in place. Tag send errors as 'network' and clear them
when the server confirms session activity (message.updated / session.idle),
also clearing the restored input text. Genuine server-reported session errors
(kind 'session') are preserved.

* style: restyle ErrorBanner with neutral card fill and destructive accent bar

Replace the all-red destructive Alert variant (transparent background, full
red text) with a neutral card-filled banner, a left destructive accent bar,
red icon, foreground title, and muted body/detail text. Improves the send-error
and git-error banners on the dark theme.
2026-06-27 09:26:37 -04:00
Chris Scott 71ba7371bc fix: allow saving edited PAT credential when reusing existing token 2026-06-21 09:25:48 -04:00
Chris Scott 55af93062a refactor: extract CredentialProvider service and consolidate git-auth utilities (#283)
* refactor: extract CredentialProvider service and consolidate git-auth utilities

* refactor: add git-credentials route and gh env plugin, pass internal token to OpenCode

* refactor: update credential provider integration and git route

* refactor: integrate credential provider across git auth, routes, and IPC
2026-06-20 21:52:18 -04:00
Chris Scott 5b85abd627 refactor: remove assistant auto-launch and simplify redirect flow (#282) 2026-06-20 12:28:32 -04:00
Chris Scott 617962f2dd feat: directory files upload system, deferred restart model, cache invalidation consolidation, and misc improvements (#281)
* feat: show variant label on model picker and add folder upload for agents/commands

- Replace three-dot variant menu trigger with selected variant label
- Add POST /api/settings/opencode-directory-files/install endpoint
- Upload agents/commands markdown folders into .config/opencode/{agents,commands}/
- Reload OpenCode server after upload so files are picked up

* fix: revalidate branch/git caches when mobile sheet opens and on vcs.branch.updated SSE

- add shared invalidateRepoGitCaches() helper for consistent invalidation
- revalidate repo list when mobile repo quick-switch sheet opens
- revalidate current repo when mobile More drawer opens
- revalidate repo/git caches when Source Control dialog opens
- handle vcs.branch.updated SSE event with optimistic cache update
- use helper in branch create/switch mutations in useGit and BranchesTab

* style: make variant selector look more like a button with chevron and compact sizing

* refactor: consolidate settings editors, add folder upload support, and clean up unused code

* refactor: consolidate settings editors, add folder upload support, and clean up unused code

* feat: add opencode-directory-files listing service and consolidate settings editors

* fix: distinguish scroll from tap in suggestion popups on touch devices

* refactor: consolidate settings editors and add DirectoryFilesList component

* refactor: target repo status cache updates only to affected batch entries

* refactor: streamline settings, git hooks, and query invalidation logic
2026-06-20 00:40:36 -04:00
Chris Scott d268182610 refactor: extract SettingsList component and unify settings editor layouts (#280) 2026-06-18 10:44:52 -04:00
Chris Scott 6e80cdfb8c feat: add skill installer (#279)
* feat: add skill installer with install/uninstall and settings UI

* feat: refactor skill installer with extracted SkillLibraryList component

* feat: simplify SkillsEditor, extract SkillLibraryList

* feat: refactor skill installer components and add github utility
2026-06-17 23:11:29 -04:00
Chris Scott 24d34f28a3 Revert "feat: add skill installer with install/uninstall and settings UI (#277)" (#278)
This reverts commit 9cb2bb156b.
2026-06-17 23:09:34 -04:00
Chris Scott 9cb2bb156b feat: add skill installer with install/uninstall and settings UI (#277)
* feat: add skill installer with install/uninstall and settings UI

* feat: refactor skill installer with extracted SkillLibraryList component

* feat: simplify SkillsEditor, extract SkillLibraryList
2026-06-17 22:52:05 -04:00
Chris Scott 3e617c2df8 fix: preserve prompt text on network error and allow offline typing (#276)
* fix: preserve prompt text on network error and allow offline typing

* fix: preserve prompt on network error, swallow 524 to avoid duplicate sends

* feat: add service worker precaching with app shell and runtime cache strategies

* fix: copy frontend/plugins into Docker build context

* fix: improve service worker update checks with visibility and focus handlers

* fix: add connect timeout to event stream to recover from failed connections

* fix: remove optimistic message insert, keep prompt in input until server confirms
2026-06-17 17:28:59 -04:00
Chris Scott a7d0c13f9a fix: avoid auto-applying OpenCode config on dropdown selection (#275) 2026-06-15 18:58:50 -04:00
Chris Scott 4e32fd5b00 feat: add session status store with optimistic active state and SSE polling (#272)
* feat: add session status store with optimistic active state and SSE polling

- Adds sessionStatusStore with setOptimisticActive (auto-timeout), statusCache deduplication, and replaceStatuses/clearStatus

- Integrates store in useSendPrompt (set optimistic on send, clear on error)

- Adds session.status SSE event handling in useSSE with 5s polling fallback

- Refactors test to mock the store instead of using real store instance

- Fixes repoId null check in useRepoActivity

* feat: replace event-source-polyfill with native SSE for PromptInput

* fix: keep stop button visible and hide clear prompt button during active session

* feat: restore failed queued prompts and preserve optimistic active status during poll

* test: add MessageThread tests for optimistic editing state and resend flow

* fix: handle queued prompt edge cases during pending submission and SSE errors
2026-06-10 08:35:19 -04:00
Chris Scott 8133b655b0 refactor: persist assistant repo in database with ID migration (#271) 2026-06-09 14:46:39 -04:00
Chris Scott 0d384d6cf0 refactor: move assistant workspace install before OpenCode server start (#263)
* refactor: move assistant workspace install before OpenCode server start

* refactor: skip assistant-mode status fetch on open, use repo fullPath and cached session
2026-06-07 13:35:19 -04:00
Chris Scott 0d14e754e1 refactor: extract shared useUrlParams hook and use push navigation for dialogs (#266)
* refactor: extract shared useUrlParams hook and use push navigation for dialogs

* Remove schedule badges and fix dialog safe area padding

* fix: deduplicate server health toasts with stable IDs

* fix: restore Enabled/Paused status badges on schedule jobs

* refactor: consolidate url state hooks and add shared test utilities
2026-06-07 13:02:56 -04:00
Chris Scott ec7a47dc10 feat: replay session statuses on upstream reconnect and add compact type (#268) 2026-06-06 23:02:48 -04:00
Chris Scott 95ae584f6a feat: interactive task list checkboxes in markdown preview (#267)
* feat: interactive task list checkboxes in markdown preview

* fix: persist markdown checkbox toggles

* fix: sync optimistic markdown checkbox state

* fix: align markdown checkbox preview state

* fix: prevent "0" rendering in file browser header when repoId is 0
2026-06-06 22:11:49 -04:00
Chris Scott ac3cfc32f9 fix: allow editing in config editor without clearing search first (#265) 2026-06-06 18:16:13 -04:00
Chris Scott bcabcc145a fix: derive session active state from server status and incomplete assistant, not last user message 2026-06-06 16:02:10 -04:00