feat(pty): expose shells and connect tokens
This commit is contained in:
parent
9de001d92f
commit
dbe7b937ef
6 changed files with 50 additions and 4 deletions
|
|
@ -78,6 +78,7 @@ export class ExitedError extends Schema.TaggedErrorClass<ExitedError>()("Pty.Exi
|
|||
}) {}
|
||||
|
||||
export interface Interface {
|
||||
readonly shells: () => Effect.Effect<ReadonlyArray<Pty.Shell>>
|
||||
readonly list: () => Effect.Effect<Info[]>
|
||||
readonly get: (id: PtyID) => Effect.Effect<Info, NotFoundError>
|
||||
readonly create: (input: CreateInput) => Effect.Effect<Info>
|
||||
|
|
@ -158,6 +159,10 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
|
|||
return Array.from(sessions.values()).map((session) => session.info)
|
||||
})
|
||||
|
||||
const shells = Effect.fn("Pty.shells")(function* () {
|
||||
return yield* Effect.promise(() => ShellSelect.list(options))
|
||||
})
|
||||
|
||||
const get = Effect.fn("Pty.get")(function* (id: PtyID) {
|
||||
return (yield* requireSession(id)).info
|
||||
})
|
||||
|
|
@ -309,7 +314,7 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
|
|||
}
|
||||
})
|
||||
|
||||
return Service.of({ list, get, create, update, remove, write, attach })
|
||||
return Service.of({ shells, list, get, create, update, remove, write, attach })
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,18 @@ const waitForOutput = (output: Queue.Queue<string>, text: string) =>
|
|||
}),
|
||||
)
|
||||
|
||||
describe("Pty.shells", () => {
|
||||
it.live("lists available shells", () =>
|
||||
Effect.gen(function* () {
|
||||
const pty = yield* Pty.Service
|
||||
const shells = yield* pty.shells()
|
||||
|
||||
expect(shells.length).toBeGreaterThan(0)
|
||||
expect(shells.every((shell) => shell.path && shell.name && typeof shell.acceptable === "boolean")).toBe(true)
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe("pty", () => {
|
||||
it.live("returns typed not found errors for missing sessions", () =>
|
||||
Effect.gen(function* () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue