GeezerVison is showing github.com — Merge origin/main into feat/scheduled-tasks-follow-thread-model · pingdotgg/t3code@7134113
File treeExpand file treeCollapse file tree Open diff view settings mobile/src/features/layout/workspace
provider-cursor/src/server provider-opencode/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: 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/src/features/layout/workspace/WorkspaceRootScreen.android.tsx +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -24,6 +24,8 @@ import { WorkspaceAppBarScope } from "../../../components/ui/WorkspaceAppBar.and | 24 | 24 | import { usePaneRole } from "../../../components/ui/Pane"; | 25 | 25 | import { AndroidWorkspaceSidebar } from "./AndroidWorkspaceSidebar.android"; | 26 | 26 | import type { WorkspaceTab } from "./workspace-tabs-state"; | | 27 | +import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab"; | | 28 | +import { useHardwareBack } from "../../../lib/backHandler"; | 27 | 29 |
| 28 | 30 | const TABS: readonly WorkspaceTab[] = NAVIGATION_TAB_ORDER; | 29 | 31 |
| @@ -49,6 +51,18 @@ function WorkspaceRoot() { | 49 | 51 | : 16, | 50 | 52 | }; | 51 | 53 | const tab = workspace.state.selectedTab; | | 54 | + const selectTab = useSelectWorkspaceTab(); | | 55 | + // Tabs are panes of Home, not routes, so Back has nothing to pop and would leave the app. | | 56 | + // An open search keeps Back for itself. | | 57 | + useHardwareBack( | | 58 | + tab !== "threads" && | | 59 | + enabled.includes("threads") && | | 60 | + workspace.state.tabs[tab].searchMode === "resting", | | 61 | + () => { | | 62 | + selectTab("threads"); | | 63 | + return true; | | 64 | + }, | | 65 | + ); | 52 | 66 |
| 53 | 67 | return ( | 54 | 68 | <WorkspaceTabsContext value={context}> | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/layout/workspace/workspace-tabs-state.test.ts +46-3Lines changed: 46 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,8 @@ import { | 11 | 11 | workspaceSearchBottomClearance, | 12 | 12 | workspaceDockBottomClearance, | 13 | 13 | workspaceUsesColumns, | | 14 | + type WorkspaceTab, | | 15 | + type WorkspaceTabsState, | 14 | 16 | } from "./workspace-tabs-state"; | 15 | 17 |
| 16 | 18 | describe("compact list clearance", () => { | @@ -179,12 +181,25 @@ describe("workspace root navigation", () => { | 179 | 181 | }); | 180 | 182 | }); | 181 | 183 |
| 182 | | -const mocks = vi.hoisted(() => ({ split: false, floating: false })); | | 184 | +const mocks = vi.hoisted(() => ({ | | 185 | + split: false, | | 186 | + floating: false, | | 187 | + state: undefined as WorkspaceTabsState | undefined, | | 188 | + openWorkspaceTab: (_tab: string) => {}, | | 189 | + backListeners: new Set<() => boolean>(), | | 190 | +})); | 183 | 191 |
| 184 | 192 | vi.mock("../../settings/appearance/AppearancePreferencesProvider", () => ({ | 185 | 193 | useAndroidFloatingTabs: () => mocks.floating, | 186 | 194 | })); | 187 | 195 | vi.mock("react-native", () => ({ | | 196 | + BackHandler: { | | 197 | + addEventListener: (_event: string, listener: () => boolean) => { | | 198 | + mocks.backListeners.add(listener); | | 199 | + return { remove: () => mocks.backListeners.delete(listener) }; | | 200 | + }, | | 201 | + }, | | 202 | + Keyboard: { dismiss: () => undefined }, | 188 | 203 | useWindowDimensions: () => ({ width: 400, height: 800 }), | 189 | 204 | View: ({ children }: { children: ReactNode }) => createElement("div", null, children), | 190 | 205 | })); | @@ -198,12 +213,16 @@ vi.mock("../AdaptiveWorkspaceLayout", () => ({ | 198 | 213 | startNewTask: () => undefined, | 199 | 214 | }), | 200 | 215 | })); | | 216 | +vi.mock("@react-navigation/native", () => ({ useIsFocused: () => true })); | | 217 | +vi.mock("../adaptive-workspace-context", () => ({ | | 218 | + useAdaptiveWorkspaceLayout: () => ({ openWorkspaceTab: mocks.openWorkspaceTab }), | | 219 | +})); | 201 | 220 | vi.mock("./navigation-tabs", () => ({ | 202 | 221 | useEnabledNavigationTabs: () => ["threads", "pullRequests", "usage"], | 203 | 222 | })); | 204 | 223 | vi.mock("./WorkspaceTabsContext", () => ({ | 205 | 224 | WorkspaceTabsContext: createContext(null), | 206 | | - useWorkspaceTabs: () => ({ state: { selectedTab: "usage" } }), | | 225 | + useWorkspaceTabs: () => ({ state: mocks.state, dispatch: () => undefined }), | 207 | 226 | })); | 208 | 227 | vi.mock("./WorkspaceExtraTab", () => ({ | 209 | 228 | WorkspaceExtraTab: function UsageProbe() { | @@ -238,13 +257,37 @@ vi.mock("../../../components/ui/WorkspaceAppBar.android", () => ({ | 238 | 257 | WorkspaceAppBarScope: ({ children }: { children: ReactNode }) => children, | 239 | 258 | })); | 240 | 259 |
| 241 | | -function setup(split: boolean, floating: boolean) { | | 260 | +function setup(split: boolean, floating: boolean, state = selected("usage")) { | 242 | 261 | mocks.split = split; | 243 | 262 | mocks.floating = floating; | | 263 | + mocks.state = state; | | 264 | + mocks.openWorkspaceTab = () => undefined; | | 265 | + mocks.backListeners.clear(); | 244 | 266 | vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); | 245 | 267 | return { [Symbol.dispose]: () => vi.unstubAllGlobals() }; | 246 | 268 | } | 247 | 269 |
| | 270 | +function selected(tab: WorkspaceTab) { | | 271 | + return workspaceTabsReducer(initialWorkspaceTabsState(), { type: "select", tab }); | | 272 | +} | | 273 | + | | 274 | +/** Android calls the newest listener first and stops at the first that handles Back. */ | | 275 | +function pressBack() { | | 276 | + return [...mocks.backListeners].reverse().some((listener) => listener()); | | 277 | +} | | 278 | + | | 279 | +it("Back from the Pulls tab returns to Threads instead of leaving the app", async () => { | | 280 | + using _actEnvironment = setup(false, false, selected("pullRequests")); | | 281 | + const opened: string[] = []; | | 282 | + mocks.openWorkspaceTab = (tab) => opened.push(tab); | | 283 | + const root = createRoot(document.createElement("div")); | | 284 | + using _root = { [Symbol.dispose]: () => act(() => root.unmount()) }; | | 285 | + await act(async () => root.render(createElement(WorkspaceRootScreen))); | | 286 | + | | 287 | + expect(pressBack()).toBe(true); | | 288 | + expect(opened).toEqual(["threads"]); | | 289 | +}); | | 290 | + | 248 | 291 | it.each([ | 249 | 292 | [false, false], | 250 | 293 | [true, false], | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/environment/ServerEnvironment.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -274,6 +274,7 @@ export const make = Effect.gen(function* () { | 274 | 274 | projectCloneTracking: true, | 275 | 275 | projectOrganization: true, | 276 | 276 | ignoredFileListing: true, | | 277 | + ignoredFileSearch: true, | 277 | 278 | triage: true, | 278 | 279 | oneTimeSchedules: true, | 279 | 280 | freshContext: true, | |
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/Orchestrator.ts +7-5Lines changed: 7 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3741,19 +3741,19 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio | 3741 | 3741 | command.searchQuery, | 3742 | 3742 | ) | 3743 | 3743 | : null; | 3744 | | - // Viewing a thread changes read state only. Loading its transcript (or | 3745 | | - // bumping updatedAt) makes a routine read receipt scale with its history. | | 3744 | + if (!movesForward && opens === null) return; | | 3745 | + // Viewing a thread changes read state only. Loading its transcript, bumping | | 3746 | + // updatedAt, or copying the thread into the event makes a read receipt scale with it. | 3746 | 3747 | yield* emit( | 3747 | 3748 | events, | 3748 | 3749 | command, | 3749 | 3750 | )({ | 3750 | | - type: "thread.visited", | | 3751 | + type: "thread.visit-recorded", | 3751 | 3752 | threadId: command.threadId, | 3752 | 3753 | providerInstanceId: thread.providerInstanceId, | 3753 | 3754 | occurredAt, | 3754 | 3755 | payload: { | 3755 | | - ...thread, | 3756 | | - ...(movesForward ? { lastVisitedAt: visitedAt.value } : {}), | | 3756 | + lastVisitedAt: movesForward ? visitedAt.value : thread.lastVisitedAt, | 3757 | 3757 | ...(opens ? { opens } : {}), | 3758 | 3758 | }, | 3759 | 3759 | }); | @@ -15014,6 +15014,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio | 15014 | 15014 | planned.events.length > 0 || | 15015 | 15015 | isUnobservedAcknowledgement(command) || | 15016 | 15016 | command.type === "thread.background-work.settle" || | | 15017 | + // A stale visit changes no read state. | | 15018 | + command.type === "thread.visit" || | 15017 | 15019 | // A read can answer a watch again before a push's reopen lands; nothing is left to clear. | 15018 | 15020 | command.type === "thread.pull-request-watch.checks-reopen" || | 15019 | 15021 | command.type === "thread.interrupt.unresponsive" || | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/ProjectionStore.ts +16-1Lines changed: 16 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { ProjectThreadAwarenessV2Input } from "@t3tools/shared/agentAwareness"; | 2 | | -import { pendingGuestMessageCount } from "@t3tools/contracts"; | | 2 | +import { applyOrchestrationV2ThreadVisit, pendingGuestMessageCount } from "@t3tools/contracts"; | 3 | 3 | import { applyThreadPullRequestLinkUpdate } from "../sourceControl/threadPullRequests.ts"; | 4 | 4 | import { projectTurnItemForWire } from "./WireProjection.ts"; | 5 | 5 | import * as Stream from "effect/Stream"; | @@ -927,6 +927,11 @@ export function applyToProjection( | 927 | 927 | ...projection, | 928 | 928 | thread: event.payload, | 929 | 929 | }; | | 930 | + case "thread.visit-recorded": | | 931 | + return { | | 932 | + ...projection, | | 933 | + thread: applyOrchestrationV2ThreadVisit(projection.thread, event.payload), | | 934 | + }; | 930 | 935 | case "run.created": | 931 | 936 | case "run.updated": | 932 | 937 | return withLocalVisibleTurnItems({ | @@ -2242,6 +2247,15 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> = | 2242 | 2247 | }); | 2243 | 2248 | break; | 2244 | 2249 | } | | 2250 | + case "thread.visit-recorded": { | | 2251 | + const thread = yield* getThread(event.threadId); | | 2252 | + yield* apply({ | | 2253 | + ...event, | | 2254 | + type: "thread.visited", | | 2255 | + payload: applyOrchestrationV2ThreadVisit(thread, event.payload), | | 2256 | + }); | | 2257 | + break; | | 2258 | + } | 2245 | 2259 | case "thread.created": | 2246 | 2260 | case "thread.archived": | 2247 | 2261 | case "thread.unarchived": | @@ -3074,6 +3088,7 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> = | 3074 | 3088 | event.type !== "thread.active-reordered" && | 3075 | 3089 | event.type !== "thread.tags-updated" && | 3076 | 3090 | event.type !== "thread.visited" && | | 3091 | + event.type !== "thread.visit-recorded" && | 3077 | 3092 | event.type !== "thread.marked-unread" && | 3078 | 3093 | event.type !== "thread.metadata-updated" && | 3079 | 3094 | event.type !== "thread.pull-request-synced" && | |
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) => | |
|