Skip to content

Commit 760a216

Browse files
committed
fix(core): use current workspace with /new; fix warping into local project
1 parent 25ecf0a commit 760a216

5 files changed

Lines changed: 28 additions & 7 deletions

File tree

packages/opencode/src/cli/cmd/tui/component/dialog-workspace-create.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ export function DialogWorkspaceSelect(props: {
129129
.toSorted((a, b) => b.time.updated - a.time.updated)
130130
.flatMap((session) => (session.workspaceID ? [session.workspaceID] : []))
131131
.filter((workspaceID, index, list) => list.indexOf(workspaceID) === index)
132-
.slice(0, 3)
133132
.flatMap((workspaceID) => {
134133
const workspace = project.workspace.get(workspaceID)
135-
return workspace ? [workspace] : []
134+
return workspace && project.workspace.status(workspace.id) === "connected" ? [workspace] : []
136135
})
136+
.slice(0, 3)
137137
return [
138138
...list.map((adapter) => ({
139139
title: adapter.name,

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export function Prompt(props: PromptProps) {
182182
const [warpNotice, setWarpNotice] = createSignal<string>()
183183
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
184184
const hasRightContent = createMemo(() => Boolean(props.right))
185+
const defaultWorkspaceID = createMemo(() => props.workspaceID ?? project.workspace.current())
185186

186187
function selectWorkspace(selection: WorkspaceSelection | undefined) {
187188
setWorkspaceSelection(selection)
@@ -861,14 +862,14 @@ export function Prompt(props: PromptProps) {
861862
if (sessionID == null) {
862863
const workspace = workspaceSelection()
863864
const workspaceID = iife(() => {
864-
if (!workspace) return undefined
865+
if (!workspace) return defaultWorkspaceID()
865866
if (workspace.type === "none") return undefined
866867
if (workspace.type === "existing") return workspace.workspaceID
867868
return undefined
868869
})
869870

870871
const res = await sdk.client.session.create({
871-
workspace: props.workspaceID,
872+
workspace: workspaceID,
872873
agent: agent.name,
873874
model: {
874875
providerID: selectedModel.providerID,
@@ -1145,7 +1146,17 @@ export function Prompt(props: PromptProps) {
11451146
| undefined
11461147
>(() => {
11471148
const selected = workspaceSelection()
1148-
if (!selected) return
1149+
if (!selected) {
1150+
const workspaceID = defaultWorkspaceID()
1151+
if (props.sessionID || !workspaceID) return
1152+
const workspace = project.workspace.get(workspaceID)
1153+
return {
1154+
type: "existing",
1155+
workspaceType: workspace?.type ?? "unknown",
1156+
workspaceName: workspace?.name ?? workspaceID,
1157+
status: project.workspace.status(workspaceID) ?? "error",
1158+
}
1159+
}
11491160
if (selected.type === "none") return
11501161
if (props.sessionID && !workspaceCreating()) return
11511162
if (selected.type === "new") {

packages/opencode/src/server/routes/instance/httpapi/public.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ function matchLegacyOpenApi(input: Record<string, unknown>) {
146146
if (properties?.branch) properties.branch = { anyOf: [properties.branch, { type: "null" }] }
147147
if (properties?.extra) properties.extra = { anyOf: [properties.extra, { type: "null" }] }
148148
}
149+
if (path === "/experimental/workspace/warp" && method === "post") {
150+
const ref = operation.requestBody.content?.["application/json"]?.schema?.$ref?.replace(
151+
"#/components/schemas/",
152+
"",
153+
)
154+
const properties = ref
155+
? spec.components?.schemas?.[ref]?.properties
156+
: operation.requestBody.content?.["application/json"]?.schema?.properties
157+
if (properties?.id) properties.id = { anyOf: [properties.id, { type: "null" }] }
158+
}
149159
}
150160
for (const response of Object.values(operation.responses ?? {})) {
151161
for (const content of Object.values(response.content ?? {})) {

packages/sdk/js/src/v2/gen/sdk.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ export class Workspace extends HeyApiClient {
10191019
parameters?: {
10201020
directory?: string
10211021
workspace?: string
1022-
id?: string
1022+
id?: string | null
10231023
sessionID?: string
10241024
},
10251025
options?: Options<never, ThrowOnError>,

packages/sdk/js/src/v2/gen/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6656,7 +6656,7 @@ export type ExperimentalWorkspaceRemoveResponse =
66566656

66576657
export type ExperimentalWorkspaceWarpData = {
66586658
body?: {
6659-
id: string
6659+
id: string | null
66606660
sessionID: string
66616661
}
66626662
path?: never

0 commit comments

Comments
 (0)