* 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>
* 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>
* 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>
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.
* 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>
* 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.
* 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.
* 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>
* 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>
* 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>
* 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>