45 Commits

Author SHA1 Message Date
Will Sather
be582e90c3
fix: disconnected github dialog and failed connection info (#847)
* fix: disconnected github dialog and failed connection info

* fix: lint

* fix: tests
2026-04-22 20:22:06 -07:00
Will Sather
0863110359
fix: small git panel + sidebar bugs (#830)
* fix: sync leaderboard and rank cache on data refresh

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: improve pr-deployment fallback logic and token error handling

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: update pr-deployment tests for Vercel-first lookup behavior

The route now always tries the Vercel API first (by branch) regardless
of PR state, falling back to GitHub PR comments only when needed.

Updated tests:
- 'prefers Vercel API over PR comment lookup when both return a URL'
- 'falls back to PR comment lookup when Vercel API has no deployment'
- 'returns failedDeploymentUrl for PR sessions via Vercel API'

* fix: use UTC date methods for consistent leaderboard caching

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-21 00:12:18 -05:00
open-agents-bot[bot]
9679c867ce
chore: rename open-harness to open-agents (#703)
* refactor: rename open-harness to open-agents

* refactor: replace ai-sdk import with inline FetchFunction type

* refactor: rename "Open Agents" to "Open Agent"

* fix: align chat runtime package imports

---------

Co-authored-by: willsather <56037657+willsather@users.noreply.github.com>
Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-20 23:09:41 -05:00
Will Sather
cee13abfaa
feat: replace manual oauth with better-auth (#820)
* feat: replace manual oauth with better-auth

* fix: lint

* chore: refactor accounts to unify github + vercel

* feat: enhance auth config with host allowlisting

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: add newline at end of manifest.json

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: update betterAuth database schema mappings

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: sanitize redirects and preserve destination in github flow

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* feat: enhance GitHub app callback with installation sync tracking

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* build: add BETTER_AUTH_SECRET to turbo env

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* refactor: update sign-in callback to skip onboarding

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-20 15:40:13 +01:00
Nico Albanese
e0fc0e3840
fix: improve repository sorting by recent activity (#795)
* refactor: sort repos by recent activity across pages

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: stop paging early when limit is reached

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: increase per_page to 50 for better sorting

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-16 10:15:11 +00:00
Nico Albanese
7c12e8b7da
feat: optimize repo selector pagination with early stopping (#753)
* feat: stop pagination early when repo limit is reached

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* refactor: reduce repo selector result limit to 25

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

* fix: reduce installation repos page size to 25

Co-Authored-By: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>

---------

Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-14 17:47:22 +02:00
Nico Albanese
e1e89d956d
chore: remove unused tarball download logic (#747)
Co-authored-by: open-agents-bot[bot] <260704009+open-agents-bot[bot]@users.noreply.github.com>
2026-04-14 12:03:41 +02:00
willsather
d428542158 fix: await async getAppCoAuthorTrailer call and fetch bot user ID 2026-04-14 01:49:43 +00:00
open-agents-bot[bot]
4628543292
refactor: migrate GitHub operations to use OAuth tokens (#723)
* refactor: remove unused GitHub repos API and installation endpoints

* refactor(github): prefer user OAuth tokens for user-initiated actions

* refactor: migrate user GitHub ops to OAuth tokens

* refactor: simplify OAuth token handling with single token

---------

Co-authored-by: willsather <56037657+willsather@users.noreply.github.com>
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-14 03:18:32 +02:00
nicoalbanese
b2cd4dab1d fix: github scope issues 2026-04-13 22:44:09 +01:00
open-agents-bot[bot]
66aa7e5032
fix: unstable_cache on github api (#716)
* refactor: remove cached-api in favor of direct fetch functions

* fix: update auto-pr test mocks for cached-api removal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: willsather <56037657+willsather@users.noreply.github.com>
Co-authored-by: willsather <will@sather.ws>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 21:19:57 +01:00
Nico Albanese
5044d03bcf
remove cache on installations (#715)
* remove cache on installations

* update

* format fix

* update
2026-04-13 19:52:47 +00:00
open-agents-bot[bot]
0441f1f49c
feat: add GitHub installation reconnection flow (#692)
* docs: revise plan for live GitHub connection health checks

* feat: add GitHub installation reconnection flow

* feat: improve GitHub auth detection and handle connection loading

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-10 18:23:59 +01:00
open-agents-bot[bot]
a54a012c57
feat: add diff stats to merge readiness (#665)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-10 11:13:44 +00:00
nicoalbanese
9634c36ae7 test: add github client merge readiness tests 2026-04-09 15:36:39 +00:00
willsather
e9979f5b42 feat: add PR title and body to merge readiness response 2026-04-08 16:36:30 +00:00
open-agents-bot[bot]
9c58154165
feat: sort repositories by recent activity (#637)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-08 16:04:55 +00:00
openharness[bot]
288df2c80e
chore: rename Open Harness to Open Agents (#624)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-07 17:57:26 +00:00
Will Sather
f4e02d3b83
merge: feat: improve merge dialog + checks ui (#614) 2026-04-07 12:43:58 -05:00
openharness[bot]
8929159159
feat: add branch limiting support to GitHub API (#625)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-07 17:35:59 +00:00
willsather
acecb6f8a3 feat: add check logs API and improve merge dialog error display 2026-04-07 15:20:12 +00:00
willsather
8b4039d8a7 feat: improve merge dialog check failure handling 2026-04-07 15:20:12 +00:00
openharness[bot]
ff194dfe5e
feat: implement auto-merge PR creation with improved error handling (#607)
* test: add comprehensive PR route tests

* refactor: improve auto-merge with nodeId and error handling

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-05 11:03:53 +00:00
openharness[bot]
733b35d532
feat: display required status checks in merge dialog (#586)
* feat: display check run status in merge dialog

* feat: fetch required checks from branch protection

* style: improve formatting in merge-pr-dialog

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-03 13:06:02 +01:00
openharness[bot]
b1cfb282eb
feat: add auto pull request creation support for chat sessions (#540)
* docs: plan workflow auto-create-PR feature

* refactor: extract PR generation logic and add autoCreatePr

* feat: add auto pull request creation support

* feat: return auto-commit result to gate auto-PR creation

* feat: prevent auto PR creation when PR already exists

* refactor: extract GitHub auth remote URL builder

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-25 22:29:13 +00:00
openharness[bot]
81c2655352
fix: handle Vercel 404/403 errors gracefully in sandbox lifecycle management (#529)
* fix: handle 403/404 gracefully and prevent duplicate lifecycle kicks

* fix: handle 404 errors as graceful shutdown in reconnect logic

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-20 18:17:22 +00:00
openharness[bot]
4ad3769545
feat: add polling for pull request mergeability (#497)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-19 18:41:31 +00:00
openharness[bot]
477ca47edf
feat: add ability to close pull requests with session archival (#488)
* feat: add ability to close pull requests with session archival

* style: format multiline elements for readability

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-19 16:28:04 +00:00
openharness[bot]
f64e06b204
feat: add draft pull request creation support (#400)
* feat: add draft pull request creation support

* feat: replace draft toggle with dropdown PR creation mode selector

* style: format code and update bun-types

---------

Co-authored-by: willsather <56037657+willsather@users.noreply.github.com>
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-19 06:55:15 -07:00
Nico Albanese
44e45791dc
Simplify platform to web + cloud-only agent runtime (#443)
* Remove CLI from project

* Simplify agent approvals to bash safety only

* simplify agent cloud execution model

* hardcode bash safety policy

* Remove agent context compaction

* remove

* updates

* refactor(agent): replace call options with agent factories

* refactor(agent): remove prepareCall from agents

* Use model selections in agent factory

* Relax bash approval heuristics

* Remove local and in-memory sandboxes

* Refactor agent sandbox config to be serializable

* Fix stale bash approval test

* Revert "refactor(agent): replace call options with agent factories"

This reverts commit b0b8345526b2dd152fe09b0ef25bd5b868290345.

* refactor(agent): remove live sandbox from call options

* refactor(agent): remove live sandbox compatibility path

* refactor: extract chat auth context into reusable module (#444)

Co-authored-by: nicoalbanese
<49612682+nicoalbanese@users.noreply.github.com>

* resolve merge conficts

* soft reconnect fix

* remove dead compaction context code from chat request helpers
2026-03-16 09:31:20 +00:00
openharness[bot]
39189d7b6d
feat: add PR merge button with readiness validation for sessions (#387)
* feat: add merge readiness API endpoint for sessions

* test: add validation for invalid JSON and null head owner cases

* feat: add check run details to merge readiness dialog

* feat: add PR refresh and open buttons to merge dialog

* refactor: remove merge & archive button from session chat

* refactor: extract toDateStr helper function

* refactor: simplify conditional logic and remove redundant code

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-08 18:07:22 +00:00
openharness[bot]
7570722280
feat: display Vercel deployment URL in navbar for sessions (#330)
* feat: add Vercel deployment URL display in navbar

* fix: change deployment button text from "View Deployment" to "Preview"

* Update apps/web/lib/github/client.ts

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

* feat: refresh diff cache in background after chat response (#327)

* feat: refresh diff cache in background after chat response

* refactor: wrap diff cache update with Next.js after() API

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>

* feat: disable git buttons while sandbox is spinning up (#328)

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>

* docs: increase sandbox inactivity timeout from 20 to 30 min (#329)

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>

* Na/d572fa41 (#331)

* feat: disable git buttons while sandbox is spinning up

* fix: remove git button disabled state check

* style: format pr deployment route

* feat: extract Vercel deployment URL from metadata

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: openharness[bot] <260704009+openharness[bot]@users.noreply.github.com>
2026-03-02 16:05:48 +00:00
openharness[bot]
bd35727d16
fix: resolve manage repo access 404 by using app slug (#326)
Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-03-02 14:26:12 +00:00
Nico Albanese
4dacdf9b3b
feat: detect existing PRs and persist branch info after message completion (#263)
Add automatic branch and PR detection that runs after each agent message
completes, replacing the previous approach of only checking when the
Create PR dialog was opened. The branch name and any existing PR info
are now persisted to the session DB and reflected in the nav/sidebar.
2026-02-23 11:56:09 +01:00
Nico Albanese
6603081f4d
feat: add co-author trailer for GitHub App commits (#204)
* feat: add co-author trailer for GitHub App commits

* chore: format api routes
2026-02-20 16:58:21 +01:00
Nico Albanese
049c86dcbd
Improve React performance, loading states, and session layout (#198)
* Improve React performance: parallelize fetches, dynamic imports, memoization

- Parallelize independent server-side data fetches with Promise.all in page.tsx
- Add next/dynamic for DiffViewer, CreatePRDialog, CreateRepoDialog modals
- Add optimizePackageImports for lucide-react in next.config.ts
- Memoize SessionChatContext provider value (36 properties)
- Memoize derived state (renderMessages, lastMessage, showThinkingIndicator)
- Convert sandboxUiStatus IIFE to useMemo
- Use messages.length in scroll effect dependency array
- Update audit doc to mark fixed items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Address remaining React best practices audit items

- Add loading.tsx/error.tsx for key route segments (Suspense boundaries)
- Replace hasMounted useState+useEffect with useSyncExternalStore
- Extract ChatSidebar component from monolithic SessionChatContent
- Replace direct fetch with SWR in CreateRepoDialog for cache sharing
- Convert conditional && rendering to explicit ternaries
- Remove unused react-hook-form, @hookform/resolvers, form.tsx, chat-context.tsx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Move sidebar to session layout so it persists during chat navigation

The loading spinner was replacing the entire page (including sidebar)
when switching between chats, causing a jarring flash. By introducing a
Next.js layout at the session level, the sidebar stays mounted and only
the chat content area shows the loading state during navigation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Show session name and input shell in chat loading state

Instead of a full-page spinner, the chat loading state now preserves
the header (with real session/repo name from layout context) and an
input area shell so only the messages area shows the loading spinner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix input height mismatch in loading skeleton and suppress overlay flash

Use a real disabled textarea in the loading skeleton so height matches
the actual input exactly. Also hide the sandbox overlay during initial
reconnection (idle state) to prevent the Resume/Create buttons from
flashing briefly on navigation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Improve web chat route responsiveness by removing fetch waterfalls, caching repeated setup work, and trimming initial session payloads.

* Improve chat UI responsiveness with memoized message grouping and smarter polling backoff.

* Improve GitHub repo fetch performance with cached installation queries

* Fix chat auto-scroll during streaming updates

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 16:27:48 +01:00
Nico Albanese
11fc722ed7
fix: refresh expired GitHub OAuth tokens instead of silently failing (#192)
* fix: refresh expired GitHub OAuth tokens instead of silently failing

GitHub Apps with expiring user tokens issue tokens that expire after ~8h.
The OAuth exchange was ignoring refresh_token and expires_in from GitHub's
response, so after expiration all GitHub API calls returned 401, causing
the connector page to show a blank state.

Store refresh_token/expiresAt during OAuth exchange, and add inline token
refresh logic to getUserGitHubToken (mirroring the existing Vercel token
refresh pattern). Existing users will need to reconnect GitHub once to
pick up a refresh token.

* fix: harden GitHub token refresh against DB persistence failures

Return the refreshed token even if persisting to the database fails,
preventing a permanently broken GitHub connection when the refresh
token has already been consumed. Also add response.ok check before
parsing the refresh response body.
2026-02-18 16:10:39 +01:00
Nico Albanese
68e5f53a34
Fix PR generation fork fallback and permission error detection (#187)
* Improve public repo PR flow with fork and compare fallbacks

* fix: preserve fork head owner when branch is already pushed

* fix: gate fork fallback on permission errors only

Non-permission push failures (e.g. rejected/non-fast-forward) now fall
through to informative error handling instead of triggering fork creation.

* fix: tighten permission error heuristic and use actual fork repo name

- Replace broad substring matches ('permission', '403', 'denied') in
  isPermissionPushError with specific git error patterns to avoid false
  positives from commit messages or ref names.
- Parse actual fork repo name from GitHub API response in ensureForkExists
  instead of assuming it matches the upstream repo name, handling cases
  where GitHub appends a suffix due to naming conflicts.
2026-02-18 12:40:18 +01:00
Nico Albanese
a6177acd41
feat: unified GitHub App install + OAuth flow with per-org install UI (#165)
* feat: unified GitHub App install + OAuth flow with per-org install UI

Replaces the two-step OAuth-then-install flow with a single GitHub App
installation flow that handles OAuth authorization inline (via GitHub's
'Request user authorization during installation' setting).

- Add app callback OAuth code exchange so install + account link happen
  in one redirect
- Use /installations/select_target URL to always show the account/org
  picker (fixes redirect to existing personal install settings)
- Add per-org install via target_id for direct org install links
- Add /api/github/orgs/install-status endpoint returning per-org
  install state with GitHub IDs
- Rebuild accounts settings page with per-org status rows, install/
  configure actions, request-access guidance, and post-return toasts
- Delete the separate OAuth link routes (no longer needed)
- Add sonner for toast notifications
- Update repo-selector-compact wording to 'Install to organization'
- Document GitHub App setup requirements (public app, OAuth during
  install, callback URL) in .env.example and AGENTS.md

* Fix GitHub app callback auth and installation sync pagination

* Fix GitHub reconnect after disconnect skipping install page

After disconnecting GitHub, the app only revoked the OAuth token but the
GitHub App installation remained. Clicking Connect again sent users to
the install page which redirected to existing installation settings
instead of re-authorizing.

Use a github_reconnect cookie set during disconnect to route reconnects
through the OAuth authorize URL, re-linking the account and syncing
existing installations without requiring a fresh app install.

* Fix installation upsert conflict and initial repo push token

* Fix repo creation to use installation tokens and add owner picker

Use installation tokens for org repo creation (createInOrg) and user
OAuth tokens for personal accounts. Add account/org picker to the
create repo dialog so users select where to create the repository.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix repo creation push token and missing installation handling

Return an error when the requested owner has no GitHub App installation
instead of silently falling back to the user's personal account. Use
installation token for push only on org repos — personal accounts use
the OAuth token that created the repo to avoid permission gaps when the
installation has "selected repositories" access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 20:43:44 +01:00
Nico Albanese
7f170b5504
web: add Vercel auth, GitHub linking, and turbo env config (#156)
* web: add Vercel auth, GitHub account linking, and connect-to-GitHub prompt

Adds Vercel as the primary auth provider with GitHub as a linked account
for repo access. Introduces account linking/unlinking flows, accounts
settings page, and a "Connect to GitHub" prompt in the repo selector
when GitHub isn't linked.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add Vercel and GitHub OAuth setup instructions to README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: stop revoking linked GitHub token on sign-out

The sign-out handler was revoking the GitHub OAuth token on GitHub's
side but leaving the account record in the database. After logging back
in, the app treated GitHub as still connected but all API calls failed
with an invalid token, causing persistent 500 errors on repo refresh.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: add auth env vars to turbo.json build cache keys

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix GitHub link action and clarify/respect stream lifecycle intent

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 12:30:59 +01:00
Nico Albanese
6474c269ef
web: add repo search limits and cache revalidation (#148) 2026-02-05 18:57:42 +00:00
Nico Albanese
312e644102
Replace hardcoded Vercel imports with unified connectSandbox API (#91)
* Add hybrid sandbox architecture research and test scripts

- Document hybrid sandbox design for eliminating cloud sandbox startup latency
- Add test scripts validating JustBash + Vercel parallel startup approach
- Test tarball loading, handoff mechanism, serialization, and pending ops replay
- Document serialization API design decision (class-level methods on JustBashSandbox)
- Add tar dependency for GitHub tarball extraction

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add serialization API to JustBashSandbox for serverless persistence

Implement serialize() and fromSnapshot() methods to enable JustBash state
persistence across serverless request boundaries. This is a key building
block for the hybrid sandbox architecture.

Changes:
- Add serialize() instance method to export sandbox state
- Add fromSnapshot() static factory to restore from snapshot
- Export JustBashSnapshot type from @open-harness/sandbox
- Update createJustBashSandbox() return type to JustBashSandbox
- Use FsEntry type directly from just-bash library

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add JustBash persistence for serverless (Milestone 1)

- Add justBashSnapshot column to tasks table for storing serialized
  JustBash state across serverless request boundaries
- Fix JustBashSandbox to use native bash.readFile/writeFile methods
  instead of shell commands (preserves whitespace correctly)
- Fix fromSnapshot to restore empty directories
- Add test endpoint at /api/test/justbash-persistence to validate
  persistence flow (create -> serialize -> restore -> verify)

Results: 6ms restore time, 769 bytes state size, all files persist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add GitHub repo loading in JustBash (Milestone 2)

- Add tarball utility to download and extract GitHub repos
- Filter binary files and lock files to reduce snapshot size by 87%
- Add JustBash init endpoint (/api/sandbox/justbash)
- Add test endpoint (/api/test/justbash-repo)
- Integrate JustBash support into chat route
- Support both JustBash and Vercel sandbox modes

Milestone 2 results:
- Tarball load: 345ms (target < 500ms)
- Restore time: 2ms (target < 10ms)
- Full repo + modifications persist across requests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add JustBash web integration experiment notes

Documents the experimental changes tested to bypass Vercel sandbox
and use JustBash directly in the web app. Includes warnings that
this is not a production-ready approach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add background Vercel startup (Milestone 3)

- Add vercelStatus, vercelStartedAt, vercelError fields to tasks schema
- Create /api/sandbox/vercel-background endpoint for background startup
- Create /api/test/hybrid-background test endpoint
- Add test script: scripts/test-milestone3.ts

Results: JustBash ready in 727ms, Vercel in 8.75s (12x speedup)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add seamless handoff from JustBash to Vercel (Milestone 4)

- Add pendingOperations and sandboxMode columns to tasks schema
- Create HybridSandbox wrapper class that tracks write operations
- Add handoff API endpoint (GET status, POST perform handoff)
- Add test endpoint and script for Milestone 4 validation

Results: All writes replay correctly (5 ops), files verified in Vercel,
git works after handoff, handoff time 2.98s (< 5s target).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add Milestone 5: Chat route integration plan

Documents the steps needed to integrate HybridSandbox into the
web chat route for seamless automatic handoff from JustBash to Vercel.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Implement hybrid sandbox for instant startup (Milestone 5)

- Modify /api/sandbox to use JustBash immediately (~300-500ms) instead of
  blocking for Vercel (~10s). Vercel starts in background.
- Update /api/chat to wrap JustBash in HybridSandbox for write tracking
- Add automatic handoff: when Vercel ready, replays pending ops and switches
- Fix sandbox validation to handle hybrid placeholder IDs after handoff
- Add test endpoint and script for Milestone 5 validation

User can now start chatting immediately after task creation. Vercel
capabilities (git, npm) become available after background startup completes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Keep reconnects on Vercel-only path for now

Hybrid approach only for new tasks. Reconnects use Vercel directly
to preserve uncommitted changes. Hybrid reconnect with snapshot
restoration is a future improvement.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add sandbox consumer abstraction desing

* Rename sandbox abstraction concepts for clarity

- getSandbox() → connectSandbox() (better conveys connection semantics)
- SandboxPayload → SandboxState (captures round-trip nature)
- JustBashState/VercelState/HybridState → *Config (these are init params)
- Flatten discriminated union (remove nested state property)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add folder restructure as prerequisite for sandbox abstraction

- Create sandbox-folder-restructure.md documenting the reorganization
  of sandbox implementations from single files into self-contained folders
- Update sandbox-abstraction-design.md to reference the folder
  restructure as a prerequisite and colocate state types with
  their implementations (*/connect.ts pattern)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Rename state.ts to factory.ts in sandbox design docs

Factory better describes the purpose - it's a factory function that
takes config and returns the right sandbox instance.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Restructure sandbox package into self-contained folders

Reorganize sandbox implementations from single files into folders to
enable cleaner separation between sandbox classes, config types, and
future connect functions for the abstraction layer.

- Add shared types.ts with Source, FileEntry, PendingOperation
- Move LocalSandbox to local/sandbox.ts with index.ts re-export
- Move VercelSandbox to vercel/sandbox.ts with config.ts for types
- Move JustBashSandbox to just-bash/sandbox.ts with snapshot.ts
- Update package.json exports for bundler compatibility
- Use extensionless imports for Next.js Turbopack compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Mark sandbox folder restructure as complete in docs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update todos

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Implement unified sandbox abstraction layer

Add connectSandbox() factory function that provides a single entry point
for creating, restoring, or reconnecting to any sandbox type. The state
shape determines behavior internally.

Changes:
- Add SandboxState union type and ConnectOptions interface
- Add state types (JustBashState, VercelState, HybridState)
- Add connect functions for each implementation
- Add getState() and status to all sandbox classes
- Move HybridSandbox from apps/web to packages/sandbox/hybrid/
- Add SandboxStatus type for lifecycle tracking

The consumer API is now:
  const sandbox = await connectSandbox(state, { env, gitUser, hooks });
  const newState = sandbox.getState(); // round-trip ready

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update AGENTS.md: do not use .js extensions in imports

The .js extension causes module resolution issues with Next.js/Turbopack.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add technical debt note for .js extension cleanup

packages/shared still uses .js extensions in imports which can cause
issues with Next.js/Turbopack.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* update todos

* step 8 migrate web ui to unified sandbox

* Improve hybrid sandbox reconnect and handoff handling

- Simplify ReconnectResponse type and handle pre-handoff hybrid state
- Add race condition documentation and stop unused Vercel sandboxes
- Add error tracking for pending operation replay during handoff
- Fix missing sandboxInfo dependency in handleKillSandbox callback

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Mark sandbox abstraction migration steps 7-8 as complete

Web app now uses unified sandboxState API and old schema fields
have been removed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add plans

* Implement hybrid sandbox completion plan with unified API

- Add HybridHooks interface with onCloudSandboxReady/onCloudSandboxFailed
- Add SandboxConnectConfig discriminated union for type-safe config
- Add HybridConnectOptions with registerBackgroundTask support
- Update connectHybrid to automatically start cloud sandbox in background
- Migrate web app sandbox route to use unified connectSandbox API
- Remove direct provider imports from web app (now uses abstraction)
- Export new types: HybridHooks, HybridConnectOptions, SandboxConnectConfig

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Replace registerBackgroundTask with callback-based scheduleBackgroundWork

Change the background task API from promise-based to callback-based for
framework-agnostic serverless support:

- Next.js after(): scheduleBackgroundWork: (cb) => after(cb)
- Vercel waitUntil(): scheduleBackgroundWork: (cb) => waitUntil(cb())
- Cloudflare Workers: scheduleBackgroundWork: (cb) => ctx.waitUntil(cb())

The callback approach defers execution until the runtime invokes it,
allowing each framework to control when work begins.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Always use hybrid sandbox and spin up cloud in background

- Simplify sandbox route to always use hybrid mode (remove Vercel fallback)
- Start cloud sandbox in background even without a source/repo
- Add getState() to Sandbox interface to avoid instanceof checks
- Add debug logging for background sandbox startup flow

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix null safety issues in HybridSandbox state transitions

- Fix potential null pointer dereference in `current` getter by adding
  explicit null checks instead of non-null assertion
- Handle "switching" state properly in both `current` and `getState()`
- Throw descriptive error if sandbox reaches invalid state
- Ensure vercel-based state is returned during/after handoff to prevent
  stale JustBash state from being persisted

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add sandbox type switcher to task input

Add a dropdown selector in the task input toolbar that allows users to
choose between hybrid, vercel, and just-bash sandbox types. The selected
type is passed via URL parameter to the task detail page where it's used
when creating the sandbox. The sandbox type is shown in the header tooltip
when hovering over the active indicator.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add potential plan

* update sandbox labels

* Add documentation for git simulation in in-memory sandboxes

Documents the approach, architecture, and implementation details for
simulating git commands in in-memory sandboxes. Includes rationale for
why this approach is NOT appropriate for scratchpad-style sandboxes
(like JustBash) where a file browser is more suitable.

Preserved for future reference if needed for sandboxes where changes
are meant to be integrated into real codebases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Disable diff button for in-memory sandboxes

The diff feature relies on git which isn't available in just-bash mode.
Button is now disabled with a tooltip explaining the limitation.
Also fixed the button to be disabled by default until diff data exists.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix sandbox status indicator for in-memory sandboxes

Update sandbox type in client state immediately after creation instead
of requiring a page refresh. Hide the stop/pause button for just-bash
sandboxes since they're in-memory and don't need to be stopped.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Disable timeout for in-memory sandboxes

Return timeout: null for just-bash sandboxes from the API. The client
now respects this by skipping the countdown timer and showing the
sandbox as always-active with an "in-memory" label.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Hide create repo button for in-memory sandboxes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Remove hybrid sandbox test files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* update lock

* Fix sandbox state persistence for all sandbox types

The chat route was only persisting state for HybridSandbox instances,
causing file modifications to be lost when using just-bash or vercel
sandbox types. Changed to check for getState method existence instead,
matching the pattern in /api/sandbox/route.ts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* do not open diff panel for just-bash

* Skip snapshot save for just-bash sandboxes

just-bash sandboxes persist state via getState() after each message,
so filesystem snapshots are unnecessary and unsupported.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix race condition in hybrid sandbox state persistence

The chat route's onFinish was overwriting the sandboxId set by
background work. Now checks if background work has already set
a sandboxId before persisting state, preventing the race condition.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:28:52 +00:00
Nico Albanese
1b69da92e7
Add GitHub repository creation feature for tasks (#67)
* Make sandbox creation work without a repository

* Add createRepository function to GitHub client

* Add create-repo API endpoint with git operations

* Add Switch component from radix-ui

* Add CreateRepoDialog component

* Support sandboxes without repos and add create repo flow

* fix: security and validation improvements for create-repo flow

- Fix command injection vulnerability in git config commands by escaping shell args
- Add explicit validation for cloneUrl/owner/repoName after repo creation
- Improve error messages to inform users when repo was created but push failed
- Sanitize taskTitle input (limit length, strip special chars) for AI prompt
- Align UI validation text with server-side rules (include periods)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update apps/web/app/api/github/create-repo/route.ts

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>

* Initialize git repo in empty sandboxes for diff viewer compatibility

Empty sandboxes (no source repo) now get git init + an empty initial commit,
allowing git diff HEAD to work consistently. This fixes the diff viewer
failing with "not a git repository" for tasks created without a clone URL.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
2026-01-12 16:26:59 +00:00
Nico Albanese
6b58d6808a
Add task management and PR creation features (#64)
* init scaffold

* add archive functionality

* update

* remove focus change

* update homepage styles

* add new branch button

* add persistence

* add create pr button

* fix critical errors

cc

* cc critical fixes

* critical fixes

* add diff viewer plan

* more critical fixes

* cc critical fixes

* Guard initial task message without sandbox

Prevents chat requests when tasks lack cloneUrl or sandboxId.

* fix: enforce task sandbox ownership

* chore: update todos

* fix: sync PR branch with sandbox

* Add helper functions for branch management

* Create git-status API endpoint

* Add branch status detection to create PR dialog

* Add commitOnly parameter to generate-pr API

* Convert PR dialog to multi-step wizard UI

* Add readFile tool visibility task to todos

* Add OctokitResult type for auth status
2026-01-12 11:47:59 +00:00
Nico Albanese
0d28d0105a
Add GitHub authentication and repository management (#63)
* Add GitHub OAuth authentication routes

* Add GitHub API endpoints for repos and user data

* Add session and crypto utilities

* Add database schema and client setup

* Add database migrations

* Add GitHub utility functions and client

* Add authentication components and hooks

* Add repo info to chat context

* Add GitHub token to sandbox API

* Pass GitHub token to chat sandbox

* Integrate repo selection and display in chat

* Add dependencies for auth and database

* Add branch selector API endpoint

* Create branch selector component

* Add UI component library base components

* Add cmdk and popover dependencies

* Replace input field with branch selector component

* update repo selector to be combo box

* fix scroll gutter bg

* update branch selector component width

* remove storage and update todos

* fix cc comments

* add caching

* cc fixes
2026-01-11 18:32:06 +00:00