GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into codex/fix-23505-omp-e… · pingdotgg/t3code@ebaa0e7
File treeExpand file treeCollapse file tree Open diff view settings provider-acp-registry/src/server provider-cursor/src/server
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/ci.yml +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -504,8 +504,9 @@ jobs: | 504 | 504 | T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md | 505 | 505 | T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json | 506 | 506 | T3CODE_TRANSFER_BUDGET_SCENARIOS_PATH: ${{ runner.temp }}/thread-transfer-scenarios.json | | 507 | + # One process per file spends ~2s starting before its tests run; one file per vCPU overlaps that. | 507 | 508 | run: >- | 508 | | - vp run test:cached -- --shard ${{ matrix.shard }}/${{ strategy.job-total }} | | 509 | + vp run test:cached -- --shard ${{ matrix.shard }}/${{ strategy.job-total }} --concurrency 4 | 509 | 510 | --uncached apps/server/integration/transferBudgetV2.integration.test.ts | 510 | 511 | --verify-hits 1 apps/server | 511 | 512 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/updates/DesktopUpdates.test.ts +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -247,6 +247,26 @@ describe("DesktopUpdates", () => { | 247 | 247 | ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer))); | 248 | 248 | }); | 249 | 249 |
| | 250 | + it.effect("checks shortly after startup and then every four hours", () => { | | 251 | + const harness = makeHarness(); | | 252 | + | | 253 | + return Effect.scoped( | | 254 | + Effect.gen(function* () { | | 255 | + const updates = yield* DesktopUpdates.DesktopUpdates; | | 256 | + yield* updates.configure; | | 257 | + | | 258 | + yield* TestClock.adjust("15 seconds"); | | 259 | + assert.equal(harness.checkCount(), 1); | | 260 | + | | 261 | + yield* TestClock.adjust("3 hours"); | | 262 | + assert.equal(harness.checkCount(), 1); | | 263 | + | | 264 | + yield* TestClock.adjust("1 hour"); | | 265 | + assert.equal(harness.checkCount(), 2); | | 266 | + }), | | 267 | + ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer))); | | 268 | + }); | | 269 | + | 250 | 270 | it.effect( | 251 | 271 | "rejects install while a refresh check is in progress and releases the reservation", | 252 | 272 | () => | |
Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/updates/DesktopUpdates.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,7 @@ import { | 60 | 60 | const CHANNEL_CHANGE_RETRY_DELAY = Duration.seconds(1); | 61 | 61 | const CHANNEL_CHANGE_RETRIES = 30; | 62 | 62 | const AUTO_UPDATE_STARTUP_DELAY = "15 seconds"; | 63 | | -const AUTO_UPDATE_POLL_INTERVAL = "4 minutes"; | | 63 | +const AUTO_UPDATE_POLL_INTERVAL = "4 hours"; | 64 | 64 | const PREPARED_INSTALL_CHECK_WAIT = Duration.seconds(90); | 65 | 65 |
| 66 | 66 | type UpdateAction = "check" | "download" | "install" | "install-recovery" | "channel"; | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/threads/ThreadRouteScreen.tsx +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1071,9 +1071,7 @@ function ThreadRouteContent( | 1071 | 1071 | onRemoveDraftImage={composer.onRemoveDraftImage} | 1072 | 1072 | serverConfig={serverConfig} | 1073 | 1073 | onStopThread={awaitingBootstrapTurn ? handleCancelWorktreeSetup : handleStopThread} | 1074 | | - onResumeQueue={ | 1075 | | - composer.queueHeld || composer.resumableRunId !== null ? handleResumeQueue : null | 1076 | | - } | | 1074 | + onResumeQueue={composer.canResume ? handleResumeQueue : null} | 1077 | 1075 | onSendMessage={composer.onSendMessage} | 1078 | 1076 | offersSideChat={composer.sideChatUnavailableReason === null} | 1079 | 1077 | onReconnectEnvironment={handleReconnectEnvironment} | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/state/use-thread-composer-state.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,7 @@ import { | 13 | 13 | isDetailBehindShell, | 14 | 14 | } from "@t3tools/client-runtime/state/thread-activity-announcement"; | 15 | 15 | import { | | 16 | + canResumeThread, | 16 | 17 | deriveProviderSubagentStatus, | 17 | 18 | deriveProviderExtensionStatuses, | 18 | 19 | deriveResumableRunId, | @@ -401,6 +402,9 @@ export function useThreadComposerState(input: { | 401 | 402 | const resumableRunId = selectedThreadProjection | 402 | 403 | ? deriveResumableRunId(selectedThreadProjection.projection, selectedThreadRuntime) | 403 | 404 | : null; | | 405 | + const canResume = selectedThreadProjection | | 406 | + ? canResumeThread(selectedThreadProjection.projection, resumableRunId, queueHeld) | | 407 | + : queueHeld; | 404 | 408 |
| 405 | 409 | const runlessWorkStartedAt = selectedThreadProjection | 406 | 410 | ? deriveRunlessWorkStartedAt(selectedThreadProjection.projection) | @@ -919,6 +923,7 @@ export function useThreadComposerState(input: { | 919 | 923 | canSteerActiveTurn, | 920 | 924 | queueHeld, | 921 | 925 | resumableRunId, | | 926 | + canResume, | 922 | 927 | queuedRunEdit, | 923 | 928 | isSavingQueuedEdit, | 924 | 929 | cancelQueuedRunEdit, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/scripts/acp-mock-agent.ts +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,12 @@ const copilotModesProfile = process.env.T3_ACP_COPILOT_MODES === "1"; | 23 | 23 | const copilotModeId = (name: string) => | 24 | 24 | `https://agentclientprotocol.com/protocol/session-modes#${name}`; | 25 | 25 | const modeOptionCategory = process.env.T3_ACP_MODE_OPTION_CATEGORY ?? "mode"; | | 26 | +// Comma-separated command names the mock advertises, so `/compact` support is testable. | | 27 | +const advertisedCommandNames = (process.env.T3_ACP_AVAILABLE_COMMANDS ?? "") | | 28 | + .split(",") | | 29 | + .map((name) => name.trim()) | | 30 | + .filter((name) => name.length > 0); | | 31 | +const loadedCommandNames = process.env.T3_ACP_LOADED_COMMANDS?.split(",").filter(Boolean); | 26 | 32 | const emitToolCalls = process.env.T3_ACP_EMIT_TOOL_CALLS === "1"; | 27 | 33 | const emitInterleavedAssistantToolCalls = | 28 | 34 | process.env.T3_ACP_EMIT_INTERLEAVED_ASSISTANT_TOOL_CALLS === "1"; | @@ -610,6 +616,18 @@ const program = Effect.gen(function* () { | 610 | 616 | if (antigravityProfile) { | 611 | 617 | yield* publishAntigravityCommands(sessionId); | 612 | 618 | } | | 619 | + if (advertisedCommandNames.length > 0) { | | 620 | + yield* agent.client.sessionUpdate({ | | 621 | + sessionId, | | 622 | + update: { | | 623 | + sessionUpdate: "available_commands_update", | | 624 | + availableCommands: advertisedCommandNames.map((name) => ({ | | 625 | + name, | | 626 | + description: `${name} command`, | | 627 | + })), | | 628 | + }, | | 629 | + }); | | 630 | + } | 613 | 631 | return { | 614 | 632 | sessionId, | 615 | 633 | configOptions: configOptions(), | @@ -665,6 +683,15 @@ const program = Effect.gen(function* () { | 665 | 683 | yield* agent.handleLoadSession((request) => | 666 | 684 | Effect.gen(function* () { | 667 | 685 | const requestedSessionId = String(request.sessionId ?? sessionId); | | 686 | + if (loadedCommandNames !== undefined) { | | 687 | + yield* agent.client.sessionUpdate({ | | 688 | + sessionId: requestedSessionId, | | 689 | + update: { | | 690 | + sessionUpdate: "available_commands_update", | | 691 | + availableCommands: loadedCommandNames.map((name) => ({ name, description: name })), | | 692 | + }, | | 693 | + }); | | 694 | + } | 668 | 695 | if (failLoadSession) { | 669 | 696 | return yield* AcpError.AcpRequestError.internalError("Mock load session failure"); | 670 | 697 | } | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/scripts/record-cursor-agent-sdk-replay-fixture.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -219,6 +219,6 @@ const recordCursorReplayCommand = Command.make( | 219 | 219 | ); | 220 | 220 |
| 221 | 221 | Command.run(recordCursorReplayCommand, { version: "0.0.0" }).pipe( | 222 | | - Effect.provide(Layer.mergeAll(CursorSdk.layer, NodeServices.layer)), | | 222 | + Effect.provide(CursorSdk.layer.pipe(Layer.provideMerge(NodeServices.layer))), | 223 | 223 | NodeRuntime.runMain, | 224 | 224 | ); |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/cli/doctor.test.ts +85-17Lines changed: 85 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; | 1 | 2 | import * as NodeServices from "@effect/platform-node/NodeServices"; | | 3 | +import * as HostProcess from "@t3tools/shared/HostProcess"; | 2 | 4 | import { assert, it } from "@effect/vitest"; | 3 | 5 | import * as Console from "effect/Console"; | 4 | 6 | import * as Effect from "effect/Effect"; | | 7 | +import * as FileSystem from "effect/FileSystem"; | 5 | 8 | import * as Layer from "effect/Layer"; | | 9 | +import * as Path from "effect/Path"; | 6 | 10 | import * as TestClock from "effect/testing/TestClock"; | 7 | 11 |
| 8 | 12 | import * as BootService from "../cloud/bootService.ts"; | 9 | 13 | import { runDoctor } from "./doctor.ts"; | 10 | 14 | import { DatabaseMaintenance } from "../persistence/DatabaseMaintenance.ts"; | | 15 | +import * as ProcessRunner from "../processRunner.ts"; | | 16 | +import { acquireServerOwnership } from "../serverOwnership.ts"; | | 17 | +import { makePersistedServerRuntimeState } from "../serverRuntimeState.ts"; | | 18 | + | | 19 | +// An empty home, so no boot service unit installed on this machine is read. | | 20 | +const layerHost = Layer.mergeAll( | | 21 | + ProcessRunner.layer, | | 22 | + Layer.effect( | | 23 | + HostProcess.HomeDirectory, | | 24 | + Effect.gen(function* () { | | 25 | + return yield* (yield* FileSystem.FileSystem).makeTempDirectoryScoped(); | | 26 | + }), | | 27 | + ), | | 28 | + Layer.succeed(HostProcess.Environment, {}), | | 29 | +).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))); | 11 | 30 |
| 12 | 31 | it.effect( | 13 | | - "--fix reclaims space with the service paused and keeps the V1 database, and --dry-run changes nothing", | | 32 | + "--fix locks the home while the service is paused, names a server that holds it, keeps the V1 database, and --dry-run changes nothing", | 14 | 33 | () => | 15 | 34 | Effect.gen(function* () { | | 35 | + const fs = yield* FileSystem.FileSystem; | | 36 | + const path = yield* Path.Path; | | 37 | + const stateDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-doctor-" }); | | 38 | + const serverRuntimeStatePath = path.join(stateDir, "server-runtime.json"); | 16 | 39 | const calls: string[] = []; | | 40 | + const services = | | 41 | + yield* Effect.context<Effect.Services<ReturnType<typeof acquireServerOwnership>>>(); | | 42 | + // Stands in for a server launched for the same home, for example over SSH. | | 43 | + const startServer = Effect.scoped(acquireServerOwnership(serverRuntimeStatePath)).pipe( | | 44 | + Effect.result, | | 45 | + Effect.map((result) => | | 46 | + calls.push(result._tag === "Success" ? "server started" : result.failure._tag), | | 47 | + ), | | 48 | + Effect.provide(services), | | 49 | + ); | 17 | 50 | const doctor = (dryRun: boolean) => | 18 | | - runDoctor("/test/statev2.sqlite", { fix: true, dryRun, interactive: false }).pipe( | | 51 | + runDoctor( | | 52 | + { dbPath: path.join(stateDir, "statev2.sqlite"), serverRuntimeStatePath }, | | 53 | + { fix: true, dryRun, interactive: false }, | | 54 | + ).pipe( | 19 | 55 | Effect.provide( | 20 | 56 | Layer.mergeAll( | 21 | | - NodeServices.layer, | 22 | 57 | Layer.mock(BootService.BootService)({ | 23 | 58 | withStopped: (operation) => | 24 | 59 | Effect.sync(() => calls.push("pause")).pipe( | @@ -35,15 +70,17 @@ it.effect( | 35 | 70 | legacyDatabaseBytes: 4000, | 36 | 71 | }), | 37 | 72 | compact: () => | 38 | | - Effect.sync(() => { | 39 | | - calls.push("compact"); | 40 | | - return { | 41 | | - beforeBytes: 2000, | 42 | | - afterBytes: 1000, | 43 | | - deletedEventCount: 1, | 44 | | - deletedReceiptCount: 0, | 45 | | - }; | 46 | | - }), | | 73 | + startServer.pipe( | | 74 | + Effect.map(() => { | | 75 | + calls.push("compact"); | | 76 | + return { | | 77 | + beforeBytes: 2000, | | 78 | + afterBytes: 1000, | | 79 | + deletedEventCount: 1, | | 80 | + deletedReceiptCount: 0, | | 81 | + }; | | 82 | + }), | | 83 | + ), | 47 | 84 | removeLegacyDatabase: () => Effect.sync(() => calls.push("remove legacy")), | 48 | 85 | }), | 49 | 86 | ), | @@ -52,8 +89,32 @@ it.effect( | 52 | 89 | yield* doctor(true); | 53 | 90 | assert.deepEqual(calls, []); | 54 | 91 | yield* doctor(false); | 55 | | - assert.deepEqual(calls, ["pause", "compact", "resume"]); | 56 | | - }), | | 92 | + yield* startServer; | | 93 | + assert.deepEqual(calls, [ | | 94 | + "pause", | | 95 | + "ServerAlreadyRunningError", | | 96 | + "compact", | | 97 | + "resume", | | 98 | + "server started", | | 99 | + ]); | | 100 | + | | 101 | + calls.length = 0; | | 102 | + const state = yield* makePersistedServerRuntimeState({ | | 103 | + config: { host: undefined, devUrl: undefined }, | | 104 | + port: 3773, | | 105 | + }); | | 106 | + const refused = yield* Effect.scoped( | | 107 | + acquireServerOwnership(serverRuntimeStatePath).pipe( | | 108 | + Effect.tap((owner) => owner.publish(state)), | | 109 | + Effect.andThen(doctor(false)), | | 110 | + ), | | 111 | + ).pipe(Effect.flip); | | 112 | + assert.equal( | | 113 | + refused.message, | | 114 | + `Stop T3 Code server process ${state.pid}, which the background service did not start, before repairing the database.`, | | 115 | + ); | | 116 | + assert.deepEqual(calls, ["pause", "resume"]); | | 117 | + }).pipe(Effect.provide(layerHost)), | 57 | 118 | ); | 58 | 119 |
| 59 | 120 | it.effect("warns how long reclaiming can take and reports each step with its elapsed time", () => | @@ -65,10 +126,17 @@ it.effect("warns how long reclaiming can take and reports each step with its ela | 65 | 126 | ["rebuild-search", "1 second"], | 66 | 127 | ["checkpoint", "1 second"], | 67 | 128 | ] as const; | 68 | | - yield* runDoctor("/test/statev2.sqlite", { fix: true, dryRun: false, interactive: false }).pipe( | | 129 | + const stateDir = yield* (yield* FileSystem.FileSystem).makeTempDirectoryScoped(); | | 130 | + const path = yield* Path.Path; | | 131 | + yield* runDoctor( | | 132 | + { | | 133 | + dbPath: path.join(stateDir, "statev2.sqlite"), | | 134 | + serverRuntimeStatePath: path.join(stateDir, "server-runtime.json"), | | 135 | + }, | | 136 | + { fix: true, dryRun: false, interactive: false }, | | 137 | + ).pipe( | 69 | 138 | Effect.provide( | 70 | 139 | Layer.mergeAll( | 71 | | - NodeServices.layer, | 72 | 140 | Layer.mock(BootService.BootService)({ | 73 | 141 | withStopped: (operation) => | 74 | 142 | Effect.sync(() => output.push("<pause>")).pipe( | @@ -125,5 +193,5 @@ it.effect("warns how long reclaiming can take and reports each step with its ela | 125 | 193 | ["0:00", "1:05", "12:46", "12:47"], | 126 | 194 | "each compaction step must print one line with the elapsed time as it starts", | 127 | 195 | ); | 128 | | - }), | | 196 | + }).pipe(Effect.provide(layerHost)), | 129 | 197 | ); |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/cli/doctor.ts +41-11Lines changed: 41 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,10 +3,13 @@ import * as Clock from "effect/Clock"; | 3 | 3 | import * as Console from "effect/Console"; | 4 | 4 | import * as Effect from "effect/Effect"; | 5 | 5 | import * as Layer from "effect/Layer"; | | 6 | +import * as Option from "effect/Option"; | 6 | 7 | import { Command, Flag, GlobalFlag, Prompt } from "effect/cli"; | 7 | 8 |
| 8 | 9 | import * as BootService from "../cloud/bootService.ts"; | 9 | 10 | import * as DatabaseMaintenance from "../persistence/DatabaseMaintenance.ts"; | | 11 | +import * as ServerOwnership from "../serverOwnership.ts"; | | 12 | +import { isProcessAlive, readPersistedServerRuntimeState } from "../serverRuntimeState.ts"; | 10 | 13 | import { projectLocationFlags, resolveCliAuthConfig } from "./config.ts"; | 11 | 14 | import * as CliService from "./service.ts"; | 12 | 15 |
| @@ -29,10 +32,37 @@ const COMPACT_STEP_LABELS: Record<DatabaseMaintenance.DatabaseCompactStep, strin | 29 | 32 | checkpoint: "Flushing the write-ahead log", | 30 | 33 | }; | 31 | 34 |
| | 35 | +// Holding the server lock refuses a server launched mid-repair, such as one started over SSH. | | 36 | +// Lock only: acquireServerOwnership would also refuse the older service doctor just stopped. | | 37 | +const lockServerHome = Effect.fn("runDoctor.lockServerHome")(function* (paths: { | | 38 | + readonly dbPath: string; | | 39 | + readonly serverRuntimeStatePath: string; | | 40 | +}) { | | 41 | + yield* ServerOwnership.holdServerOwnershipLock(paths.serverRuntimeStatePath).pipe( | | 42 | + Effect.catchTags({ | | 43 | + ServerAlreadyRunningError: Effect.fn("runDoctor.nameServerHolder")(function* (cause) { | | 44 | + const owner = yield* readPersistedServerRuntimeState(paths.serverRuntimeStatePath).pipe( | | 45 | + Effect.map(Option.filter((state) => isProcessAlive(state.pid))), | | 46 | + Effect.orElseSucceed(() => Option.none()), | | 47 | + ); | | 48 | + return yield* new DatabaseMaintenance.DatabaseInUseError({ | | 49 | + path: paths.dbPath, | | 50 | + cause, | | 51 | + ...(Option.isSome(owner) && { | | 52 | + pid: owner.value.pid, | | 53 | + serviceManaged: owner.value.serviceManaged === true, | | 54 | + }), | | 55 | + }); | | 56 | + }), | | 57 | + }), | | 58 | + ); | | 59 | +}); | | 60 | + | 32 | 61 | export const runDoctor = Effect.fn("runDoctor")(function* ( | 33 | | - databasePath: string, | | 62 | + paths: { readonly dbPath: string; readonly serverRuntimeStatePath: string }, | 34 | 63 | options: { readonly fix: boolean; readonly dryRun: boolean; readonly interactive?: boolean }, | 35 | 64 | ) { | | 65 | + const databasePath = paths.dbPath; | 36 | 66 | const maintenance = yield* DatabaseMaintenance.DatabaseMaintenance; | 37 | 67 | const status = yield* maintenance.inspect(databasePath); | 38 | 68 | yield* Console.log( | @@ -123,19 +153,19 @@ export const runDoctor = Effect.fn("runDoctor")(function* ( | 123 | 153 | ); | 124 | 154 | // Report the repair before restarting, which can fail independently. | 125 | 155 | yield* service.withStopped( | 126 | | - maintenance | 127 | | - .compact(databasePath, reportStep) | 128 | | - .pipe( | 129 | | - Effect.tap((result) => | 130 | | - Clock.monotonicTimeNanos.pipe( | 131 | | - Effect.flatMap((now) => | 132 | | - Console.log( | 133 | | - `Done in ${formatElapsed(now - startedAt)}: ${formatBytes(result.beforeBytes)} -> ${formatBytes(result.afterBytes)}, ${result.deletedEventCount} superseded events removed.`, | 134 | | - ), | | 156 | + lockServerHome(paths).pipe( | | 157 | + Effect.andThen(maintenance.compact(databasePath, reportStep)), | | 158 | + Effect.tap((result) => | | 159 | + Clock.monotonicTimeNanos.pipe( | | 160 | + Effect.flatMap((now) => | | 161 | + Console.log( | | 162 | + `Done in ${formatElapsed(now - startedAt)}: ${formatBytes(result.beforeBytes)} -> ${formatBytes(result.afterBytes)}, ${result.deletedEventCount} superseded events removed.`, | 135 | 163 | ), | 136 | 164 | ), | 137 | 165 | ), | 138 | 166 | ), | | 167 | + Effect.scoped, | | 168 | + ), | 139 | 169 | ); | 140 | 170 | } | 141 | 171 | if (selected.includes("legacy")) { | @@ -163,7 +193,7 @@ export const doctorCommand = Command.make("doctor", { | 163 | 193 | Effect.gen(function* () { | 164 | 194 | const logLevel = yield* GlobalFlag.LogLevel; | 165 | 195 | const config = yield* resolveCliAuthConfig(flags, logLevel); | 166 | | - yield* runDoctor(config.dbPath, { fix: flags.fix, dryRun: flags.dryRun }).pipe( | | 196 | + yield* runDoctor(config, { fix: flags.fix, dryRun: flags.dryRun }).pipe( | 167 | 197 | Effect.provide(Layer.merge(DatabaseMaintenance.layer, CliService.layer(config))), | 168 | 198 | ); | 169 | 199 | }), | |
|