feat(core): basic implementation of remote workspace support (#15120)

This commit is contained in:
James Long
2026-02-27 15:36:39 -05:00
committed by GitHub
parent a94f564ff0
commit c12ce2ffff
26 changed files with 2153 additions and 65 deletions

View File

@@ -26,6 +26,11 @@ import type {
EventTuiToastShow,
ExperimentalResourceListResponses,
ExperimentalSessionListResponses,
ExperimentalWorkspaceCreateErrors,
ExperimentalWorkspaceCreateResponses,
ExperimentalWorkspaceListResponses,
ExperimentalWorkspaceRemoveErrors,
ExperimentalWorkspaceRemoveResponses,
FileListResponses,
FilePartInput,
FilePartSource,
@@ -901,6 +906,107 @@ export class Worktree extends HeyApiClient {
}
}
export class Workspace extends HeyApiClient {
/**
* Remove workspace
*
* Remove an existing workspace.
*/
public remove<ThrowOnError extends boolean = false>(
parameters: {
id: string
directory?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "id" },
{ in: "query", key: "directory" },
],
},
],
)
return (options?.client ?? this.client).delete<
ExperimentalWorkspaceRemoveResponses,
ExperimentalWorkspaceRemoveErrors,
ThrowOnError
>({
url: "/experimental/workspace/{id}",
...options,
...params,
})
}
/**
* Create workspace
*
* Create a workspace for the current project.
*/
public create<ThrowOnError extends boolean = false>(
parameters: {
id: string
directory?: string
branch?: string | null
config?: {
directory: string
type: "worktree"
}
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "path", key: "id" },
{ in: "query", key: "directory" },
{ in: "body", key: "branch" },
{ in: "body", key: "config" },
],
},
],
)
return (options?.client ?? this.client).post<
ExperimentalWorkspaceCreateResponses,
ExperimentalWorkspaceCreateErrors,
ThrowOnError
>({
url: "/experimental/workspace/{id}",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
/**
* List workspaces
*
* List all workspaces.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }])
return (options?.client ?? this.client).get<ExperimentalWorkspaceListResponses, unknown, ThrowOnError>({
url: "/experimental/workspace",
...options,
...params,
})
}
}
export class Session extends HeyApiClient {
/**
* List sessions
@@ -965,6 +1071,11 @@ export class Resource extends HeyApiClient {
}
export class Experimental extends HeyApiClient {
private _workspace?: Workspace
get workspace(): Workspace {
return (this._workspace ??= new Workspace({ client: this.client }))
}
private _session?: Session
get session(): Session {
return (this._session ??= new Session({ client: this.client }))

View File

@@ -887,6 +887,35 @@ export type EventVcsBranchUpdated = {
}
}
export type EventWorktreeReady = {
type: "worktree.ready"
properties: {
name: string
branch: string
}
}
export type EventWorktreeFailed = {
type: "worktree.failed"
properties: {
message: string
}
}
export type EventWorkspaceReady = {
type: "workspace.ready"
properties: {
name: string
}
}
export type EventWorkspaceFailed = {
type: "workspace.failed"
properties: {
message: string
}
}
export type Pty = {
id: string
title: string
@@ -926,21 +955,6 @@ export type EventPtyDeleted = {
}
}
export type EventWorktreeReady = {
type: "worktree.ready"
properties: {
name: string
branch: string
}
}
export type EventWorktreeFailed = {
type: "worktree.failed"
properties: {
message: string
}
}
export type Event =
| EventInstallationUpdated
| EventInstallationUpdateAvailable
@@ -979,12 +993,14 @@ export type Event =
| EventSessionDiff
| EventSessionError
| EventVcsBranchUpdated
| EventWorktreeReady
| EventWorktreeFailed
| EventWorkspaceReady
| EventWorkspaceFailed
| EventPtyCreated
| EventPtyUpdated
| EventPtyExited
| EventPtyDeleted
| EventWorktreeReady
| EventWorktreeFailed
export type GlobalEvent = {
directory: string
@@ -1627,6 +1643,16 @@ export type WorktreeCreateInput = {
startCommand?: string
}
export type Workspace = {
id: string
branch: string | null
projectID: string
config: {
directory: string
type: "worktree"
}
}
export type WorktreeRemoveInput = {
directory: string
}
@@ -2473,6 +2499,93 @@ export type WorktreeCreateResponses = {
export type WorktreeCreateResponse = WorktreeCreateResponses[keyof WorktreeCreateResponses]
export type ExperimentalWorkspaceRemoveData = {
body?: never
path: {
id: string
}
query?: {
directory?: string
}
url: "/experimental/workspace/{id}"
}
export type ExperimentalWorkspaceRemoveErrors = {
/**
* Bad request
*/
400: BadRequestError
}
export type ExperimentalWorkspaceRemoveError =
ExperimentalWorkspaceRemoveErrors[keyof ExperimentalWorkspaceRemoveErrors]
export type ExperimentalWorkspaceRemoveResponses = {
/**
* Workspace removed
*/
200: Workspace
}
export type ExperimentalWorkspaceRemoveResponse =
ExperimentalWorkspaceRemoveResponses[keyof ExperimentalWorkspaceRemoveResponses]
export type ExperimentalWorkspaceCreateData = {
body?: {
branch: string | null
config: {
directory: string
type: "worktree"
}
}
path: {
id: string
}
query?: {
directory?: string
}
url: "/experimental/workspace/{id}"
}
export type ExperimentalWorkspaceCreateErrors = {
/**
* Bad request
*/
400: BadRequestError
}
export type ExperimentalWorkspaceCreateError =
ExperimentalWorkspaceCreateErrors[keyof ExperimentalWorkspaceCreateErrors]
export type ExperimentalWorkspaceCreateResponses = {
/**
* Workspace created
*/
200: Workspace
}
export type ExperimentalWorkspaceCreateResponse =
ExperimentalWorkspaceCreateResponses[keyof ExperimentalWorkspaceCreateResponses]
export type ExperimentalWorkspaceListData = {
body?: never
path?: never
query?: {
directory?: string
}
url: "/experimental/workspace"
}
export type ExperimentalWorkspaceListResponses = {
/**
* Workspaces
*/
200: Array<Workspace>
}
export type ExperimentalWorkspaceListResponse =
ExperimentalWorkspaceListResponses[keyof ExperimentalWorkspaceListResponses]
export type WorktreeResetData = {
body?: WorktreeResetInput
path?: never