fix(core): use current workspace with /new; fix warping into local project (#25894)

This commit is contained in:
James Long 2026-05-05 16:39:37 -04:00 committed by GitHub
parent 8e182c7782
commit 12f3d1f505
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 7 deletions

View file

@ -129,11 +129,11 @@ export function DialogWorkspaceSelect(props: {
.toSorted((a, b) => b.time.updated - a.time.updated)
.flatMap((session) => (session.workspaceID ? [session.workspaceID] : []))
.filter((workspaceID, index, list) => list.indexOf(workspaceID) === index)
.slice(0, 3)
.flatMap((workspaceID) => {
const workspace = project.workspace.get(workspaceID)
return workspace ? [workspace] : []
return workspace && project.workspace.status(workspace.id) === "connected" ? [workspace] : []
})
.slice(0, 3)
return [
...list.map((adapter) => ({
title: adapter.name,

View file

@ -181,6 +181,7 @@ export function Prompt(props: PromptProps) {
const [warpNotice, setWarpNotice] = createSignal<string>()
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
const hasRightContent = createMemo(() => Boolean(props.right))
const defaultWorkspaceID = createMemo(() => props.workspaceID ?? project.workspace.current())
function selectWorkspace(selection: WorkspaceSelection | undefined) {
setWorkspaceSelection(selection)
@ -860,14 +861,14 @@ export function Prompt(props: PromptProps) {
if (sessionID == null) {
const workspace = workspaceSelection()
const workspaceID = iife(() => {
if (!workspace) return undefined
if (!workspace) return defaultWorkspaceID()
if (workspace.type === "none") return undefined
if (workspace.type === "existing") return workspace.workspaceID
return undefined
})
const res = await sdk.client.session.create({
workspace: props.workspaceID,
workspace: workspaceID,
agent: agent.name,
model: {
providerID: selectedModel.providerID,
@ -1145,7 +1146,17 @@ export function Prompt(props: PromptProps) {
| undefined
>(() => {
const selected = workspaceSelection()
if (!selected) return
if (!selected) {
const workspaceID = defaultWorkspaceID()
if (props.sessionID || !workspaceID) return
const workspace = project.workspace.get(workspaceID)
return {
type: "existing",
workspaceType: workspace?.type ?? "unknown",
workspaceName: workspace?.name ?? workspaceID,
status: project.workspace.status(workspaceID) ?? "error",
}
}
if (selected.type === "none") return
if (props.sessionID && !workspaceCreating()) return
if (selected.type === "new") {

View file

@ -146,6 +146,16 @@ function matchLegacyOpenApi(input: Record<string, unknown>) {
if (properties?.branch) properties.branch = { anyOf: [properties.branch, { type: "null" }] }
if (properties?.extra) properties.extra = { anyOf: [properties.extra, { type: "null" }] }
}
if (path === "/experimental/workspace/warp" && method === "post") {
const ref = operation.requestBody.content?.["application/json"]?.schema?.$ref?.replace(
"#/components/schemas/",
"",
)
const properties = ref
? spec.components?.schemas?.[ref]?.properties
: operation.requestBody.content?.["application/json"]?.schema?.properties
if (properties?.id) properties.id = { anyOf: [properties.id, { type: "null" }] }
}
}
for (const response of Object.values(operation.responses ?? {})) {
for (const content of Object.values(response.content ?? {})) {

View file

@ -1019,7 +1019,7 @@ export class Workspace extends HeyApiClient {
parameters?: {
directory?: string
workspace?: string
id?: string
id?: string | null
sessionID?: string
},
options?: Options<never, ThrowOnError>,

View file

@ -6656,7 +6656,7 @@ export type ExperimentalWorkspaceRemoveResponse =
export type ExperimentalWorkspaceWarpData = {
body?: {
id: string
id: string | null
sessionID: string
}
path?: never