fix(session): respect directory filter with workspaces (#30804)
This commit is contained in:
parent
d5b205657f
commit
015e79fa59
2 changed files with 30 additions and 5 deletions
|
|
@ -1013,7 +1013,7 @@ function listByProject(
|
||||||
: or(...conds)!,
|
: or(...conds)!,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (input.scope !== "project" && !input.experimentalWorkspaces) {
|
} else if (input.scope !== "project") {
|
||||||
if (input.directory) {
|
if (input.directory) {
|
||||||
conditions.push(eq(SessionTable.directory, input.directory))
|
conditions.push(eq(SessionTable.directory, input.directory))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { RuntimeFlags } from "@/effect/runtime-flags"
|
||||||
import { BackgroundJob } from "@/background/job"
|
import { BackgroundJob } from "@/background/job"
|
||||||
|
|
||||||
void Log.init({ print: false })
|
void Log.init({ print: false })
|
||||||
const it = testEffect(
|
const layer = (experimentalWorkspaces: boolean) =>
|
||||||
Layer.mergeAll(
|
Layer.mergeAll(
|
||||||
Database.defaultLayer,
|
Database.defaultLayer,
|
||||||
SessionNs.layer.pipe(
|
SessionNs.layer.pipe(
|
||||||
|
|
@ -25,11 +25,12 @@ const it = testEffect(
|
||||||
Layer.provide(Database.defaultLayer),
|
Layer.provide(Database.defaultLayer),
|
||||||
Layer.provide(EventV2Bridge.defaultLayer),
|
Layer.provide(EventV2Bridge.defaultLayer),
|
||||||
Layer.provide(SessionProjector.defaultLayer),
|
Layer.provide(SessionProjector.defaultLayer),
|
||||||
Layer.provide(RuntimeFlags.layer({ experimentalWorkspaces: false })),
|
Layer.provide(RuntimeFlags.layer({ experimentalWorkspaces })),
|
||||||
Layer.provide(BackgroundJob.defaultLayer),
|
Layer.provide(BackgroundJob.defaultLayer),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
const it = testEffect(layer(false))
|
||||||
|
const itWorkspaces = testEffect(layer(true))
|
||||||
|
|
||||||
const withSession = (input?: Parameters<SessionNs.Interface["create"]>[0]) =>
|
const withSession = (input?: Parameters<SessionNs.Interface["create"]>[0]) =>
|
||||||
Effect.acquireRelease(SessionNs.use.create(input), (created) =>
|
Effect.acquireRelease(SessionNs.use.create(input), (created) =>
|
||||||
|
|
@ -99,6 +100,30 @@ describe("session.list", () => {
|
||||||
{ git: true },
|
{ git: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
itWorkspaces.instance(
|
||||||
|
"filters by directory when experimental workspaces are enabled",
|
||||||
|
() =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const test = yield* TestInstance
|
||||||
|
yield* Effect.promise(() => mkdir(path.join(test.directory, "packages", "opencode"), { recursive: true }))
|
||||||
|
yield* Effect.promise(() => mkdir(path.join(test.directory, "packages", "app"), { recursive: true }))
|
||||||
|
|
||||||
|
const current = yield* withSession({ title: "current" }).pipe(
|
||||||
|
provideInstance(path.join(test.directory, "packages", "opencode")),
|
||||||
|
)
|
||||||
|
const sibling = yield* withSession({ title: "sibling" }).pipe(
|
||||||
|
provideInstance(path.join(test.directory, "packages", "app")),
|
||||||
|
)
|
||||||
|
|
||||||
|
const ids = (yield* SessionNs.Service.use((session) =>
|
||||||
|
session.list({ directory: path.join(test.directory, "packages", "opencode") }),
|
||||||
|
)).map((session) => session.id)
|
||||||
|
expect(ids).toContain(current.id)
|
||||||
|
expect(ids).not.toContain(sibling.id)
|
||||||
|
}),
|
||||||
|
{ git: true },
|
||||||
|
)
|
||||||
|
|
||||||
it.instance(
|
it.instance(
|
||||||
"matches a session regardless of directory separator on Windows",
|
"matches a session regardless of directory separator on Windows",
|
||||||
() =>
|
() =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue