feat(core): copy file changes when warping (#26190)

This commit is contained in:
James Long
2026-05-07 10:24:17 -04:00
committed by GitHub
parent b6ff1b18c7
commit 3c4b4d5faf
23 changed files with 955 additions and 28 deletions
+110
View File
@@ -202,8 +202,12 @@ import type {
V2SessionMessagesResponses,
V2SessionPromptResponses,
V2SessionWaitResponses,
VcsApplyErrors,
VcsApplyResponses,
VcsDiffRawResponses,
VcsDiffResponses,
VcsGetResponses,
VcsStatusResponses,
WorktreeCreateErrors,
WorktreeCreateInput,
WorktreeCreateResponses,
@@ -1022,6 +1026,7 @@ export class Workspace extends HeyApiClient {
workspace?: string
id?: string | null
sessionID?: string
copyChanges?: boolean
},
options?: Options<never, ThrowOnError>,
) {
@@ -1034,6 +1039,7 @@ export class Workspace extends HeyApiClient {
{ in: "query", key: "workspace" },
{ in: "body", key: "id" },
{ in: "body", key: "sessionID" },
{ in: "body", key: "copyChanges" },
],
},
],
@@ -1555,6 +1561,38 @@ export class Path extends HeyApiClient {
}
}
export class Diff extends HeyApiClient {
/**
* Get raw VCS diff
*
* Retrieve a raw patch for current uncommitted changes.
*/
public raw<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<VcsDiffRawResponses, unknown, ThrowOnError>({
url: "/vcs/diff/raw",
...options,
...params,
})
}
}
export class Vcs extends HeyApiClient {
/**
* Get VCS info
@@ -1586,6 +1624,36 @@ export class Vcs extends HeyApiClient {
})
}
/**
* Get VCS status
*
* Retrieve changed files in the current working tree without patches.
*/
public status<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
],
},
],
)
return (options?.client ?? this.client).get<VcsStatusResponses, unknown, ThrowOnError>({
url: "/vcs/status",
...options,
...params,
})
}
/**
* Get VCS diff
*
@@ -1617,6 +1685,48 @@ export class Vcs extends HeyApiClient {
...params,
})
}
/**
* Apply VCS patch
*
* Apply a raw patch to the current working tree.
*/
public apply<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
workspace?: string
patch?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ in: "query", key: "workspace" },
{ in: "body", key: "patch" },
],
},
],
)
return (options?.client ?? this.client).post<VcsApplyResponses, VcsApplyErrors, ThrowOnError>({
url: "/vcs/apply",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
private _diff?: Diff
get diff2(): Diff {
return (this._diff ??= new Diff({ client: this.client }))
}
}
export class Command extends HeyApiClient {
+95 -2
View File
@@ -1474,6 +1474,13 @@ export type VcsInfo = {
default_branch?: string
}
export type VcsFileStatus = {
file: string
additions: number
deletions: number
status: "added" | "deleted" | "modified"
}
export type VcsFileDiff = {
file: string
patch: string
@@ -1482,6 +1489,14 @@ export type VcsFileDiff = {
status?: "added" | "deleted" | "modified"
}
export type VcsApplyError = {
name: "VcsApplyError"
data: {
message: string
reason: "non-git" | "not-clean"
}
}
export type Command = {
name: string
description?: string
@@ -1736,6 +1751,13 @@ export type Workspace = {
projectID: string
}
export type WorkspaceWarpError = {
name: "WorkspaceWarpError"
data: {
message: string
}
}
export type SyncEventMessageUpdated = {
type: "sync"
name: "message.updated.1"
@@ -4020,6 +4042,25 @@ export type VcsGetResponses = {
export type VcsGetResponse = VcsGetResponses[keyof VcsGetResponses]
export type VcsStatusData = {
body?: never
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/vcs/status"
}
export type VcsStatusResponses = {
/**
* VCS status
*/
200: Array<VcsFileStatus>
}
export type VcsStatusResponse = VcsStatusResponses[keyof VcsStatusResponses]
export type VcsDiffData = {
body?: never
path?: never
@@ -4040,6 +4081,57 @@ export type VcsDiffResponses = {
export type VcsDiffResponse = VcsDiffResponses[keyof VcsDiffResponses]
export type VcsDiffRawData = {
body?: never
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/vcs/diff/raw"
}
export type VcsDiffRawResponses = {
/**
* Raw VCS diff
*/
200: string
}
export type VcsDiffRawResponse = VcsDiffRawResponses[keyof VcsDiffRawResponses]
export type VcsApplyData = {
body?: {
patch: string
}
path?: never
query?: {
directory?: string
workspace?: string
}
url: "/vcs/apply"
}
export type VcsApplyErrors = {
/**
* VcsApplyError
*/
400: VcsApplyError
}
export type VcsApplyError2 = VcsApplyErrors[keyof VcsApplyErrors]
export type VcsApplyResponses = {
/**
* VCS patch applied
*/
200: {
applied: boolean
}
}
export type VcsApplyResponse = VcsApplyResponses[keyof VcsApplyResponses]
export type CommandListData = {
body?: never
path?: never
@@ -6667,6 +6759,7 @@ export type ExperimentalWorkspaceWarpData = {
body?: {
id: string | null
sessionID: string
copyChanges?: boolean
}
path?: never
query?: {
@@ -6678,9 +6771,9 @@ export type ExperimentalWorkspaceWarpData = {
export type ExperimentalWorkspaceWarpErrors = {
/**
* Bad request
* WorkspaceWarpError | VcsApplyError
*/
400: BadRequestError
400: WorkspaceWarpError | VcsApplyError
}
export type ExperimentalWorkspaceWarpError = ExperimentalWorkspaceWarpErrors[keyof ExperimentalWorkspaceWarpErrors]