mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-08 18:40:29 +00:00
fix(core): use current workspace with /new; fix warping into local project (#25894)
This commit is contained in:
parent
8e182c7782
commit
12f3d1f505
5 changed files with 28 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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") {
|
||||
|
|
|
|||
|
|
@ -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 ?? {})) {
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -6656,7 +6656,7 @@ export type ExperimentalWorkspaceRemoveResponse =
|
|||
|
||||
export type ExperimentalWorkspaceWarpData = {
|
||||
body?: {
|
||||
id: string
|
||||
id: string | null
|
||||
sessionID: string
|
||||
}
|
||||
path?: never
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue