@p4code/cli 0.4.15 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +62 -30
- package/dist/client/assets/{DiffPanel-g0pllfdt.js → DiffPanel-nfXQ6agW.js} +3 -3
- package/dist/client/assets/FilePreviewPanel-CXOOrRUw.js +2230 -0
- package/dist/client/assets/PreviewPanel-CssSb7Yi.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-Df6f50Qv.js → PullRequestCodeTab-D0fAUWen.js} +4 -4
- package/dist/client/assets/{fileCommentAnnotations-DvVQmvdC.js → fileCommentAnnotations-4NC7LRU5.js} +2 -2
- package/dist/client/assets/{index-cqm4-bHh.css → index-Dpz4CmzF.css} +1 -1
- package/dist/client/assets/{index-DVPc23Lg.js → index-uIueElRa.js} +162 -151
- package/dist/client/assets/{previewAssetResource-DdooihFl.js → previewAssetResource-D3HjmQ_a.js} +2 -2
- package/dist/client/assets/{renderFileChildren-BP62VMwZ.js → renderFileChildren-B8BVzpw1.js} +2 -2
- package/dist/client/assets/{toggle-group-Cdm_59x2.js → toggle-group-CKtx0pfu.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/FilePreviewPanel-BQeBuvWH.js +0 -2230
- package/dist/client/assets/PreviewPanel-CXcnwWFv.js +0 -2
package/dist/bin.mjs
CHANGED
|
@@ -260,7 +260,7 @@ const make$115 = () => {
|
|
|
260
260
|
const layer$118 = Layer.sync(NetService, make$115);
|
|
261
261
|
//#endregion
|
|
262
262
|
//#region package.json
|
|
263
|
-
var version$1 = "0.4.
|
|
263
|
+
var version$1 = "0.4.17";
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/config.ts
|
|
266
266
|
/**
|
|
@@ -53225,19 +53225,19 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
|
|
|
53225
53225
|
invoke: (scope, input, hostId) => Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
53226
53226
|
const { requestId, connection, completion, request } = yield* admission.withPermits(1)(Effect.gen(function* () {
|
|
53227
53227
|
if (scope.authorizationLifetime?.revoked === true || !scope.capabilities.has("computer-use") || scope.environmentId !== environmentId) return yield* deny();
|
|
53228
|
-
if (
|
|
53229
|
-
const grantedHostId = scope.computerUseHostId;
|
|
53228
|
+
if (scope.computerUseHostId && hostId !== void 0 && hostId !== scope.computerUseHostId) return yield* deny();
|
|
53229
|
+
const grantedHostId = scope.computerUseHostId ?? hostId;
|
|
53230
53230
|
const key = scopeKey(scope);
|
|
53231
53231
|
const existing = leases.get(key);
|
|
53232
53232
|
if (existing && (connections.get(existing.host.hostId) !== existing || hostId !== void 0 && hostId !== existing.host.hostId)) return yield* new ComputerUseError({
|
|
53233
53233
|
reason: "disconnected",
|
|
53234
53234
|
detail: "Reset Computer Use before changing host connections."
|
|
53235
53235
|
});
|
|
53236
|
-
const candidates = [...connections.values()].filter((entry) => (entry.host.browser || entry.host.nativeApps) && entry.host.hostId === grantedHostId);
|
|
53236
|
+
const candidates = [...connections.values()].filter((entry) => (entry.host.browser || entry.host.nativeApps) && (grantedHostId === void 0 || entry.host.hostId === grantedHostId));
|
|
53237
53237
|
const connection = existing ?? (candidates.length === 1 ? candidates[0] : void 0);
|
|
53238
53238
|
if (!connection) return yield* new ComputerUseError({
|
|
53239
53239
|
reason: "unavailable",
|
|
53240
|
-
detail: candidates.length > 1 ?
|
|
53240
|
+
detail: candidates.length > 1 ? `Select a Computer Use host with hostId: ${candidates.map((entry) => `${entry.host.label} (${entry.host.hostId})`).join(", ")}.` : "No Computer Use host is available."
|
|
53241
53241
|
});
|
|
53242
53242
|
if (pending.size >= MAX_PENDING_REQUESTS || [...pending.values()].some((request) => request.scopeKey === key)) return yield* new ComputerUseError({
|
|
53243
53243
|
reason: "busy",
|
|
@@ -63290,7 +63290,8 @@ function formatAskUserQuestionAnswers(answers) {
|
|
|
63290
63290
|
* only a one-line reference and the mutable `[fusion-pair]` metadata.
|
|
63291
63291
|
*/
|
|
63292
63292
|
const FUSION_BUILDER_INSTRUCTIONS = `You are Fusion Builder in an already-created native server pair. Server owns pairing and coordination. Do not inspect or invoke the Fusion skill, create/pair/rename threads, or announce/setup Fusion. Start the user's task directly. Before editing, create and maintain the phase list with your provider's step-tracking tool (Claude Code: TaskCreate for each phase, then TaskUpdate for status, or TodoWrite when that is the tool offered; Codex: update_plan), never the MCP task board tools - one entry per phase in order, exactly one in progress at a time, marked completed at each phase end - so phases render in the task banner. That list holds phase entries only for the whole task; keep step-level or per-file todos out of it. Name each phase in 3-6 words by its outcome, never by a command, file path, or flag, because the banner shows the title verbatim. Prose alone leaves the banner empty. Split it into the fewest substantial phases the task genuinely needs plus a final integration/whole-task phase; most tasks need one to three work phases. Each phase is a complete reviewable slice of behavior. Never split per file, per function, or per trivial step: over-splitting spends review turns instead of finishing the job. Add a phase only when a real review boundary, risky decision, or independent behavior separates the work. Complete exactly one phase per turn, and finish the whole phase in that turn rather than stopping early. Do not run tests, typecheck, lint, or builds per phase; write the tests the change needs, then run verification once in the final phase over the whole task. Exception: a phase whose own correctness is unclear may run the single narrowest check that resolves it. End every phase turn with phase completed, todo status, changed behavior/files, and remaining phases; do not start the next phase in the same turn. Server then wakes the paired Supervisor, which resumes you through ${FUSION_ADVICE_PROMPT_PREFIX}; a user message may also revise or resume the work. Final phase verifies the entire task against the original request and labels it ready for whole-task review. Supervisor is unreachable during your turn. Never spawn/use another Supervisor thread/subagent or attribute Supervisor decisions without ${FUSION_ADVICE_PROMPT_PREFIX}. Within the current phase, continue when straightforward or evidence is clear. For a concrete unresolved tradeoff, correctness risk, or design decision materially needing judgment, stop safely before the risky choice; final response states the exact question and why review is needed. Evaluate/follow Supervisor advice unless conflicting with user request or verified repo state.`;
|
|
63293
|
-
const
|
|
63293
|
+
const FUSION_WATCHER_TOOL_INSTRUCTIONS = `Supervisor tools belong to the p4-code MCP server: thread_watch_review, thread_watch_events, thread_advise, and thread_gate_respond. If absent from the visible tool list, first use the available tool search/discovery facility to load those exact tools, including provider-prefixed names; absence from the initial list does not establish unavailability. If discovery or a call fails, report the exact missing capability or error and the need to restore the p4-code MCP connection. Do not offer manual relay, draft or implement the task yourself, or abandon the supervisor role as a workaround. For an actionable user requirement, read the relevant builder evidence and relay it through thread_advise; when a gate is open, answer through thread_gate_respond instead.`;
|
|
63294
|
+
const FUSION_WATCHER_INSTRUCTIONS = `You are Fusion Supervisor (watcher) in an already-created native server pair. Server owns pairing and coordination and wakes you with ${FUSION_REVIEW_PROMPT_PREFIX} or ${FUSION_GATE_PROMPT_PREFIX} prompts at builder turn boundaries. A plain message outside such a wake may arrive after your conversational memory of the pair is gone; its [fusion-pair] metadata block is authoritative: the builder thread exists and is the counterpart thread id. Never report that no builder thread exists. For a new pair, the initial user request is yours: inspect the task and available project context, plan the work, then direct the first actionable phase to the idle builder through thread_advise. Include the original requirements, constraints, and authorized delivery scope in that direction. The builder has not received the initial prompt and must not start before your direction. Missing builder turn evidence is expected before that first direction; do not wait for it or implement the work yourself. Ask the user only when needed to resolve a blocking requirement. ${FUSION_WATCHER_TOOL_INSTRUCTIONS} To resume supervision, read builder evidence with thread_watch_review from lastReviewedImplementerSequence, capture its throughSequence on the first page and reuse that fixed bound while paging with nextAfterSequence until hasMore is false (including empty pages). Apply message append/replace operations by identity; recover truncated evidence through targeted raw thread_watch_events source ranges. Retain reviewed requirements and evidence for final review; recover missing context with targeted history reads rather than mandatory raw replay from zero, derive phase from artifacts (git log/status, PR, builder events, including its turn.plan.updated phase list), steer with thread_advise, and answer an open gate with thread_gate_respond. When a review or gate wake prompt specifies an explicit event range, that range wins over this metadata. Never poll or wait for the builder; deliver review or advice, then end the turn. Every thread_advise starts a builder turn whose completion wakes you again, so never advise a builder that is idle on an external wait or has nothing actionable; report the state in your own thread and end without advising.`;
|
|
63294
63295
|
/**
|
|
63295
63296
|
* The one-line stand-in for the full block on a message whose session already
|
|
63296
63297
|
* carries the role instructions.
|
|
@@ -125040,6 +125041,18 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker, computerUseBrok
|
|
|
125040
125041
|
branch: worktree.worktree.refName,
|
|
125041
125042
|
worktreePath: targetWorktreePath
|
|
125042
125043
|
});
|
|
125044
|
+
if (!bootstrap.createThread) {
|
|
125045
|
+
const snapshot = yield* projectionSnapshotQuery.getCommandReadModel();
|
|
125046
|
+
const pair = snapshot.threadPairs?.find((candidate) => candidate.detachedAt === null && candidate.watcherThreadId === command.threadId);
|
|
125047
|
+
const builder = pair && snapshot.threads.find((thread) => thread.id === pair.implementerThreadId && thread.deletedAt === null);
|
|
125048
|
+
if (builder && builder.latestTurn === null && builder.messages.length === 0 && builder.worktreePath === null) yield* orchestrationEngine.dispatch({
|
|
125049
|
+
type: "thread.meta.update",
|
|
125050
|
+
commandId: yield* serverCommandId("bootstrap-builder-meta-update"),
|
|
125051
|
+
threadId: builder.id,
|
|
125052
|
+
branch: worktree.worktree.refName,
|
|
125053
|
+
worktreePath: targetWorktreePath
|
|
125054
|
+
});
|
|
125055
|
+
}
|
|
125043
125056
|
yield* refreshGitStatus(targetWorktreePath);
|
|
125044
125057
|
}
|
|
125045
125058
|
yield* runSetupProgram();
|
|
@@ -126104,7 +126117,7 @@ const makeWithOptions = Effect.fn("McpSessionRegistry.make")(function* (options
|
|
|
126104
126117
|
const providerSessionId = yield* crypto.randomUUIDv4.pipe(Effect.orDie);
|
|
126105
126118
|
const rawToken = yield* crypto.randomBytes(32).pipe(Effect.map(tokenFromBytes), Effect.orDie);
|
|
126106
126119
|
const tokenHash = yield* hashToken(rawToken);
|
|
126107
|
-
const computerUseToken = request.computerUseHostId ? yield* crypto.randomBytes(32).pipe(Effect.map(tokenFromBytes), Effect.orDie) : void 0;
|
|
126120
|
+
const computerUseToken = request.computerUseAccess || request.computerUseHostId ? yield* crypto.randomBytes(32).pipe(Effect.map(tokenFromBytes), Effect.orDie) : void 0;
|
|
126108
126121
|
const computerUseHash = computerUseToken ? yield* hashToken(computerUseToken) : void 0;
|
|
126109
126122
|
const watchThreadIds = new Set((request.watchThreadIds ?? []).map((threadId) => ThreadId.make(threadId)));
|
|
126110
126123
|
const adviseThreadIds = new Set((request.adviseThreadIds ?? []).map((threadId) => ThreadId.make(threadId)));
|
|
@@ -126143,12 +126156,12 @@ const makeWithOptions = Effect.fn("McpSessionRegistry.make")(function* (options
|
|
|
126143
126156
|
controlThreadIds: /* @__PURE__ */ new Set(),
|
|
126144
126157
|
lastAliveAt: issuedAt
|
|
126145
126158
|
});
|
|
126146
|
-
if (computerUseHash
|
|
126159
|
+
if (computerUseHash) next.set(computerUseHash, {
|
|
126147
126160
|
tokenHash: computerUseHash,
|
|
126148
126161
|
scope: {
|
|
126149
126162
|
...scopeWith(false, false, computerRevocation),
|
|
126150
126163
|
capabilities: /* @__PURE__ */ new Set(["computer-use"]),
|
|
126151
|
-
computerUseHostId: request.computerUseHostId
|
|
126164
|
+
...request.computerUseHostId ? { computerUseHostId: request.computerUseHostId } : {}
|
|
126152
126165
|
},
|
|
126153
126166
|
controlThreadIds: /* @__PURE__ */ new Set(),
|
|
126154
126167
|
lastAliveAt: issuedAt
|
|
@@ -126480,16 +126493,12 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
|
|
|
126480
126493
|
const thread = yield* projectionQuery.value.getThreadShellById(threadId);
|
|
126481
126494
|
return Option.isSome(thread) ? resolveProjectAgentBrowserAccess(settings, thread.value.projectId) : false;
|
|
126482
126495
|
})), Effect.catch((cause) => Effect.logWarning("Could not read settings; withholding agent browser access.", { cause }).pipe(Effect.as(false))));
|
|
126483
|
-
const
|
|
126484
|
-
if ((yield* registry.getInstanceInfo(providerInstanceId)).driverKind === "codex" || Option.isNone(projectionQuery)) return void 0;
|
|
126485
|
-
const thread = yield* projectionQuery.value.getThreadShellById(threadId);
|
|
126486
|
-
return Option.isSome(thread) ? thread.value.computerUseHostId ?? void 0 : void 0;
|
|
126487
|
-
}).pipe(Effect.catch(() => Effect.void));
|
|
126496
|
+
const computerUseAccess = yield* registry.getInstanceInfo(providerInstanceId).pipe(Effect.map((info) => info.driverKind !== "codex"), Effect.catch(() => Effect.succeed(false)));
|
|
126488
126497
|
const credential = yield* issueActiveMcpCredential({
|
|
126489
126498
|
threadId,
|
|
126490
126499
|
providerInstanceId,
|
|
126491
126500
|
browserAccess,
|
|
126492
|
-
|
|
126501
|
+
computerUseAccess,
|
|
126493
126502
|
...watchThreadIds !== void 0 ? { watchThreadIds } : {},
|
|
126494
126503
|
...adviseThreadIds !== void 0 ? { adviseThreadIds } : {}
|
|
126495
126504
|
});
|
|
@@ -127278,6 +127287,25 @@ const makeProviderSessionReaper = (options) => Effect.gen(function* () {
|
|
|
127278
127287
|
const makeProviderSessionReaperLive = (options) => Layer.effect(ProviderSessionReaper, makeProviderSessionReaper(options));
|
|
127279
127288
|
const ProviderSessionReaperLive = makeProviderSessionReaperLive();
|
|
127280
127289
|
//#endregion
|
|
127290
|
+
//#region src/mcp/McpToolkit.ts
|
|
127291
|
+
const mcpInputSchema = (schema) => ({
|
|
127292
|
+
...schema,
|
|
127293
|
+
type: "object"
|
|
127294
|
+
});
|
|
127295
|
+
const mcpToolkit = (toolkit) => Layer.effectDiscard(Effect.gen(function* () {
|
|
127296
|
+
const server = yield* McpServer.McpServer;
|
|
127297
|
+
yield* McpServer.registerToolkit(toolkit).pipe(Effect.provideService(McpServer.McpServer, {
|
|
127298
|
+
...server,
|
|
127299
|
+
addTool: (options) => server.addTool({
|
|
127300
|
+
...options,
|
|
127301
|
+
tool: new McpSchema.Tool({
|
|
127302
|
+
...options.tool,
|
|
127303
|
+
inputSchema: mcpInputSchema(options.tool.inputSchema)
|
|
127304
|
+
})
|
|
127305
|
+
})
|
|
127306
|
+
}));
|
|
127307
|
+
}));
|
|
127308
|
+
//#endregion
|
|
127281
127309
|
//#region src/mcp/toolkits/computerUse/tools.ts
|
|
127282
127310
|
const ComputerUseJsTool = Tool.make("js", {
|
|
127283
127311
|
description: "Run JavaScript in a persistent P4 Computer Use REPL. Start with await cua.getState(). Use cua.createBrowserTab('iab', url, {visible:true}) or cua.getTab(tabId) for P4 browser tabs. Tab methods: getState(), goto(url), click({locator}), type({text,locator?,clear?}), press({key,modifiers?}), scroll({deltaY,deltaX?}). Print results with nodeRepl.write(value); emit PNG/JPEG with nodeRepl.emitImage({mimeType,data}) using base64 data. Top-level await and persistent let bindings are supported. Await each operation. Reset after timeout or host disconnect. For available native apps, use cua.getApp(exactNameOrBundleId), then getState(), activate(), click({elementId}), or type({elementId,text}) to replace a field value. Element IDs come from the latest app snapshot. List windows with app.windows(); capture a listed ID with app.screenshot(windowId), then nodeRepl.emitImage(image). Native app availability and macOS permission states are reported by the host; never assume native apps are supported. The host may be a different machine from the provider server.",
|
|
@@ -127319,7 +127347,7 @@ const register = Effect.fn("computerUse.register")(function* () {
|
|
|
127319
127347
|
tool: new McpSchema.Tool({
|
|
127320
127348
|
name: tool.name,
|
|
127321
127349
|
description: Tool.getDescription(tool),
|
|
127322
|
-
inputSchema: Tool.getJsonSchema(tool),
|
|
127350
|
+
inputSchema: mcpInputSchema(Tool.getJsonSchema(tool)),
|
|
127323
127351
|
annotations: {
|
|
127324
127352
|
readOnlyHint: false,
|
|
127325
127353
|
destructiveHint: true,
|
|
@@ -127710,7 +127738,7 @@ const registerScreenshot = Effect.fn("device.registerScreenshot")(function* () {
|
|
|
127710
127738
|
tool: new McpSchema.Tool({
|
|
127711
127739
|
name: DeviceScreenshotTool.name,
|
|
127712
127740
|
description: Tool.getDescription(DeviceScreenshotTool),
|
|
127713
|
-
inputSchema: Tool.getJsonSchema(DeviceScreenshotTool),
|
|
127741
|
+
inputSchema: mcpInputSchema(Tool.getJsonSchema(DeviceScreenshotTool)),
|
|
127714
127742
|
annotations: {
|
|
127715
127743
|
readOnlyHint: true,
|
|
127716
127744
|
destructiveHint: false,
|
|
@@ -127728,7 +127756,7 @@ const registerScreenshot = Effect.fn("device.registerScreenshot")(function* () {
|
|
|
127728
127756
|
}))))
|
|
127729
127757
|
});
|
|
127730
127758
|
});
|
|
127731
|
-
const DeviceToolkitRegistrationLive = Layer.mergeAll(
|
|
127759
|
+
const DeviceToolkitRegistrationLive = Layer.mergeAll(mcpToolkit(DeviceStandardToolkit), Layer.effectDiscard(registerScreenshot())).pipe(Layer.provide(DeviceToolkitHandlersLive));
|
|
127732
127760
|
//#endregion
|
|
127733
127761
|
//#region src/mcp/toolkits/preview/tools.ts
|
|
127734
127762
|
const dependencies$1 = [McpInvocationContext, PreviewAutomationBroker];
|
|
@@ -128466,7 +128494,7 @@ const AskUserQuestionTool = Tool.make("ask_user_question", {
|
|
|
128466
128494
|
]
|
|
128467
128495
|
}).annotate(Tool.Title, "Ask user question").annotate(Tool.Readonly, false).annotate(Tool.Destructive, false).annotate(Tool.Idempotent, false);
|
|
128468
128496
|
const ThreadSpawnTool = Tool.make("thread_spawn", {
|
|
128469
|
-
description: "Start a new agent thread and send it a first message, then return its id. Use it to hand a piece of work to a fresh thread - a subtask you just planned, a job that wants its own transcript. Set fusion true to create two new threads as a separate Fusion pair and
|
|
128497
|
+
description: "Start a new agent thread and send it a first message, then return its id. Use it to hand a piece of work to a fresh thread - a subtask you just planned, a job that wants its own transcript. Set fusion true to create two new threads as a separate Fusion pair and send prompt to its supervisor, which plans and directs the builder later, even when this thread already belongs to a pair. Set fusionWatcher true only for a supervisor to pair with the current thread. Both use saved Fusion role models unless overridden. Act on the user's request; no special command syntax is required. The new thread inherits this one's project, model, permission mode, interaction mode, compression and subagent policy, and every one of those can be set here instead - what you set is already in force for the first turn, so a thread never has to be corrected after it starts. Set modelSelection to run it on another model: give the model id, and leave instanceId out to keep this thread's provider instance. Once started it can be watched with thread_watch_events and changed later with thread_configure. A thread that was itself started this way cannot start another.",
|
|
128470
128498
|
parameters: ThreadSpawnInput,
|
|
128471
128499
|
success: ThreadSpawnResult,
|
|
128472
128500
|
failure: ThreadControlToolError,
|
|
@@ -128870,21 +128898,21 @@ const ThreadToolkitHandlersLive = ThreadToolkit.toLayer({
|
|
|
128870
128898
|
yield* dispatchControl({
|
|
128871
128899
|
type: "thread.turn.start",
|
|
128872
128900
|
commandId: yield* newCommandId,
|
|
128873
|
-
threadId,
|
|
128901
|
+
threadId: fusionPair?.watcherThreadId ?? threadId,
|
|
128874
128902
|
message: {
|
|
128875
128903
|
messageId: MessageId.make(yield* crypto.randomUUIDv4.pipe(Effect.orDie)),
|
|
128876
128904
|
role: "user",
|
|
128877
128905
|
text: input.prompt,
|
|
128878
128906
|
attachments: []
|
|
128879
128907
|
},
|
|
128880
|
-
modelSelection,
|
|
128908
|
+
modelSelection: fusionPair ? settings?.fusionWatcherModelSelection ?? modelSelection : modelSelection,
|
|
128881
128909
|
titleSeed: input.title,
|
|
128882
128910
|
runtimeMode,
|
|
128883
|
-
interactionMode,
|
|
128911
|
+
interactionMode: fusionPair ? "default" : interactionMode,
|
|
128884
128912
|
compressMode,
|
|
128885
128913
|
unpromptedSubagents,
|
|
128886
128914
|
createdAt
|
|
128887
|
-
}, threadId);
|
|
128915
|
+
}, fusionPair?.watcherThreadId ?? threadId);
|
|
128888
128916
|
return {
|
|
128889
128917
|
threadId,
|
|
128890
128918
|
projectId,
|
|
@@ -129524,7 +129552,7 @@ const registerPreviewSnapshot = Effect.fn("McpHttpServer.registerPreviewSnapshot
|
|
|
129524
129552
|
tool: new McpSchema.Tool({
|
|
129525
129553
|
name: tool.name,
|
|
129526
129554
|
description: Tool.getDescription(tool),
|
|
129527
|
-
inputSchema: Tool.getJsonSchema(tool),
|
|
129555
|
+
inputSchema: mcpInputSchema(Tool.getJsonSchema(tool)),
|
|
129528
129556
|
annotations: {
|
|
129529
129557
|
...Context.getOption(tool.annotations, Tool.Title).pipe(Option.map((title) => ({ title })), Option.getOrUndefined),
|
|
129530
129558
|
readOnlyHint: Context.get(tool.annotations, Tool.Readonly),
|
|
@@ -129566,13 +129594,13 @@ const registerPreviewSnapshot = Effect.fn("McpHttpServer.registerPreviewSnapshot
|
|
|
129566
129594
|
})
|
|
129567
129595
|
});
|
|
129568
129596
|
});
|
|
129569
|
-
const PreviewStandardToolkitRegistrationLive =
|
|
129597
|
+
const PreviewStandardToolkitRegistrationLive = mcpToolkit(PreviewStandardToolkit).pipe(Layer.provide(PreviewStandardToolkitHandlersLive));
|
|
129570
129598
|
const PreviewSnapshotRegistrationLive = Layer.effectDiscard(registerPreviewSnapshot()).pipe(Layer.provide(PreviewSnapshotToolkitHandlersLive));
|
|
129571
129599
|
const PreviewToolkitRegistrationLive = Layer.mergeAll(PreviewStandardToolkitRegistrationLive, PreviewSnapshotRegistrationLive);
|
|
129572
|
-
const TaskToolkitRegistrationLive =
|
|
129573
|
-
const ThreadToolkitRegistrationLive =
|
|
129574
|
-
const WatchToolkitRegistrationLive =
|
|
129575
|
-
const AdviseToolkitRegistrationLive =
|
|
129600
|
+
const TaskToolkitRegistrationLive = mcpToolkit(TaskToolkit).pipe(Layer.provide(TaskToolkitHandlersLive));
|
|
129601
|
+
const ThreadToolkitRegistrationLive = mcpToolkit(ThreadToolkit).pipe(Layer.provide(ThreadToolkitHandlersLive));
|
|
129602
|
+
const WatchToolkitRegistrationLive = mcpToolkit(WatchToolkit).pipe(Layer.provide(WatchToolkitHandlersLive));
|
|
129603
|
+
const AdviseToolkitRegistrationLive = mcpToolkit(AdviseToolkit).pipe(Layer.provide(AdviseToolkitHandlersLive));
|
|
129576
129604
|
const McpTransportLive = McpServer.layerHttp({
|
|
129577
129605
|
name: "P4Code",
|
|
129578
129606
|
version: version$1,
|
|
@@ -129584,7 +129612,7 @@ const ComputerUseMcpLive = ComputerUseToolkitRegistrationLive.pipe(Layer.provide
|
|
|
129584
129612
|
version: version$1,
|
|
129585
129613
|
path: "/mcp/computer-use"
|
|
129586
129614
|
}).pipe(Layer.provide(McpAuthMiddlewareLive))));
|
|
129587
|
-
const layer$3 = Layer.mergeAll(StandardMcpLive, ComputerUseMcpLive);
|
|
129615
|
+
const layer$3 = Layer.mergeAll(Layer.fresh(StandardMcpLive), Layer.fresh(ComputerUseMcpLive));
|
|
129588
129616
|
//#endregion
|
|
129589
129617
|
//#region src/hub/HubActivityTransport.ts
|
|
129590
129618
|
const REQUEST_TIMEOUT_MS = 8e3;
|
|
@@ -133983,6 +134011,8 @@ After restart/context loss, derive phase from workspace git log/status, PR, rece
|
|
|
133983
134011
|
const watcherPrompt = (input) => `${FUSION_REVIEW_PROMPT_PREFIX}
|
|
133984
134012
|
Review completed builder turn ${input.implementerThreadId}.
|
|
133985
134013
|
|
|
134014
|
+
${FUSION_WATCHER_TOOL_INSTRUCTIONS}
|
|
134015
|
+
|
|
133986
134016
|
Call thread_watch_review, threadId ${input.implementerThreadId}, afterSequence ${input.afterSequence}, throughSequence ${input.throughSequence}. Continue with nextAfterSequence and the same throughSequence until hasMore is false, including empty pages. Apply message append/replace operations by identity across pages. Recover truncated or uncertain evidence with targeted thread_watch_events reads using its source sequence range. Inspect repo when useful.
|
|
133987
134017
|
|
|
133988
134018
|
Always report concise:
|
|
@@ -134014,6 +134044,8 @@ const gateKindDescription = (gate) => {
|
|
|
134014
134044
|
const gatePrompt = (input) => `${FUSION_GATE_PROMPT_PREFIX}
|
|
134015
134045
|
Gate ${input.gate.id} is open on builder thread ${input.implementerThreadId}: ${gateKindDescription(input.gate)}. Round ${Math.min(input.gate.round + 1, input.roundCap)} of ${input.roundCap}.
|
|
134016
134046
|
|
|
134047
|
+
${FUSION_WATCHER_TOOL_INSTRUCTIONS}
|
|
134048
|
+
|
|
134017
134049
|
First read delta: thread_watch_review, threadId ${input.implementerThreadId}, afterSequence ${input.afterSequence}, throughSequence ${input.throughSequence}. Continue with nextAfterSequence and the same throughSequence until hasMore is false, including empty pages. Apply message append/replace operations by identity across pages; recover truncated or uncertain evidence with targeted thread_watch_events reads using its source sequence range. Inspect repo when useful.
|
|
134018
134050
|
|
|
134019
134051
|
Then thread_gate_respond, threadId ${input.implementerThreadId}, gateId ${input.gate.id}:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Et as i,Ga as a,Hr as o,Ja as s,Jr as c,Ka as l,Lr as ee,Pa as u,Pl as te,Ra as d,Vu as f,Wa as p,Zl as m,_n as ne,b as re,cu as h,dl as g,fl as _,gt as v,h as y,ht as b,ja as x,mu as S,pl as C,qa as ie,ru as w,st as T,ul as ae,vt as E,xn as D,za as oe}from"./previewAssetResource-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{Et as i,Ga as a,Hr as o,Ja as s,Jr as c,Ka as l,Lr as ee,Pa as u,Pl as te,Ra as d,Vu as f,Wa as p,Zl as m,_n as ne,b as re,cu as h,dl as g,fl as _,gt as v,h as y,ht as b,ja as x,mu as S,pl as C,qa as ie,ru as w,st as T,ul as ae,vt as E,xn as D,za as oe}from"./previewAssetResource-D3HjmQ_a.js";import{a as O,c as se,i as k,n as A,o as j,r as M,s as ce,t as N}from"./toggle-group-CKtx0pfu.js";import{F as le,Fr as ue,I as de,J as fe,L as pe,Lr as me,Mr as he,Nr as ge,R as P,Rr as _e,Y as ve,_ as ye,_r as be,at as xe,cr as Se,ct as Ce,dr as we,fr as Te,h as Ee,hr as De,it as Oe,jr as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rt as Ie,si as Le,sr as Re,st as ze,ur as Be,yr as Ve}from"./index-uIueElRa.js";import{a as He,n as Ue}from"./fileCommentAnnotations-4NC7LRU5.js";var We=C(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}T.getState().openFile(e,t);return}r(n?y(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=De(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:l,className:u,renderHeaderPrefix:te}=e,d=ee(Qe),f=ee(B),p;t[0]===a?p=t[1]:(p=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=p);let m=ee(p),[ne,re]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),_;t[2]===n?_=t[3]:(_=new Map(n.map(Ze)),t[2]=n,t[3]=_);let v=_,y;if(t[4]!==h||t[5]!==n||t[6]!==m||t[7]!==r){let e;t[9]!==h||t[10]!==m||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=m.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=c(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Oe(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=m,t[11]=r,t[12]=e):e=t[12],y=n.map(e),t[4]=h,t[5]=n,t[6]=m,t[7]=r,t[8]=y}else y=t[8];let b=y,x;t[13]!==a||t[14]!==h?.annotation||t[15]!==f?(x=e=>{re(null),h?.annotation.metadata.entries.some(t=>t.id===e)?g(null):f(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=f,t[16]=x):x=t[16];let S=x,C;t[17]!==d||t[18]!==a||t[19]!==h||t[20]!==v||t[21]!==r||t[22]!==i?(C=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),s=h?v.get(h.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&d(a,c),re(null),g(null)},t[17]=d,t[18]=a,t[19]=h,t[20]=v,t[21]=r,t[22]=i,t[23]=C):C=t[23];let ie=C,w;t[24]!==v||t[25]!==r||t[26]!==i?(w=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=v.get(n.id);if(!a)return;let s=Ue(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&g({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=v,t[25]=r,t[26]=i,t[27]=w):w=t[27];let T=w,ae=h!==null,E;t[28]===l?E=t[29]:(E=l?{ref:l}:{},t[28]=l,t[29]=E);let D;t[30]===u?D=t[31]:(D=u?{className:u}:{},t[30]=u,t[31]=D);let oe=!ae,se=!ae,k;t[32]!==T||t[33]!==s||t[34]!==se||t[35]!==oe?(k={...s,enableGutterUtility:oe,enableLineSelection:se,onLineSelectionEnd:T},t[32]=T,t[33]=s,t[34]=se,t[35]=oe,t[36]=k):k=t[36];let A;t[37]===te?A=t[38]:(A=e=>e.type===`diff`?te(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=te,t[38]=A);let j;t[39]!==S||t[40]!==ie?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>S(e.id),onComment:t=>ie(e.id,t),onDelete:()=>S(e.id)},e.id))}),t[39]=S,t[40]=ie,t[41]=j):j=t[41];let M;return t[42]!==b||t[43]!==ne||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==E||t[48]!==D?(M=(0,L.jsx)(O,{...E,...D,items:b,selectedLines:ne,onSelectedLinesChange:re,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=b,t[43]=ne,t[44]=k,t[45]=A,t[46]=j,t[47]=E,t[48]=D,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:m(e,{label:`environment-data:review:diff-preview`,tag:f.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(D);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
|
|
2
2
|
[data-diffs-header],
|
|
3
3
|
[data-diff],
|
|
4
4
|
[data-file],
|
|
@@ -94,5 +94,5 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
94
94
|
color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
|
|
95
95
|
text-decoration-color: currentColor;
|
|
96
96
|
}
|
|
97
|
-
`;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:o}=re(),c=ue(),[ee]=(0,F.useState)(n),[f,m]=(0,F.useState)(`stacked`),[y,C]=(0,F.useState)(c.wordWrap),[T,D]=(0,F.useState)(c.diffIgnoreWhitespace),[O,ye]=(0,F.useState)(``),[Oe,ke]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=ge(r),qe=I?.projectId??null,Je=he(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=te(ne.configValueAtom(I?.environmentId??null)),Xe=be(I?.environmentId??null,z?.availableEditors??[]),Ze=i(I!=null&&R!=null?Ae.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>pe(e.byThreadKey,r,ee===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=de(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Oe.scopeKey===Y?Oe.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:T,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=i(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:T}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=i(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:T}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=i(W===null&&G===`branch`&&I&&X.data?.cwd?Ae.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),vt=i(W===null&&G===`branch`&&I&&X.data?.cwd?Ae.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,O),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...O.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>ze(Tt,`diff-panel:${o}`,{compactPartialHunkOffsets:W===null}),[o,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>Me(e).localeCompare(Me(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Le(e);return{fileDiff:e,filePath:Me(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=M(jt,ut),Nt=(0,F.useMemo)(()=>Fe(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=le({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!w(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...S(h(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{ke(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{ke(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ve,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(u,{children:[(0,L.jsxs)(ie,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(g,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(oe,{align:`start`,className:`w-60`,children:[(0,L.jsx)(d,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(d,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(d,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(p,{children:[(0,L.jsx)(l,{children:`Turn`}),(0,L.jsx)(a,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(d,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ve(e.completedAt,c.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(Ne,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Pe,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||ye(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ee,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(g,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Te,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(_e,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Ce,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:O,onChange:e=>ye(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Re,{children:`No matching refs.`}),(0,L.jsxs)(Be,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(je,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(je,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Ie,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(_,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(De,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(x,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(xe,{className:`size-3`}):(0,L.jsx)(se,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[f],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&m(t)},children:[(0,L.jsx)(N,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(N,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(N,{"aria-label":y?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:y,onPressedChange:e=>{C(!!e)}}),children:(0,L.jsx)(me,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:y?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(N,{"aria-label":T?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:T,onPressedChange:e=>{D(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:T?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=Me(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(`button`,{type:`button`,className:s(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,Se(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(ae,{className:`size-4`}):(0,L.jsx)(g,{className:`size-4`})}),(0,L.jsx)(v,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:f===`split`?`split`:`unified`,lineDiffType:`none`,overflow:y?`wrap`:`scroll`,theme:we(o),themeType:o,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:s(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,y?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(fe,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{ye as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-
|
|
97
|
+
`;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:o}=re(),c=ue(),[ee]=(0,F.useState)(n),[f,m]=(0,F.useState)(`stacked`),[y,C]=(0,F.useState)(c.wordWrap),[T,D]=(0,F.useState)(c.diffIgnoreWhitespace),[O,ye]=(0,F.useState)(``),[De,Oe]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=ge(r),qe=I?.projectId??null,Je=he(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=te(ne.configValueAtom(I?.environmentId??null)),Xe=be(I?.environmentId??null,z?.availableEditors??[]),Ze=i(I!=null&&R!=null?ke.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>pe(e.byThreadKey,r,ee===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=de(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=De.scopeKey===Y?De.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:T,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=i(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:T}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=i(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:T}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=i(W===null&&G===`branch`&&I&&X.data?.cwd?ke.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),vt=i(W===null&&G===`branch`&&I&&X.data?.cwd?ke.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,O),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...O.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>ze(Tt,`diff-panel:${o}`,{compactPartialHunkOffsets:W===null}),[o,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>je(e).localeCompare(je(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Ie(e);return{fileDiff:e,filePath:je(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=M(jt,ut),Nt=(0,F.useMemo)(()=>Pe(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=le({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!w(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...S(h(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Oe(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{Oe(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ve,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(u,{children:[(0,L.jsxs)(ie,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(g,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(oe,{align:`start`,className:`w-60`,children:[(0,L.jsx)(d,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(d,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(d,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(p,{children:[(0,L.jsx)(l,{children:`Turn`}),(0,L.jsx)(a,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(d,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ve(e.completedAt,c.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(Le,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||ye(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Te,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(g,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(we,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(_e,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Se,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:O,onChange:e=>ye(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Re,{children:`No matching refs.`}),(0,L.jsxs)(Be,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ae,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Fe,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(_,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(Ee,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(x,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Me,{className:`size-3`}):(0,L.jsx)(se,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[f],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&m(t)},children:[(0,L.jsx)(N,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(N,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(N,{"aria-label":y?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:y,onPressedChange:e=>{C(!!e)}}),children:(0,L.jsx)(me,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:y?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(N,{"aria-label":T?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:T,onPressedChange:e=>{D(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:T?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=je(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(E,{render:(0,L.jsx)(`button`,{type:`button`,className:s(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,xe(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(ae,{className:`size-4`}):(0,L.jsx)(g,{className:`size-4`})}),(0,L.jsx)(v,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:f===`split`?`split`:`unified`,lineDiffType:`none`,overflow:y?`wrap`:`scroll`,theme:Ce(o),themeType:o,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:s(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,y?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(fe,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{ye as DiffWorkerPoolProvider,U as default};
|
|
98
|
+
//# sourceMappingURL=DiffPanel-nfXQ6agW.js.map
|