Repository navigation
feat(runner): run one opted-in agent on the PTY runner (#240) #241
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
523d594
refactor(runner): promote the runner out of tests for slice 2 (#240)
simon-inkie d0a8785
docs(specs): record commit for #240
simon-inkie 3293d06
feat(runner): PTY registry, opt-in, lock, launch environment and shut…
simon-inkie dfd3d28
docs(specs): record commit for #240
simon-inkie 0412b72
feat(base): skip and refuse PTY-runner agents in boot, push and provi…
simon-inkie 2acd807
docs(specs): record commit for #240
simon-inkie e43efde
Merge step 3 guards into the slice 2 branch (#240)
simon-inkie 5bec1b0
feat(runner): route send, push and terminal view through the PTY runn…
simon-inkie 22d7411
docs(specs): record commit for #240
simon-inkie b7f3031
Merge origin/main into pty-slice-2 (#240)
simon-inkie 4af6d74
fix(runner): keep the inbox push guard working inside the PTY child, …
simon-inkie b357555
docs(specs): record commit for #240
simon-inkie 7db30a6
fix(runner): make lock recovery and cleanup crash-safe (#240)
simon-inkie b6de9d3
docs(specs): record commit for #240
simon-inkie 098986b
fix(runner): recover lock phase and failure latches after transient e…
simon-inkie c783bcb
docs(specs): record commit for #240
simon-inkie 64f6f47
fix(runner): base guards key on the .runner file, stop works after op…
simon-inkie 13e9c22
docs(specs): record commit for #240
simon-inkie f906fe6
test(base): reset push_rc before each invocation in the PTY guard cas…
simon-inkie 24dd805
docs(specs): record commit for #240
simon-inkie ec075e2
merge: origin/main into pty-slice-2
simon-inkie 015c08b
fix(runner): address CodeRabbit lock and recovery findings (#241)
simon-inkie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { PassThrough } from "node:stream"; | ||
| import { createReadableStreamFromReadable } from "@react-router/node"; | ||
| import { isbot } from "isbot"; | ||
| import { renderToPipeableStream } from "react-dom/server"; | ||
| import { ServerRouter, type EntryContext } from "react-router"; | ||
| import { runnerRegistry } from "./lib/runner/registry.server.js"; | ||
|
|
||
| export const runnerLifecycle = { | ||
| recover: () => runnerRegistry.recover(), | ||
| shutdown: () => runnerRegistry.shutdown(), | ||
| }; | ||
|
|
||
| export const streamTimeout = 5_000; | ||
|
|
||
| export default function handleRequest( | ||
| request: Request, | ||
| responseStatusCode: number, | ||
| responseHeaders: Headers, | ||
| routerContext: EntryContext, | ||
| ) { | ||
| if (request.method.toUpperCase() === "HEAD") { | ||
| return new Response(null, { status: responseStatusCode, headers: responseHeaders }); | ||
| } | ||
|
|
||
| return new Promise<Response>((resolve, reject) => { | ||
| let shellRendered = false; | ||
| const userAgent = request.headers.get("user-agent"); | ||
| const readyOption = (userAgent && isbot(userAgent)) || routerContext.isSpaMode ? "onAllReady" : "onShellReady"; | ||
| const timeout = setTimeout(() => abort(), streamTimeout + 1000); | ||
| const { pipe, abort } = renderToPipeableStream( | ||
| <ServerRouter context={routerContext} url={request.url} />, | ||
| { | ||
| [readyOption]() { | ||
| shellRendered = true; | ||
| const body = new PassThrough({ | ||
| final(callback) { | ||
| clearTimeout(timeout); | ||
| callback(); | ||
| }, | ||
| }); | ||
| responseHeaders.set("Content-Type", "text/html"); | ||
| pipe(body); | ||
| resolve(new Response(createReadableStreamFromReadable(body), { | ||
| headers: responseHeaders, status: responseStatusCode, | ||
| })); | ||
| }, | ||
| onShellError(error: unknown) { | ||
| clearTimeout(timeout); | ||
| reject(error); | ||
| }, | ||
| onError(error: unknown) { | ||
| responseStatusCode = 500; | ||
| if (shellRendered) console.error(error); | ||
| }, | ||
| }, | ||
| ); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.