fix(app): default project picker to home

This commit is contained in:
Brendan Allan 2026-07-31 04:07:43 +00:00 committed by opencode-agent[bot]
commit 7865d69001
10 changed files with 31 additions and 8 deletions

View file

@ -77,7 +77,7 @@ export function DialogSelectDirectoryV2(props: DialogSelectDirectoryV2Props) {
config: "", config: "",
worktree: location.project.directory, worktree: location.project.directory,
directory: location.directory, directory: location.directory,
home: "", home: location.home,
}), }),
) )
.catch(() => undefined), .catch(() => undefined),

View file

@ -68,7 +68,7 @@ export function DialogSelectDirectory(props: DialogSelectDirectoryProps) {
config: "", config: "",
worktree: location.project.directory, worktree: location.project.directory,
directory: location.directory, directory: location.directory,
home: "", home: location.home,
}), }),
) )
.catch(() => undefined), .catch(() => undefined),

View file

@ -276,7 +276,7 @@ export const loadPathQuery = (
config: "", config: "",
worktree: location.project.directory, worktree: location.project.directory,
directory: location.directory, directory: location.directory,
home: "", home: location.home,
})), })),
}) })

View file

@ -61,7 +61,7 @@ export interface ServerApi<E = never> {
export type Endpoint2_0Input = { export type Endpoint2_0Input = {
readonly location?: { readonly directory?: string | undefined; readonly workspace?: string | undefined } | undefined 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 type LocationGetOperation<E = never> = (input?: Endpoint2_0Input) => Effect.Effect<Endpoint2_0Output, E>
export interface LocationApi<E = never> { export interface LocationApi<E = never> {

View file

@ -2519,6 +2519,7 @@ export type LocationGetOutput = {
directory: string directory: string
workspaceID?: string workspaceID?: string
project: { id: string; directory: string; canonical: string } project: { id: string; directory: string; canonical: string }
home: string
} }
export type AgentListInput = { export type AgentListInput = {

View file

@ -1,12 +1,12 @@
import { Context, Effect, Layer } from "effect" 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 { Project } from "./project"
import { LayerNode } from "@opencode-ai/util/effect/layer-node" import { LayerNode } from "@opencode-ai/util/effect/layer-node"
import { makeLocationNode, tags } from "@opencode-ai/util/effect/app-node" import { makeLocationNode, tags } from "@opencode-ai/util/effect/app-node"
export * as Location from "./location" export * as Location from "./location"
export { Info, Ref, response } export { Details, Info, Ref, response }
export interface Interface extends Info { export interface Interface extends Info {
readonly vcs?: Project.Vcs readonly vcs?: Project.Vcs

View file

@ -30,7 +30,7 @@ export const LocationGroup = HttpApiGroup.make("server.location")
.add( .add(
HttpApiEndpoint.get("location.get", "/api/location", { HttpApiEndpoint.get("location.get", "/api/location", {
query: LocationQuery, query: LocationQuery,
success: Location.Info, success: Location.Details,
}) })
.annotateMerge(locationQueryOpenApi) .annotateMerge(locationQueryOpenApi)
.annotateMerge( .annotateMerge(

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) { export function response<S extends Schema.Top>(data: S) {
return Schema.Struct({ location: Info, data }) return Schema.Struct({ location: Info, data })
} }

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()
})

View file

@ -1,6 +1,8 @@
import { Location } from "@opencode-ai/core/location" import { Location } from "@opencode-ai/core/location"
import { AbsolutePath } from "@opencode-ai/schema/schema"
import { Effect } from "effect" import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi" import { HttpApiBuilder } from "effect/unstable/httpapi"
import os from "node:os"
import { Api } from "../api" import { Api } from "../api"
export const LocationHandler = HttpApiBuilder.group(Api, "server.location", (handlers) => export const LocationHandler = HttpApiBuilder.group(Api, "server.location", (handlers) =>
@ -8,10 +10,11 @@ export const LocationHandler = HttpApiBuilder.group(Api, "server.location", (han
"location.get", "location.get",
Effect.fn(function* () { Effect.fn(function* () {
const location = yield* Location.Service const location = yield* Location.Service
return new Location.Info({ return new Location.Details({
directory: location.directory, directory: location.directory,
workspaceID: location.workspaceID, workspaceID: location.workspaceID,
project: location.project, project: location.project,
home: AbsolutePath.make(os.homedir()),
}) })
}), }),
), ),