-
Notifications
You must be signed in to change notification settings - Fork 4
Integrate 8 upstream commits (security, Claude git text gen, UI fixes) #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d644795
f0e57b3
24b3b5c
2ad3405
ad908bc
0cb0433
273bb8d
8caad87
9597c26
6b03780
77a7335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| AGENTS.md | ||
| AGENTS.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import * as NFS from "node:fs"; | ||
| import * as path from "node:path"; | ||
| import { execFileSync, spawn } from "node:child_process"; | ||
| import * as NodeServices from "@effect/platform-node/NodeServices"; | ||
| import { assert, it } from "@effect/vitest"; | ||
| import { FileSystem, Schema } from "effect"; | ||
| import * as Duration from "effect/Duration"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Fiber from "effect/Fiber"; | ||
| import { TestClock } from "effect/testing"; | ||
|
|
||
| import { readBootstrapEnvelope, resolveFdPath } from "./bootstrap"; | ||
| import { assertNone, assertSome } from "@effect/vitest/utils"; | ||
|
|
||
| const TestEnvelopeSchema = Schema.Struct({ mode: Schema.String }); | ||
|
|
||
| it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => { | ||
| it.effect("uses platform-specific fd paths", () => | ||
| Effect.sync(() => { | ||
| assert.equal(resolveFdPath(3, "linux"), "/proc/self/fd/3"); | ||
| assert.equal(resolveFdPath(3, "darwin"), "/dev/fd/3"); | ||
| assert.equal(resolveFdPath(3, "win32"), undefined); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("reads a bootstrap envelope from a provided fd", () => | ||
| Effect.gen(function* () { | ||
| const fs = yield* FileSystem.FileSystem; | ||
| const filePath = yield* fs.makeTempFileScoped({ prefix: "t3-bootstrap-", suffix: ".ndjson" }); | ||
|
|
||
| yield* fs.writeFileString( | ||
| filePath, | ||
| `${yield* Schema.encodeEffect(Schema.fromJsonString(TestEnvelopeSchema))({ | ||
| mode: "desktop", | ||
| })}\n`, | ||
| ); | ||
|
|
||
| const fd = yield* Effect.acquireRelease( | ||
| Effect.sync(() => NFS.openSync(filePath, "r")), | ||
| (fd) => Effect.sync(() => NFS.closeSync(fd)), | ||
| ); | ||
|
|
||
| const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 }); | ||
| assertSome(payload, { | ||
| mode: "desktop", | ||
| }); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("returns none when the fd is unavailable", () => | ||
| Effect.gen(function* () { | ||
| const fd = NFS.openSync("/dev/null", "r"); | ||
| NFS.closeSync(fd); | ||
|
|
||
| const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 }); | ||
| assertNone(payload); | ||
| }), | ||
| ); | ||
|
|
||
| it.effect("returns none when the bootstrap read times out before any value arrives", () => | ||
| Effect.gen(function* () { | ||
| const fs = yield* FileSystem.FileSystem; | ||
| const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" }); | ||
| const fifoPath = path.join(tempDir, "bootstrap.pipe"); | ||
|
|
||
| yield* Effect.sync(() => execFileSync("mkfifo", [fifoPath])); | ||
|
|
||
| const _writer = yield* Effect.acquireRelease( | ||
| Effect.sync(() => | ||
| spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], { | ||
| stdio: ["ignore", "ignore", "ignore"], | ||
| }), | ||
| ), | ||
| (writer) => | ||
| Effect.sync(() => { | ||
| writer.kill("SIGKILL"); | ||
| }), | ||
| ); | ||
|
|
||
| const fd = yield* Effect.acquireRelease( | ||
| Effect.sync(() => NFS.openSync(fifoPath, "r")), | ||
| (fd) => Effect.sync(() => NFS.closeSync(fd)), | ||
| ); | ||
|
|
||
| const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { | ||
| timeoutMs: 100, | ||
| }).pipe(Effect.forkScoped); | ||
|
|
||
| yield* Effect.yieldNow; | ||
| yield* TestClock.adjust(Duration.millis(100)); | ||
|
|
||
| const payload = yield* Fiber.join(fiber); | ||
| assertNone(payload); | ||
| }).pipe(Effect.provide(TestClock.layer())), | ||
| ); | ||
|
Comment on lines
+50
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard these fd tests on Windows. These cases use 🤖 Prompt for AI Agents |
||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.