diff --git a/scripts/scenarios/start-app.ts b/scripts/scenarios/start-app.ts index 5dee3f26c1..3613273c17 100644 --- a/scripts/scenarios/start-app.ts +++ b/scripts/scenarios/start-app.ts @@ -17,7 +17,7 @@ import * as Stream from "effect/Stream"; import { Argument, Command } from "effect/cli"; import { ChildProcess, ChildProcessSpawner } from "effect/process"; -import { ScenarioError } from "./shell.ts"; +import { run, ScenarioError } from "./shell.ts"; // The dev runner's web port is 5733 plus an offset. Mirror of BASE_WEB_PORT in dev-runner.ts. const BASE_WEB_PORT = 5733; @@ -52,7 +52,7 @@ esac const encodeSettings = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown)); -const prepareHome = Effect.fn("startApp.prepareHome")(function* (home: string) { +const prepareHome = Effect.fn("startApp.prepareHome")(function* (home: string, revision: string) { const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; yield* fs.remove(home, { recursive: true, force: true }); @@ -60,15 +60,20 @@ const prepareHome = Effect.fn("startApp.prepareHome")(function* (home: string) { yield* fs.makeDirectory(path.join(home, "bin")); for (const command of ["hostnamectl", "scutil"]) { const shim = path.join(home, "bin", command); - yield* fs.writeFileString(shim, HOST_LABEL_SHIM); + yield* fs.writeFileString(shim, HOST_LABEL_SHIM.replaceAll('echo "Scenario"', `echo "Web ${revision}"`)); yield* fs.chmod(shim, 0o755); } + const shell = path.join(home, "bin/scenario-shell"); + yield* fs.writeFileString(shell, "#!/bin/sh\nexport PS1='$ '\nexec /bin/bash --noprofile --norc -i\n"); + yield* fs.chmod(shell, 0o755); const noModel = path.join(home, "bin/no-model"); yield* fs.writeFileString(noModel, "#!/bin/sh\necho 'scenarios run no model' >&2\nexit 1\n"); yield* fs.chmod(noModel, 0o755); yield* fs.writeFileString( path.join(home, "userdata/settings.json"), yield* encodeSettings({ + automaticGitFetchInterval: 0, + backgroundActivity: { profile: "custom", baseProfile: "balanced", overrides: { automaticGitFetchInterval: 0 } }, defaultModelSelection: REPLAY, providerInstances: Object.fromEntries( REAL_PROVIDERS.map((driver) => [ @@ -125,11 +130,13 @@ const startApp = Effect.fn("startApp")(function* (input: { const node = yield* HostProcess.ExecutablePath; const checkout = yield* HostProcess.WorkingDirectory; const hostEnvironment = yield* HostProcess.Environment; - yield* prepareHome(input.home); + const revision = (yield* run("git", ["rev-parse", "--short=10", "HEAD"], { cwd: checkout })).stdout.trim(); + yield* prepareHome(input.home, revision); const env = { ...hostEnvironment, PATH: `${path.join(input.home, "bin")}:${hostEnvironment.PATH ?? ""}`, T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "0", + SHELL: path.join(input.home, "bin/scenario-shell"), }; const devRunner = (mode: string, args: ReadonlyArray) => [ "scripts/dev-runner.ts",