Compare commits

...

1 Commits

Author SHA1 Message Date
Brendan Allan 7865d69001 fix(app): default project picker to home 2026-07-31 04:07:53 +00:00
10 changed files with 31 additions and 8 deletions
@@ -77,7 +77,7 @@ export function DialogSelectDirectoryV2(props: DialogSelectDirectoryV2Props) {
config: "",
worktree: location.project.directory,
directory: location.directory,
home: "",
home: location.home,
}),
)
.catch(() => undefined),
@@ -68,7 +68,7 @@ export function DialogSelectDirectory(props: DialogSelectDirectoryProps) {
config: "",
worktree: location.project.directory,
directory: location.directory,
home: "",
home: location.home,
}),
)
.catch(() => undefined),
@@ -276,7 +276,7 @@ export const loadPathQuery = (
config: "",
worktree: location.project.directory,
directory: location.directory,
home: "",
home: location.home,
})),
})
+1 -1
View File
@@ -61,7 +61,7 @@ export interface ServerApi<E = never> {
export type Endpoint2_0Input = {
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined
}
export type Endpoint2_0Output = Location.Info
export type Endpoint2_0Output = Location.Details
export type LocationGetOperation<E = never> = (input?: Endpoint2_0Input) => Effect.Effect<Endpoint2_0Output, E>
export interface LocationApi<E = never> {
@@ -2519,6 +2519,7 @@ export type LocationGetOutput = {
directory: string
workspaceID?: string
project: { id: string; directory: string; canonical: string }
home: string
}
export type AgentListInput = {
+2 -2
View File
@@ -1,12 +1,12 @@
import { Context, Effect, Layer } from "effect"
import { Info, Ref, response } from "@opencode-ai/schema/location"
import { Details, Info, Ref, response } from "@opencode-ai/schema/location"
import { Project } from "./project"
import { LayerNode } from "@opencode-ai/util/effect/layer-node"
import { makeLocationNode, tags } from "@opencode-ai/util/effect/app-node"
export * as Location from "./location"
export { Info, Ref, response }
export { Details, Info, Ref, response }
export interface Interface extends Info {
readonly vcs?: Project.Vcs
+1 -1
View File
@@ -30,7 +30,7 @@ export const LocationGroup = HttpApiGroup.make("server.location")
.add(
HttpApiEndpoint.get("location.get", "/api/location", {
query: LocationQuery,
success: Location.Info,
success: Location.Details,
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(
+5
View File
@@ -21,6 +21,11 @@ export class Info extends Schema.Class<Info>("Location.Info")({
}),
}) {}
export class Details extends Schema.Class<Details>("Location.Details")({
...Info.fields,
home: AbsolutePath,
}) {}
export function response<S extends Schema.Top>(data: S) {
return Schema.Struct({ location: Info, data })
}
+14
View File
@@ -0,0 +1,14 @@
import { expect, test } from "bun:test"
import { Schema } from "effect"
import { Location } from "../src/location.js"
const details = {
directory: "/project",
project: { id: "project", directory: "/project", canonical: "/project" },
home: "/home/user",
}
test("Location.Details includes the server home directory", () => {
expect(Schema.decodeUnknownSync(Location.Details)(details).home).toBe("/home/user")
expect(() => Schema.decodeUnknownSync(Location.Details)({ ...details, home: undefined })).toThrow()
})
+4 -1
View File
@@ -1,6 +1,8 @@
import { Location } from "@opencode-ai/core/location"
import { AbsolutePath } from "@opencode-ai/schema/schema"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import os from "node:os"
import { Api } from "../api"
export const LocationHandler = HttpApiBuilder.group(Api, "server.location", (handlers) =>
@@ -8,10 +10,11 @@ export const LocationHandler = HttpApiBuilder.group(Api, "server.location", (han
"location.get",
Effect.fn(function* () {
const location = yield* Location.Service
return new Location.Info({
return new Location.Details({
directory: location.directory,
workspaceID: location.workspaceID,
project: location.project,
home: AbsolutePath.make(os.homedir()),
})
}),
),