fix(core): use current workspace with /new; fix warping into local project (#25894)
This commit is contained in:
@@ -129,11 +129,11 @@ export function DialogWorkspaceSelect(props: {
|
|||||||
.toSorted((a, b) => b.time.updated - a.time.updated)
|
.toSorted((a, b) => b.time.updated - a.time.updated)
|
||||||
.flatMap((session) => (session.workspaceID ? [session.workspaceID] : []))
|
.flatMap((session) => (session.workspaceID ? [session.workspaceID] : []))
|
||||||
.filter((workspaceID, index, list) => list.indexOf(workspaceID) === index)
|
.filter((workspaceID, index, list) => list.indexOf(workspaceID) === index)
|
||||||
.slice(0, 3)
|
|
||||||
.flatMap((workspaceID) => {
|
.flatMap((workspaceID) => {
|
||||||
const workspace = project.workspace.get(workspaceID)
|
const workspace = project.workspace.get(workspaceID)
|
||||||
return workspace ? [workspace] : []
|
return workspace && project.workspace.status(workspace.id) === "connected" ? [workspace] : []
|
||||||
})
|
})
|
||||||
|
.slice(0, 3)
|
||||||
return [
|
return [
|
||||||
...list.map((adapter) => ({
|
...list.map((adapter) => ({
|
||||||
title: adapter.name,
|
title: adapter.name,
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ export function Prompt(props: PromptProps) {
|
|||||||
const [warpNotice, setWarpNotice] = createSignal<string>()
|
const [warpNotice, setWarpNotice] = createSignal<string>()
|
||||||
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
|
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
|
||||||
const hasRightContent = createMemo(() => Boolean(props.right))
|
const hasRightContent = createMemo(() => Boolean(props.right))
|
||||||
|
const defaultWorkspaceID = createMemo(() => props.workspaceID ?? project.workspace.current())
|
||||||
|
|
||||||
function selectWorkspace(selection: WorkspaceSelection | undefined) {
|
function selectWorkspace(selection: WorkspaceSelection | undefined) {
|
||||||
setWorkspaceSelection(selection)
|
setWorkspaceSelection(selection)
|
||||||
@@ -860,14 +861,14 @@ export function Prompt(props: PromptProps) {
|
|||||||
if (sessionID == null) {
|
if (sessionID == null) {
|
||||||
const workspace = workspaceSelection()
|
const workspace = workspaceSelection()
|
||||||
const workspaceID = iife(() => {
|
const workspaceID = iife(() => {
|
||||||
if (!workspace) return undefined
|
if (!workspace) return defaultWorkspaceID()
|
||||||
if (workspace.type === "none") return undefined
|
if (workspace.type === "none") return undefined
|
||||||
if (workspace.type === "existing") return workspace.workspaceID
|
if (workspace.type === "existing") return workspace.workspaceID
|
||||||
return undefined
|
return undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
const res = await sdk.client.session.create({
|
const res = await sdk.client.session.create({
|
||||||
workspace: props.workspaceID,
|
workspace: workspaceID,
|
||||||
agent: agent.name,
|
agent: agent.name,
|
||||||
model: {
|
model: {
|
||||||
providerID: selectedModel.providerID,
|
providerID: selectedModel.providerID,
|
||||||
@@ -1145,7 +1146,17 @@ export function Prompt(props: PromptProps) {
|
|||||||
| undefined
|
| undefined
|
||||||
>(() => {
|
>(() => {
|
||||||
const selected = workspaceSelection()
|
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 (selected.type === "none") return
|
||||||
if (props.sessionID && !workspaceCreating()) return
|
if (props.sessionID && !workspaceCreating()) return
|
||||||
if (selected.type === "new") {
|
if (selected.type === "new") {
|
||||||
|
|||||||
@@ -146,6 +146,16 @@ function matchLegacyOpenApi(input: Record<string, unknown>) {
|
|||||||
if (properties?.branch) properties.branch = { anyOf: [properties.branch, { type: "null" }] }
|
if (properties?.branch) properties.branch = { anyOf: [properties.branch, { type: "null" }] }
|
||||||
if (properties?.extra) properties.extra = { anyOf: [properties.extra, { 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 response of Object.values(operation.responses ?? {})) {
|
||||||
for (const content of Object.values(response.content ?? {})) {
|
for (const content of Object.values(response.content ?? {})) {
|
||||||
|
|||||||
@@ -1019,7 +1019,7 @@ export class Workspace extends HeyApiClient {
|
|||||||
parameters?: {
|
parameters?: {
|
||||||
directory?: string
|
directory?: string
|
||||||
workspace?: string
|
workspace?: string
|
||||||
id?: string
|
id?: string | null
|
||||||
sessionID?: string
|
sessionID?: string
|
||||||
},
|
},
|
||||||
options?: Options<never, ThrowOnError>,
|
options?: Options<never, ThrowOnError>,
|
||||||
|
|||||||
@@ -6656,7 +6656,7 @@ export type ExperimentalWorkspaceRemoveResponse =
|
|||||||
|
|
||||||
export type ExperimentalWorkspaceWarpData = {
|
export type ExperimentalWorkspaceWarpData = {
|
||||||
body?: {
|
body?: {
|
||||||
id: string
|
id: string | null
|
||||||
sessionID: string
|
sessionID: string
|
||||||
}
|
}
|
||||||
path?: never
|
path?: never
|
||||||
|
|||||||
Reference in New Issue
Block a user