GeezerVison is showing github.com — Merge remote-tracking branch 'origin/main' into fix/browser-stop-loading · pingdotgg/t3code@15a02b2
File treeExpand file treeCollapse file tree Open diff view settings mobile/modules/t3-terminal/ios
provider-cursor/src/server provider-opencode/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/desktop/src/app/DesktopCliShim.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -56,7 +56,7 @@ const fakeAppImage = (canMount = true, app = REPORTER) => { | 56 | 56 | `echo $$ >'${root}/mounter.pid'`, | 57 | 57 | canMount ? `echo '${image}'` : 'echo "Cannot mount AppImage"; exit 1', | 58 | 58 | // Like the FUSE runtime, any of these unmounts. fd 3 reports to the test when it is open. | 59 | | - `trap 'echo unmounted >&3 2>/dev/null; touch "${root}/unmounted"; exit 0' TERM HUP INT`, | | 59 | + "trap 'echo unmounted >&3 2>/dev/null; exit 0' TERM HUP INT", | 60 | 60 | "trap 'echo mounted >&3 2>/dev/null' WINCH", | 61 | 61 | "while :; do sleep 0.05; done", | 62 | 62 | "", | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/modules/t3-terminal/ios/T3TerminalView.swift +30-8Lines changed: 30 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -285,7 +285,7 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte | 285 | 285 | didSet { | 286 | 286 | guard oldValue != fontSize else { return } | 287 | 287 | inputField.font = UIFont.monospacedSystemFont(ofSize: max(fontSize, 13), weight: .regular) | 288 | | - resetSurface() | | 288 | + applyConfigInPlace() | 289 | 289 | } | 290 | 290 | } | 291 | 291 |
| @@ -321,14 +321,14 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte | 321 | 321 | didSet { | 322 | 322 | guard oldValue != appearanceScheme else { return } | 323 | 323 | appearance = TerminalAppearanceScheme(value: appearanceScheme) | 324 | | - resetSurface() | | 324 | + applyConfigInPlace() | 325 | 325 | } | 326 | 326 | } | 327 | 327 |
| 328 | 328 | var themeConfig: String = "" { | 329 | 329 | didSet { | 330 | 330 | guard oldValue != themeConfig else { return } | 331 | | - resetSurface() | | 331 | + applyConfigInPlace() | 332 | 332 | } | 333 | 333 | } | 334 | 334 |
| @@ -663,7 +663,8 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte | 663 | 663 | surfaceCreationFailed = true | 664 | 664 | return | 665 | 665 | } | 666 | | - loadThemeConfig(into: config) | | 666 | + // Creation proceeds without the file, as before; font_size is also set on the surface config. | | 667 | + _ = loadThemeConfig(into: config) | 667 | 668 | ghostty_config_finalize(config) | 668 | 669 | defer { ghostty_config_free(config) } | 669 | 670 |
| @@ -710,6 +711,27 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte | 710 | 711 | setNeedsLayout() | 711 | 712 | } | 712 | 713 |
| | 714 | + // Font and theme change in place: a new surface would replay output and re-answer its queries. | | 715 | + private func applyConfigInPlace() { | | 716 | + guard let app, let surface else { | | 717 | + resetSurface() | | 718 | + return | | 719 | + } | | 720 | + guard let config = ghostty_config_new() else { return } | | 721 | + defer { ghostty_config_free(config) } | | 722 | + let loaded = loadThemeConfig(into: config) | | 723 | + ghostty_config_finalize(config) | | 724 | + ghostty_app_set_color_scheme(app, appearance.ghosttyColorScheme) | | 725 | + ghostty_surface_set_color_scheme(surface, appearance.ghosttyColorScheme) | | 726 | + tickApp() | | 727 | + // Without the file, the config lacks font-size and would reset the surface to defaults. | | 728 | + if loaded { | | 729 | + ghostty_surface_update_config(surface, config) | | 730 | + } | | 731 | + resizeSurface() | | 732 | + setNeedsLayout() | | 733 | + } | | 734 | + | 713 | 735 | private func destroySurface() { | 714 | 736 | // Unblock the io thread before ghostty_surface_free joins it. | 715 | 737 | tickApp() | @@ -933,16 +955,16 @@ public final class T3TerminalView: ExpoView, UITextFieldDelegate, UIEditMenuInte | 933 | 955 | terminalViewport.backgroundColor = backgroundColorValue | 934 | 956 | } | 935 | 957 |
| 936 | | - private func loadThemeConfig(into config: ghostty_config_t) { | 937 | | - guard let path = writeThemeConfigFile() else { return } | | 958 | + private func loadThemeConfig(into config: ghostty_config_t) -> Bool { | | 959 | + guard let path = writeThemeConfigFile() else { return false } | 938 | 960 | path.withCString { cString in | 939 | 961 | ghostty_config_load_file(config, cString) | 940 | 962 | } | | 963 | + return true | 941 | 964 | } | 942 | 965 |
| 943 | 966 | private func writeThemeConfigFile() -> String? { | 944 | | - guard !themeConfig.isEmpty else { return nil } | 945 | | - let configContents = themeConfig | | 967 | + let configContents = "\(themeConfig)\nfont-size = \(String(format: "%g", Double(fontSize)))\n" | 946 | 968 | let url = URL(fileURLWithPath: NSTemporaryDirectory()) | 947 | 969 | .appendingPathComponent("t3-terminal-theme-\(appearance.rawValue).ghostty") | 948 | 970 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/device/LocalDeviceHost.test.ts +51-17Lines changed: 51 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { describe, expect, it } from "@effect/vitest"; | 2 | 2 | import * as NodePath from "@effect/platform-node/NodePath"; | 3 | 3 | import * as HostProcess from "@t3tools/shared/HostProcess"; | | 4 | +import * as Deferred from "effect/Deferred"; | 4 | 5 | import * as Effect from "effect/Effect"; | | 6 | +import * as Fiber from "effect/Fiber"; | 5 | 7 | import * as Layer from "effect/Layer"; | 6 | 8 | import * as Option from "effect/Option"; | 7 | 9 | import * as Path from "effect/Path"; | @@ -45,7 +47,8 @@ const agentFixture = Effect.fn("agentFixture")(function* ( | 45 | 47 | const fs = yield* FileSystem.FileSystem; | 46 | 48 | const path = yield* Path.Path; | 47 | 49 | const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-device-agent-start-" }); | 48 | | - const hub = { running: true, spawnFails: false }; | | 50 | + const hub = { running: true, spawnFails: false, cleanup: Effect.void }; | | 51 | + const daemonStopRequested = yield* Deferred.make<ReadonlyArray<string>>(); | 49 | 52 | const stateDir = agentDeviceStateDir(path, path.join(baseDir, "userdata")); | 50 | 53 | const daemonHealthy = yield* Ref.make(true); | 51 | 54 | const runs: Array<ProcessRunner.ProcessRunInput> = []; | @@ -80,20 +83,22 @@ const agentFixture = Effect.fn("agentFixture")(function* ( | 80 | 83 | description: "Hub entry missing", | 81 | 84 | }), | 82 | 85 | ) | 83 | | - : Effect.succeed( | 84 | | - ChildProcessSpawner.makeHandle({ | 85 | | - pid: ChildProcessSpawner.ProcessId(123), | 86 | | - stdout: Stream.empty, | 87 | | - stderr: Stream.empty, | 88 | | - all: Stream.empty, | 89 | | - exitCode: Effect.never, | 90 | | - isRunning: Effect.sync(() => hub.running), | 91 | | - kill: () => Effect.void, | 92 | | - stdin: Sink.drain, | 93 | | - getInputFd: () => Sink.drain, | 94 | | - getOutputFd: () => Stream.empty, | 95 | | - unref: Effect.succeed(Effect.void), | 96 | | - }), | | 86 | + : Effect.addFinalizer(() => hub.cleanup).pipe( | | 87 | + Effect.as( | | 88 | + ChildProcessSpawner.makeHandle({ | | 89 | + pid: ChildProcessSpawner.ProcessId(123), | | 90 | + stdout: Stream.empty, | | 91 | + stderr: Stream.empty, | | 92 | + all: Stream.empty, | | 93 | + exitCode: Effect.never, | | 94 | + isRunning: Effect.sync(() => hub.running), | | 95 | + kill: () => Effect.void, | | 96 | + stdin: Sink.drain, | | 97 | + getInputFd: () => Sink.drain, | | 98 | + getOutputFd: () => Stream.empty, | | 99 | + unref: Effect.succeed(Effect.void), | | 100 | + }), | | 101 | + ), | 97 | 102 | ), | 98 | 103 | ), | 99 | 104 | ), | @@ -102,7 +107,9 @@ const agentFixture = Effect.fn("agentFixture")(function* ( | 102 | 107 | runs.push(input); | 103 | 108 | return input.args.includes("devices") | 104 | 109 | ? startup(stateDir) | 105 | | - : Effect.succeed(input.args.includes("-list-avds") ? avdOutput : processOutput(0)); | | 110 | + : input.args.includes("daemon") | | 111 | + ? Deferred.succeed(daemonStopRequested, input.args).pipe(Effect.as(processOutput(0))) | | 112 | + : Effect.succeed(input.args.includes("-list-avds") ? avdOutput : processOutput(0)); | 106 | 113 | }, | 107 | 114 | }), | 108 | 115 | Effect.provideService( | @@ -122,7 +129,7 @@ const agentFixture = Effect.fn("agentFixture")(function* ( | 122 | 129 | ), | 123 | 130 | ); | 124 | 131 | yield* host.ensureReady(() => Effect.void); | 125 | | - return { host, fs, baseDir, stateDir, hub, daemonHealthy, runs }; | | 132 | + return { host, fs, baseDir, stateDir, hub, daemonHealthy, daemonStopRequested, runs }; | 126 | 133 | }); | 127 | 134 |
| 128 | 135 | describe("AgentDevice startup", () => { | @@ -353,6 +360,33 @@ describe("AgentDevice startup", () => { | 353 | 360 | expect(yield* fs.exists(path.join(stateDir, "daemon.json"))).toBe(false); | 354 | 361 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), | 355 | 362 | ); | | 363 | + | | 364 | + it.effect("stops the agent daemon while the hub is still shutting down", () => | | 365 | + Effect.gen(function* () { | | 366 | + const fs = yield* FileSystem.FileSystem; | | 367 | + const { host, hub, stateDir, daemonStopRequested } = yield* agentFixture((stateDir) => | | 368 | + fs | | 369 | + .writeFileString( | | 370 | + `${stateDir}/daemon.json`, | | 371 | + JSON.stringify({ httpPort: 12345, token: "test-token" }), | | 372 | + ) | | 373 | + .pipe(Effect.orDie, Effect.as(processOutput(0))), | | 374 | + ); | | 375 | + yield* host.ensureAgentReady(() => Effect.void); | | 376 | + const hubExited = yield* Deferred.make<void>(); | | 377 | + hub.cleanup = Deferred.await(hubExited); | | 378 | + const stopping = yield* Effect.forkChild(host.stop); | | 379 | + expect((yield* Deferred.await(daemonStopRequested)).slice(1)).toEqual([ | | 380 | + "daemon", | | 381 | + "stop", | | 382 | + "--state-dir", | | 383 | + stateDir, | | 384 | + ]); | | 385 | + yield* Deferred.succeed(hubExited, undefined); | | 386 | + yield* Fiber.join(stopping); | | 387 | + expect(yield* fs.exists(`${stateDir}/hub.json`)).toBe(false); | | 388 | + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), | | 389 | + ); | 356 | 390 | }); | 357 | 391 |
| 358 | 392 | const diagnose = ( | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/device/LocalDeviceHost.ts +10-3Lines changed: 10 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -870,9 +870,16 @@ export const make = Effect.fn("LocalDeviceHost.make")(function* () { | 870 | 870 | const stop: DeviceHost.DeviceHost["Service"]["stop"] = startLock.withPermits(1)( | 871 | 871 | Effect.gen(function* () { | 872 | 872 | const running = yield* Ref.getAndSet(runningRef, null); | 873 | | - yield* stopHub(running?.hub); | 874 | | - yield* fs.remove(hubStatePath(), { force: true }).pipe(Effect.ignore); | 875 | | - yield* stopAgentDeviceDaemon; | | 873 | + // Hub cleanup waits for its exit unbounded; it must not strand the detached agent daemon. | | 874 | + yield* Effect.all( | | 875 | + [ | | 876 | + stopHub(running?.hub).pipe( | | 877 | + Effect.andThen(fs.remove(hubStatePath(), { force: true }).pipe(Effect.ignore)), | | 878 | + ), | | 879 | + stopAgentDeviceDaemon, | | 880 | + ], | | 881 | + { concurrency: "unbounded", discard: true }, | | 882 | + ); | 876 | 883 | }), | 877 | 884 | ); | 878 | 885 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +50Lines changed: 50 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -109,6 +109,7 @@ import * as ClaudeAdapterV2 from "./ClaudeAdapterV2.ts"; | 109 | 109 | import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; | 110 | 110 | import * as ProviderInstallationGate from "../../provider/ProviderInstallationGate.ts"; | 111 | 111 | import { ClaudeOrchestratorReplayHarness } from "./ClaudeAdapterV2.testkit.ts"; | | 112 | +import { withInlineContext } from "../ContextHandoffDelivery.ts"; | 112 | 113 | import { provideDeterministicTestRuntime } from "../testkit/DeterministicRuntime.ts"; | 113 | 114 | import { runOrchestratorV2Scenario } from "../testkit/OrchestratorScenario.ts"; | 114 | 115 | import { layerProviderReplay } from "../testkit/ProviderReplayHarness.ts"; | @@ -5483,6 +5484,55 @@ describe("ClaudeAdapterV2 background wake turns", () => { | 5483 | 5484 | ), | 5484 | 5485 | ); | 5485 | 5486 |
| | 5487 | + // regression: #34393 a provider switch replayed a $skill from the handoff history | | 5488 | + it.effect("dispatches only skills from the user's text, not from inline handoff history", () => | | 5489 | + Effect.gen(function* () { | | 5490 | + const fs = yield* FileSystem.FileSystem; | | 5491 | + const path = yield* Path.Path; | | 5492 | + const homePath = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-skill-handoff-" }); | | 5493 | + const directory = path.join(homePath, "skills", "review"); | | 5494 | + yield* fs.makeDirectory(directory, { recursive: true }); | | 5495 | + yield* fs.writeFileString( | | 5496 | + path.join(directory, "SKILL.md"), | | 5497 | + "---\nname: review\n---\nFollow the review instructions.\n", | | 5498 | + ); | | 5499 | + const harness = yield* makeWakeHarnessWithOptions({ | | 5500 | + settings: { ...DEFAULT_CLAUDE_SETTINGS, homePath }, | | 5501 | + }); | | 5502 | + const history = "Context handoff:\n[Historical user; user_message]\n$review the diff"; | | 5503 | + const text = withInlineContext(history, "continue"); | | 5504 | + yield* harness.runtime.startTurn({ | | 5505 | + ...makeClaudeTestTurnInput({ | | 5506 | + threadId: harness.threadId, | | 5507 | + providerThread: harness.providerThread, | | 5508 | + now: yield* DateTime.now, | | 5509 | + attemptId: RunAttemptId.make("skill-handoff"), | | 5510 | + text, | | 5511 | + attachments: [], | | 5512 | + runtimePolicy: { ...CLAUDE_TEST_RUNTIME_POLICY, cwd: homePath }, | | 5513 | + }), | | 5514 | + inlineContextLength: text.length - "continue".length, | | 5515 | + }); | | 5516 | + | | 5517 | + const content = harness.offeredMessages[0]?.message.content; | | 5518 | + const blocks = | | 5519 | + typeof content === "string" | | 5520 | + ? [content] | | 5521 | + : (content ?? []).map((block) => (block.type === "text" ? block.text : "")); | | 5522 | + assert.isFalse(blocks.some((text) => text.startsWith("/review"))); | | 5523 | + assert.include(blocks.join("\n"), "$review the diff"); | | 5524 | + }).pipe( | | 5525 | + Effect.provide( | | 5526 | + Layer.mergeAll( | | 5527 | + IdAllocator.layer, | | 5528 | + McpProviderSessions.layer, | | 5529 | + NodeServices.layer, | | 5530 | + NodeCrypto.layer, | | 5531 | + ), | | 5532 | + ), | | 5533 | + ), | | 5534 | + ); | | 5535 | + | 5486 | 5536 | // regression: #15475 MCP title arriving after the tool starts must survive to completion | 5487 | 5537 | it.effect.each([ | 5488 | 5538 | { isError: false, title: "Check weather" }, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +23-7Lines changed: 23 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2631,12 +2631,15 @@ export function makeClaudeUserMessage(input: { | 2631 | 2631 | readonly text: string; | 2632 | 2632 | readonly priority?: SDKUserMessage["priority"]; | 2633 | 2633 | readonly skills?: ReadonlyMap<string, ClaudeSkillTarget>; | | 2634 | + readonly skillMentionsFrom?: number; | 2634 | 2635 | readonly uuid?: SDKUserMessage["uuid"]; | 2635 | 2636 | }): SDKUserMessage { | 2636 | 2637 | // Claude expands a skill only when `/name` starts the last text block. | 2637 | 2638 | // Keep the whole request before that block; see ClaudeSkillDispatch. | 2638 | 2639 | const dispatch = | 2639 | | - input.skills === undefined ? undefined : planClaudeSkillDispatch(input.text, input.skills); | | 2640 | + input.skills === undefined | | 2641 | + ? undefined | | 2642 | + : planClaudeSkillDispatch(input.text, input.skills, input.skillMentionsFrom); | 2640 | 2643 | // Claude runs `/goal` only when it opens the prompt, so a goal stays one block. | 2641 | 2644 | const isGoalCommand = parseGoalCommand({ text: input.text }) !== null; | 2642 | 2645 | return { | @@ -2801,11 +2804,15 @@ const makeClaudeUserMessageWithAttachments = Effect.fnUntraced(function* (input: | 2801 | 2804 | readonly fileSystem: FileSystem.FileSystem; | 2802 | 2805 | readonly pdfReservation: Effect.Success<ReturnType<typeof reserveClaudePdfBudget>>; | 2803 | 2806 | readonly skills?: ReadonlyMap<string, ClaudeSkillTarget>; | | 2807 | + readonly skillMentionsFrom?: number; | 2804 | 2808 | }) { | 2805 | 2809 | if (input.attachments.length === 0) { | 2806 | 2810 | const message = makeClaudeUserMessage({ | 2807 | 2811 | text: input.text, | 2808 | 2812 | ...(input.skills === undefined ? {} : { skills: input.skills }), | | 2813 | + ...(input.skillMentionsFrom === undefined | | 2814 | + ? {} | | 2815 | + : { skillMentionsFrom: input.skillMentionsFrom }), | 2809 | 2816 | ...(input.priority === undefined ? {} : { priority: input.priority }), | 2810 | 2817 | ...(input.uuid === undefined ? {} : { uuid: input.uuid }), | 2811 | 2818 | }); | @@ -2829,7 +2836,7 @@ const makeClaudeUserMessageWithAttachments = Effect.fnUntraced(function* (input: | 2829 | 2836 | const dispatch = | 2830 | 2837 | input.skills === undefined | 2831 | 2838 | ? undefined | 2832 | | - : planClaudeSkillDispatch(textWithAttachmentPaths, input.skills); | | 2839 | + : planClaudeSkillDispatch(textWithAttachmentPaths, input.skills, input.skillMentionsFrom); | 2833 | 2840 | const content: Array<ClaudeUserContentBlock> = []; | 2834 | 2841 | // Base64 adds a third to the payload. Leave room below Anthropic's 32 MB | 2835 | 2842 | // request limit for text, instructions, and SDK framing. The SDK does not | @@ -12422,15 +12429,24 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | 12422 | 12429 | pdfBudgets.get(nativeThreadId)!, | 12423 | 12430 | persistAttachmentBudget(nativeThreadId), | 12424 | 12431 | ); | | 12432 | + const promptText = applyClaudePromptEffortPrefix( | | 12433 | + turnInput.message.text, | | 12434 | + compileClaudeModelSelection(turnInput.modelSelection, modelCatalog).promptEffort, | | 12435 | + ); | 12425 | 12436 | const userMessage = | 12426 | 12437 | promptUuid === null | 12427 | 12438 | ? null | 12428 | 12439 | : yield* makeClaudeUserMessageWithAttachments({ | 12429 | | - text: applyClaudePromptEffortPrefix( | 12430 | | - turnInput.message.text, | 12431 | | - compileClaudeModelSelection(turnInput.modelSelection, modelCatalog) | 12432 | | - .promptEffort, | 12433 | | - ), | | 12440 | + text: promptText, | | 12441 | + // Mentions in inline handoff history are history, not this turn's skill. | | 12442 | + ...(turnInput.inlineContextLength === undefined | | 12443 | + ? {} | | 12444 | + : { | | 12445 | + skillMentionsFrom: | | 12446 | + promptText.length - | | 12447 | + turnInput.message.text.slice(turnInput.inlineContextLength).trimEnd() | | 12448 | + .length, | | 12449 | + }), | 12434 | 12450 | attachments: turnInput.message.attachments, | 12435 | 12451 | attachmentsDir, | 12436 | 12452 | fileSystem, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProviderTurnStartService.ts +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1639,12 +1639,11 @@ export const layer: Layer.Layer< | 1639 | 1639 | .filter((part) => part !== "") | 1640 | 1640 | .join("\n\n"); | 1641 | 1641 | const { restartContinuationOfRunId: _resumedRunId, ...promptedInput } = turnInput; | | 1642 | + const text = goalCommand ? userText : withInlineContext(context, userText); | 1642 | 1643 | yield* start({ | 1643 | 1644 | ...(noteContinuation ? promptedInput : turnInput), | 1644 | | - message: { | 1645 | | - ...turnInput.message, | 1646 | | - text: goalCommand ? userText : withInlineContext(context, userText), | 1647 | | - }, | | 1645 | + message: { ...turnInput.message, text }, | | 1646 | + ...(text === userText ? {} : { inlineContextLength: text.length - userText.length }), | 1648 | 1647 | }).pipe( | 1649 | 1648 | // Clear pending handoff markers for refused prompts so the next turn retains the native session. | 1650 | 1649 | Effect.tapError((error) => | |
|