@p4code/cli 0.6.18 → 0.6.20

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 CHANGED
@@ -268,7 +268,7 @@ const make$124 = () => {
268
268
  const layer$124 = Layer.sync(NetService, make$124);
269
269
  //#endregion
270
270
  //#region package.json
271
- var version$1 = "0.6.18";
271
+ var version$1 = "0.6.20";
272
272
  //#endregion
273
273
  //#region src/config.ts
274
274
  /**
@@ -2921,6 +2921,8 @@ const MODEL_SLUG_ALIASES_BY_PROVIDER = {
2921
2921
  "opus-4.6": "claude-opus-4-6",
2922
2922
  "claude-opus-4.6": "claude-opus-4-6",
2923
2923
  "claude-opus-4-6-20251117": "claude-opus-4-6",
2924
+ "sonnet-5.5": "claude-sonnet-5-5",
2925
+ "claude-sonnet-5.5": "claude-sonnet-5-5",
2924
2926
  sonnet: "claude-sonnet-5",
2925
2927
  "sonnet-5": "claude-sonnet-5",
2926
2928
  "claude-sonnet-5.0": "claude-sonnet-5",
@@ -3293,6 +3295,7 @@ const FUSION_RETRY_PROMPT_PREFIX = "[fusion-retry]";
3293
3295
  */
3294
3296
  const FUSION_REVIEW_MESSAGE_ID_PREFIX = "fusion-review:";
3295
3297
  const FUSION_GATE_MESSAGE_ID_PREFIX = "fusion-gate:";
3298
+ const FUSION_EVIDENCE_REPORT_REPAIR_MESSAGE_ID_PREFIX = "fusion-evidence-report-repair:";
3296
3299
  const FUSION_GATE_UNWATCHED_SUMMARY = "Gate passed unwatched";
3297
3300
  const FUSION_GATE_DEFAULT_TIMEOUT_MS = 12e4;
3298
3301
  const OrchestrationProposedPlanId = TrimmedNonEmptyString;
@@ -3401,7 +3404,8 @@ const JEV_CONSULTED_ACTIVITY_KIND = "jev.consulted";
3401
3404
  const JevConsultedFeature = Schema$1.Literals([
3402
3405
  "capability-hints",
3403
3406
  "auto-workspace",
3404
- "role-routing"
3407
+ "role-routing",
3408
+ "live-surface"
3405
3409
  ]);
3406
3410
  /**
3407
3411
  * Which Fusion role-routing decision a consultation answered: who owns a user
@@ -7803,7 +7807,9 @@ const ProviderSendTurnInput = Schema$1.Struct({
7803
7807
  interactionMode: Schema$1.optional(ProviderInteractionMode),
7804
7808
  compressMode: Schema$1.optional(CompressMode),
7805
7809
  unpromptedSubagents: Schema$1.optional(Schema$1.Boolean),
7806
- fusionRole: Schema$1.optional(FusionRole)
7810
+ fusionRole: Schema$1.optional(FusionRole),
7811
+ /** False when Jev judged the turn needs no Computer Use; omits its routing note. */
7812
+ computerUseGuidance: Schema$1.optional(Schema$1.Boolean)
7807
7813
  });
7808
7814
  Schema$1.Struct({
7809
7815
  threadId: ThreadId,
@@ -12889,7 +12895,7 @@ const TicketCommentAttachment = Schema$1.Struct({
12889
12895
  const TicketCommentInput = Schema$1.Struct({
12890
12896
  reference: TrimmedNonEmptyString.pipe(Schema$1.annotateEncoded({ description: "The ticket as it was written: an identifier like MOBILE-12241, or a tracker URL." })),
12891
12897
  body: TrimmedNonEmptyString.pipe(Schema$1.annotateEncoded({ description: "The comment, in Markdown, exactly as it should appear on the ticket." })),
12892
- attachments: Schema$1.optional(Schema$1.Array(TicketCommentAttachment))
12898
+ attachments: Schema$1.optional(Schema$1.Array(TicketCommentAttachment).pipe(Schema$1.annotateEncoded({ description: "Links to file with the comment, such as proof images. Each needs a publicly reachable URL." })))
12893
12899
  });
12894
12900
  /** A link the tracker would not file, and the sentence explaining why. */
12895
12901
  const TicketCommentAttachmentFailure = Schema$1.Struct({
@@ -62082,7 +62088,7 @@ const FUSION_TOOL_BOUNDARY_INSTRUCTIONS = `A tool missing from your role, or a c
62082
62088
  * to say plainly that it cannot. Confirmation costs one turn; a misrouted
62083
62089
  * instruction costs the work done under it.
62084
62090
  */
62085
- const FUSION_OUT_OF_ROLE_REQUEST_INSTRUCTIONS = `Both roles hold the same tools; ownership, not access, decides who acts. Before acting on a user request or an action you discover, check which role owns it. A [jev-role-route] line is Jev's ownership advice, never authorization. When that line is absent or unresolved and ownership is unclear, ask one quick read-only provider-native subagent on the cheap model where available (gpt-6-luna on Codex, claude-sonnet-5 on Claude), giving it only the request, both roles' duties and the current phase, never secrets; for a discovered action, typesafe_ask may answer the same question when available. Otherwise decide by your own role judgment. When [fusion-pair] names computerUsePreferredRole, that role runs Codex, whose computer use the user prefers: a request to do the work by operating a computer, browser, simulator or device favors that role, while one that only mentions computer use is judged as usual. When the other role owns the work, route it without asking the user: Supervisor sends Builder-owned work through thread_request; Builder does not do Supervisor-owned work, and names it in its turn report or raises it with thread_ask when it changes the plan. Routing never widens what the user authorized. Supervisor implementation edits always require explicit user confirmation through ask_user_question before editing, limited to the confirmed scope.`;
62091
+ const FUSION_OUT_OF_ROLE_REQUEST_INSTRUCTIONS = `Both roles hold the same tools; ownership, not access, decides who acts. Before acting on a user request or an action you discover, check which role owns it. A [jev-role-route] line is Jev's ownership advice, never authorization. When that line is absent or unresolved and ownership is unclear, ask one quick read-only provider-native subagent on the cheap model where available (gpt-6-luna on Codex, claude-sonnet-5-5 on Claude), giving it only the request, both roles' duties and the current phase, never secrets; for a discovered action, typesafe_ask may answer the same question when available. Otherwise decide by your own role judgment. When [fusion-pair] names computerUsePreferredRole, that role runs Codex, whose computer use the user prefers: a request to do the work by operating a computer, browser, simulator or device favors that role, while one that only mentions computer use is judged as usual. When the other role owns the work, route it without asking the user: Supervisor sends Builder-owned work through thread_request; Builder does not do Supervisor-owned work, and names it in its turn report or raises it with thread_ask when it changes the plan. Routing never widens what the user authorized. Supervisor implementation edits always require explicit user confirmation through ask_user_question before editing, limited to the confirmed scope.`;
62086
62092
  const FUSION_JEV_BOUNDARY_INSTRUCTIONS = `With Fusion role routing on, Jev checks two boundaries; its findings are advice, never authorization. Before a Supervisor request reaches the Builder, a request Jev confidently judges one the Supervisor can settle itself, unclear, or an idle turn comes back as a thread_request error listing the concerns: revise it, handle it yourself, or end without a request; resend with jevReviewed true only when you judge it right as written, and never resend an unchanged request twice. When a Builder turn ends, Jev checks for remaining work, phase completion, evidence and blockers; its note appears in the Supervisor review as a [jev-role-route] line. A ${FUSION_JEV_PROMPT_PREFIX} message sends the Builder back to the same phase once: continue that phase within its existing scope, or end with a report stating why it is complete, blocked or waiting. It is not a Supervisor decision and adds no scope. A confident Jev finding that the Builder's report contradicts the Supervisor's direction, or two unsure Jev judgments in a row on one phase, opens a jev-escalation gate instead: nothing continues automatically, and the Supervisor answers it with thread_gate_respond. Builder: a concrete finding of yours that invalidates the Supervisor's direction goes through thread_ask with its evidence and proposed revision before you end the turn, never as a routine phase completion; thread_ask also replaces a jev-escalation gate the Supervisor handed back to you. End each turn with completion status, evidence and blockers stated plainly so both checks can read them.`;
62087
62093
  const FUSION_BUILDER_INSTRUCTIONS = `You are Fusion Builder in an already-created native server pair. Server owns pairing and coordination. Follow the current turn's [fusion-review-policy] block when present; it overrides the phase-boundary scheduling rules below. Do not inspect or invoke the Fusion skill, create/pair/rename threads, or announce/setup Fusion. Start the user's task directly. The phase plan is not yours: Supervisor authors it, orders it, moves every phase status, and alone renders its Tasks banner. Your thread receives only the current phase through Supervisor requests and never gets a plan banner. Never create or edit a phase list yourself - not with TaskCreate, TaskUpdate, TodoWrite, update_plan, the MCP task board tools, or thread_plan_update - and never mark your own phase complete. Work the one phase Supervisor put in progress, and report what you did. Step-level notes for your own use are fine as long as they never become a phase list. 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 a report of at most six non-empty lines: the phase you finished, what changed and where, what you verified with its result, and anything unresolved. One line each, every fact once, no restatement of the plan or of request you were given. Code, exact error text and security warnings are exempt from the cap. 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. 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. thread_ask is a low-friction plan objection channel, not a generic question loop: call it only when a concrete objection, discovered implementation constraint, or proposed revision invalidates the Supervisor-owned plan. Send the current phase, exact objection or reason, and suggested replacement or addition. The call pauses only the affected work and wakes the paired Supervisor. Continue independent work within the approved scope while it considers the revision. Resume affected work only after it sends a request to you with an explicit accept, modify, or reject decision through ${FUSION_ADVICE_PROMPT_PREFIX}. Accept and modify update the plan first; reject preserves it. After thread_ask, stop only affected work; do not apply the proposed revision or edit the plan yourself. Evaluate/follow Supervisor requests unless conflicting with user request or verified repo state. Both roles may read either paired conversation on demand with thread_watch_review or thread_watch_events. Read only what the task needs; do not preload full histories. thread_evidence_report remains Supervisor-owned. Unrelated threads are outside this grant. Both roles may read task-relevant tickets, comments, images, design files, documents and other configured external sources when needed, under existing permissions. Supervisor owns authorized ticket changes and comments; Builder owns authorized commits, pushes, pull requests and releases. Access does not grant permission to write. Both follow applicable global/project instructions and load relevant memories and skills on demand. Before ending a phase, save its concise summary, blockers and evidence links with thread_context_update, then report the summary in your response. Read the canonical plan and shared working context through thread_context_read or thread_plan_read when needed. ${FUSION_OUT_OF_ROLE_REQUEST_INSTRUCTIONS} ${FUSION_JEV_BOUNDARY_INSTRUCTIONS} ${FUSION_TOOL_BOUNDARY_INSTRUCTIONS} ${FUSION_PAIR_COMMUNICATION_INSTRUCTIONS}`;
62088
62094
  const FUSION_WATCHER_TOOL_INSTRUCTIONS = `Before the first thread_request, publish the complete detailed implementation plan you own: ordered phases plus each phase's intended behavior, likely code boundaries, completion condition, and deferred verification. The plan renders only in your Supervisor Tasks banner; naming the paired Builder in thread_plan_update stamps its current boundary without writing any Builder plan activity. Before every later phase-boundary thread_request, publish the whole plan again after the Builder turn: advance the approved phase, keep or reopen the current phase for rework, and leave exactly one phase in progress. The server rejects stale or partial plan state. Final approval updates every phase to completed and ends without thread_request; an all-complete plan cannot restart the Builder. A request appended to a currently running Builder turn, a true interrupt, waitForUser, or rejecting a plan objection skips this phase-sync requirement. Ordinary requests enter Builder context as normal user messages without cancelling work; use interrupt only when the request requires it. Keep the Tasks banner concise. Save requirements, decisions, blockers and evidence links with thread_context_update. Both roles can read the same saved plan and working context with thread_context_read; do not copy full transcripts into shared state. Send only the current in-progress phase through thread_request, with enough detailed requirements and completion evidence that the Builder should not need corrective discovery turns; never copy the complete phase list into requests. Supervisor tools belong to the p4-code MCP server: thread_watch_review, thread_watch_events, thread_evidence_report, thread_plan_update, thread_request, thread_gate_respond, and the task board tools task_current, task_get, task_list, task_create and task_update. Read the board whenever planning needs it, and read a named ticket with ticket_resolve together with its comments, treating a later comment as newer intent than the description. Resolve which task that is by calling task_current with the builder's threadId, because a pair started from the board links the row to the builder and not to you; a bare task_current answers for your own thread and reports the task as unlinked. Write only within that task: update it or a subtask you created under it, never an unrelated row and never another project's board. A direct request in the current user message to create a task or ticket is a separate, explicit authorization. Check the requested source first for the same task: call task_list with that source and a query from the proposed title or context, then compare the returned task; task_current accepts the same source when the conversation already links it. If the task exists, report it instead of creating another. Otherwise call task_create once yourself in that turn with linkCurrentThread true and the requested source. Do not send creation through the Builder or ask whether the user meant the Builder. Never repeat creation from a later Builder completion or review wake. This exception authorizes only the task the user requested, never an inferred external write or an unrelated tracker mutation. 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 within your role, use the Builder summary first, recover underlying evidence only when needed, and send a request through thread_request. For a plan-objection gate, choose accept, modify, or reject: accept and modify require thread_plan_update before thread_request, while reject preserves the current plan and goes directly through thread_request. Answer every other open gate through thread_gate_respond. Structure every actionable Supervisor request message with these Markdown headings, in order:
@@ -62142,8 +62148,8 @@ const FUSION_DETACHED_REMINDER = "[fusion-detached] The Fusion pair ended. Fusio
62142
62148
  */
62143
62149
  const FUSION_SUMMARIZER_MODEL_BY_PROVIDER = {
62144
62150
  codex: "gpt-6-luna",
62145
- claudeAgent: "claude-sonnet-5",
62146
- claude: "claude-sonnet-5"
62151
+ claudeAgent: "claude-sonnet-5-5",
62152
+ claude: "claude-sonnet-5-5"
62147
62153
  };
62148
62154
  /**
62149
62155
  * The model the supervisor is told to spawn its summarizer on.
@@ -66873,7 +66879,7 @@ function hasValidClaudeManifestAdapters(manifest) {
66873
66879
  //#region src/provider/model-manifest.json
66874
66880
  var model_manifest_default = {
66875
66881
  version: 1,
66876
- updatedAt: "2026-09-04T19:10:48Z",
66882
+ updatedAt: "2026-09-28T20:00:00Z",
66877
66883
  currentModels: {
66878
66884
  "codex": [
66879
66885
  "gpt-6-astra",
@@ -66886,6 +66892,7 @@ var model_manifest_default = {
66886
66892
  "claudeAgent": [
66887
66893
  "claude-fable-5-1",
66888
66894
  "claude-opus-5",
66895
+ "claude-sonnet-5-5",
66889
66896
  "claude-sonnet-5"
66890
66897
  ],
66891
66898
  "antigravity": [
@@ -67404,6 +67411,15 @@ var model_manifest_default = {
67404
67411
  "status": "legacy",
67405
67412
  "profile": "opus-4-5"
67406
67413
  },
67414
+ {
67415
+ "slug": "claude-sonnet-5-5",
67416
+ "name": "Claude Sonnet 5.5",
67417
+ "aliases": ["sonnet-5.5", "claude-sonnet-5.5"],
67418
+ "status": "current",
67419
+ "badge": "new",
67420
+ "profile": "sonnet-5",
67421
+ "adapter": { "claudeCode": { "minVersion": "2.1.284" } }
67422
+ },
67407
67423
  {
67408
67424
  "slug": "claude-sonnet-5",
67409
67425
  "name": "Claude Sonnet 5",
@@ -68263,6 +68279,7 @@ const CLAUDE_PRESENTATION = {
68263
68279
  displayName: "Claude",
68264
68280
  showInteractionModeToggle: true
68265
68281
  };
68282
+ const MINIMUM_CLAUDE_SONNET_5_5_VERSION = "2.1.284";
68266
68283
  const MINIMUM_CLAUDE_FABLE_5_1_VERSION = "2.1.257";
68267
68284
  const MINIMUM_CLAUDE_OPUS_5_VERSION = "2.1.219";
68268
68285
  const MINIMUM_CLAUDE_FABLE_5_VERSION = "2.1.169";
@@ -68594,6 +68611,58 @@ const BUILT_IN_MODELS = [
68594
68611
  label: "Fast Mode"
68595
68612
  })] })
68596
68613
  },
68614
+ {
68615
+ slug: "claude-sonnet-5-5",
68616
+ name: "Claude Sonnet 5.5",
68617
+ isCustom: false,
68618
+ capabilities: createModelCapabilities({ optionDescriptors: [
68619
+ buildSelectOptionDescriptor({
68620
+ id: "effort",
68621
+ label: "Reasoning",
68622
+ options: [
68623
+ {
68624
+ value: "low",
68625
+ label: "Low"
68626
+ },
68627
+ {
68628
+ value: "medium",
68629
+ label: "Medium"
68630
+ },
68631
+ {
68632
+ value: "high",
68633
+ label: "High",
68634
+ isDefault: true
68635
+ },
68636
+ {
68637
+ value: "xhigh",
68638
+ label: "Extra High"
68639
+ },
68640
+ {
68641
+ value: "max",
68642
+ label: "Max"
68643
+ },
68644
+ {
68645
+ value: "ultrathink",
68646
+ label: "Ultrathink"
68647
+ }
68648
+ ],
68649
+ promptInjectedValues: ["ultrathink"]
68650
+ }),
68651
+ buildSelectOptionDescriptor({
68652
+ id: "contextWindow",
68653
+ label: "Context Window",
68654
+ options: [{
68655
+ value: "200k",
68656
+ label: "200k",
68657
+ isDefault: true
68658
+ }, {
68659
+ value: "1m",
68660
+ label: "1M"
68661
+ }]
68662
+ }),
68663
+ buildAutoCompactWindowDescriptor()
68664
+ ] })
68665
+ },
68597
68666
  {
68598
68667
  slug: "claude-sonnet-5",
68599
68668
  name: "Claude Sonnet 5",
@@ -68704,6 +68773,9 @@ const BUILT_IN_MODELS = [
68704
68773
  })] })
68705
68774
  }
68706
68775
  ];
68776
+ function supportsClaudeSonnet55(version) {
68777
+ return version ? compareSemverVersions(version, MINIMUM_CLAUDE_SONNET_5_5_VERSION) >= 0 : false;
68778
+ }
68707
68779
  function supportsClaudeOpus5(version) {
68708
68780
  return version ? compareSemverVersions(version, MINIMUM_CLAUDE_OPUS_5_VERSION) >= 0 : false;
68709
68781
  }
@@ -68721,6 +68793,7 @@ function supportsClaudeOpus47(version) {
68721
68793
  }
68722
68794
  function getBuiltInClaudeModelsForVersion(version) {
68723
68795
  return BUILT_IN_MODELS.filter((model) => {
68796
+ if (model.slug === "claude-sonnet-5-5") return supportsClaudeSonnet55(version);
68724
68797
  if (model.slug === "claude-fable-5-1") return supportsClaudeFable51(version);
68725
68798
  if (model.slug === "claude-opus-5") return supportsClaudeOpus5(version);
68726
68799
  if (model.slug === "claude-fable-5") return supportsClaudeFable5(version);
@@ -68749,6 +68822,9 @@ function mergeClaudeManifestModels(models, manifest, version) {
68749
68822
  }
68750
68823
  return additions.length === 0 ? models : [...models, ...additions];
68751
68824
  }
68825
+ function formatClaudeSonnet55UpgradeMessage(version) {
68826
+ return `Claude Code ${version ? `v${version}` : "the installed version"} is too old for Claude Sonnet 5.5. Upgrade to v${MINIMUM_CLAUDE_SONNET_5_5_VERSION} or newer to access it.`;
68827
+ }
68752
68828
  function formatClaudeFable51UpgradeMessage(version) {
68753
68829
  return `Claude Code ${version ? `v${version}` : "the installed version"} is too old for Claude Fable 5.1. Upgrade to v${MINIMUM_CLAUDE_FABLE_5_1_VERSION} or newer to access it.`;
68754
68830
  }
@@ -68804,7 +68880,7 @@ function normalizeClaudeCliEffort(effort, model, manifest, customModels = []) {
68804
68880
  if (catalog) return normalizeClaudeCatalogEffort(catalog, effort, model);
68805
68881
  if (!effort || effort === "ultrathink") return;
68806
68882
  if (effort === "ultracode") return "xhigh";
68807
- if (effort === "xhigh" && model !== "claude-fable-5-1" && model !== "claude-fable-5" && model !== "claude-opus-5" && model !== "claude-opus-4-8" && model !== "claude-sonnet-5") return "max";
68883
+ if (effort === "xhigh" && model !== "claude-fable-5-1" && model !== "claude-fable-5" && model !== "claude-opus-5" && model !== "claude-opus-4-8" && model !== "claude-sonnet-5-5" && model !== "claude-sonnet-5") return "max";
68808
68884
  if (effort === "max" && model === "claude-sonnet-4-6") return "high";
68809
68885
  return effort;
68810
68886
  }
@@ -69126,7 +69202,7 @@ const checkClaudeProviderStatus = Effect.fn("checkClaudeProviderStatus")(functio
69126
69202
  });
69127
69203
  }
69128
69204
  const models = providerModelsFromSettings(mergeClaudeManifestModels(getBuiltInClaudeModelsForVersion(parsedVersion), manifest, parsedVersion), claudeSettings.customModels, DEFAULT_CLAUDE_MODEL_CAPABILITIES);
69129
- const versionUpgradeMessage = supportsClaudeFable51(parsedVersion) ? void 0 : supportsClaudeOpus5(parsedVersion) ? formatClaudeFable51UpgradeMessage(parsedVersion) : supportsClaudeFable5(parsedVersion) ? formatClaudeOpus5UpgradeMessage(parsedVersion) : supportsClaudeOpus48(parsedVersion) ? formatClaudeFable5UpgradeMessage(parsedVersion) : supportsClaudeOpus47(parsedVersion) ? formatClaudeOpus48UpgradeMessage(parsedVersion) : formatClaudeOpus47UpgradeMessage(parsedVersion);
69205
+ const versionUpgradeMessage = supportsClaudeSonnet55(parsedVersion) ? void 0 : supportsClaudeFable51(parsedVersion) ? formatClaudeSonnet55UpgradeMessage(parsedVersion) : supportsClaudeOpus5(parsedVersion) ? formatClaudeFable51UpgradeMessage(parsedVersion) : supportsClaudeFable5(parsedVersion) ? formatClaudeOpus5UpgradeMessage(parsedVersion) : supportsClaudeOpus48(parsedVersion) ? formatClaudeFable5UpgradeMessage(parsedVersion) : supportsClaudeOpus47(parsedVersion) ? formatClaudeOpus48UpgradeMessage(parsedVersion) : formatClaudeOpus47UpgradeMessage(parsedVersion);
69130
69206
  const capabilities = resolveCapabilities ? yield* resolveCapabilities(claudeSettings).pipe(Effect.orElseSucceed(() => void 0)) : void 0;
69131
69207
  const skills = yield* discoverClaudeSkills(claudeSettings, cwd, resolvedEnvironment, disabledSkills);
69132
69208
  const dedupedSlashCommands = dedupeSlashCommands(capabilities?.slashCommands ?? []);
@@ -69868,7 +69944,7 @@ const INSTRUCTIONS_AND_MEMORY_PROMPT = "Follow applicable global and project ins
69868
69944
  const encodeUnknownJsonStringExit$3 = Schema$1.encodeUnknownExit(Schema$1.UnknownFromJsonString);
69869
69945
  const decodeUnknownJsonStringExit = Schema$1.decodeUnknownExit(Schema$1.UnknownFromJsonString);
69870
69946
  const PROVIDER$6 = ProviderDriverKind.make("claudeAgent");
69871
- const DEFAULT_CLAUDE_SUBAGENT_MODEL = "claude-sonnet-5";
69947
+ const DEFAULT_CLAUDE_SUBAGENT_MODEL = "claude-sonnet-5-5";
69872
69948
  function encodeJsonStringForDiagnostics$3(input) {
69873
69949
  const result = encodeUnknownJsonStringExit$3(input);
69874
69950
  return Exit.isSuccess(result) ? result.value : void 0;
@@ -132767,6 +132843,7 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker, computerUseBrok
132767
132843
  currentBranch: localStatus.refName,
132768
132844
  defaultBranch: defaultBranchName
132769
132845
  }, textGeneration, jevWorkspaceAdvisor);
132846
+ const picked = decision;
132770
132847
  let preparedBranch = null;
132771
132848
  if (decision.mode === "local" || decision.mode === "default-branch") {
132772
132849
  const prepared = yield* prepareSharedCheckout({
@@ -132823,7 +132900,7 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker, computerUseBrok
132823
132900
  },
132824
132901
  createdAt: command.createdAt
132825
132902
  });
132826
- if (decision.source === "jev") yield* orchestrationEngine.dispatch({
132903
+ if (picked.source === "jev") yield* orchestrationEngine.dispatch({
132827
132904
  type: "thread.activity.append",
132828
132905
  commandId: yield* serverCommandId("jev-consulted-workspace"),
132829
132906
  threadId: command.threadId,
@@ -132835,7 +132912,7 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker, computerUseBrok
132835
132912
  summary: "Consulted with Jev",
132836
132913
  payload: {
132837
132914
  feature: "auto-workspace",
132838
- summary: decision.mode === "worktree" ? "Chose a new worktree" : decision.mode === "default-branch" ? "Chose the default branch" : "Chose the current checkout"
132915
+ summary: picked.mode === "worktree" ? "Chose a new worktree" : picked.mode === "default-branch" ? "Chose the default branch" : "Chose the current checkout"
132839
132916
  },
132840
132917
  createdAt: command.createdAt
132841
132918
  },
@@ -134516,6 +134593,12 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
134516
134593
  const serverSettings = yield* ServerSettingsService;
134517
134594
  const projectionQuery = yield* Effect.serviceOption(ProjectionSnapshotQuery);
134518
134595
  const pendingCompactions = /* @__PURE__ */ new Map();
134596
+ /**
134597
+ * The provider session whose conversation already carries the Computer Use
134598
+ * note, by thread. Jev may drop the note only on a later turn of that same
134599
+ * session; a new session, a compaction or a rollback sends it again.
134600
+ */
134601
+ const computerUseNoteSessions = /* @__PURE__ */ new Map();
134519
134602
  const timedOutNativeCompactions = /* @__PURE__ */ new Set();
134520
134603
  const settleCompaction = (threadId, pending, terminal) => Effect.gen(function* () {
134521
134604
  if (pendingCompactions.get(threadId) !== pending) return false;
@@ -134640,6 +134723,7 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
134640
134723
  provider: canonicalEvent.provider,
134641
134724
  eventType: canonicalEvent.type
134642
134725
  });
134726
+ if (isCompactedEvent(canonicalEvent)) computerUseNoteSessions.delete(canonicalEvent.threadId);
134643
134727
  if (isCompactedEvent(canonicalEvent) && timedOutNativeCompactions.delete(canonicalEvent.threadId)) {
134644
134728
  yield* publishRuntimeEvent(canonicalEvent);
134645
134729
  return;
@@ -134897,9 +134981,14 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
134897
134981
  ...input.modelSelection?.model ? { "provider.model": input.modelSelection.model } : {}
134898
134982
  });
134899
134983
  yield* touchActiveMcpThread(input.threadId);
134984
+ const mcpSession = readMcpProviderSession(input.threadId);
134985
+ const noteCarried = mcpSession !== void 0 && computerUseNoteSessions.get(input.threadId) === mcpSession.providerSessionId;
134986
+ const sendComputerUseNote = !forCompaction && Boolean(mcpSession?.computerUse) && (input.computerUseGuidance !== false || !noteCarried);
134987
+ if (forCompaction) computerUseNoteSessions.delete(input.threadId);
134988
+ else if (sendComputerUseNote && mcpSession !== void 0) computerUseNoteSessions.set(input.threadId, mcpSession.providerSessionId);
134900
134989
  const turn = yield* routed.adapter.sendTurn({
134901
134990
  ...input,
134902
- input: withComputerUseRouting(input.input, !forCompaction && Boolean(readMcpProviderSession(input.threadId)?.computerUse), computerUseMcpServerName(routed.adapter.provider))
134991
+ input: withComputerUseRouting(input.input, sendComputerUseNote, computerUseMcpServerName(routed.adapter.provider))
134903
134992
  });
134904
134993
  yield* directory.upsert({
134905
134994
  threadId: input.threadId,
@@ -134937,6 +135026,7 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
134937
135026
  });
134938
135027
  const sendTurn = (input) => sendTurnInternal(input);
134939
135028
  const compactThread = Effect.fn("compactThread")(function* (threadId, modelSelection, requestId) {
135029
+ computerUseNoteSessions.delete(threadId);
134940
135030
  const routed = yield* resolveRoutableSession({
134941
135031
  threadId,
134942
135032
  operation: "ProviderService.compactThread",
@@ -135213,6 +135303,7 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
135213
135303
  payload: rawInput
135214
135304
  });
135215
135305
  if (input.numTurns === 0) return;
135306
+ computerUseNoteSessions.delete(input.threadId);
135216
135307
  let metricProvider = "unknown";
135217
135308
  return yield* Effect.gen(function* () {
135218
135309
  const routed = yield* resolveRoutableSession({
@@ -137836,11 +137927,12 @@ const ROLE_ROUTE_QUESTION = {
137836
137927
  "The state describes one request received by one half of a supervised coding pair: a Supervisor that plans and reviews, and a Builder that implements.",
137837
137928
  "Both halves have the same tools. Decide which half should own the requested work, using the plan, current phase, shared context and gate state.",
137838
137929
  "Judge ownership only. Do not judge whether the work is allowed or wise.",
137930
+ "Requests are often short follow-ups to a conversation the state does not show. Judge the kind of work asked for, not how much detail is missing, and keep low confidence for requests that genuinely fit two owners.",
137839
137931
  "When the state names a computerUsePreferredRole and the request asks that the work itself be done by operating a computer, browser, simulator or device, choose that role. A request that only mentions computer use, such as editing its code or docs, is judged as usual."
137840
137932
  ].join(" "),
137841
137933
  criteria: {
137842
- supervisor: "Planning or re-planning phases, scope or requirement decisions, reviewing or approving Builder work, answering gates, task-board or ticket tracker changes and closeout comments, researching before planning, or starting and coordinating other threads.",
137843
- builder: "Implementation: editing code, configuration or docs; reproducing and fixing defects; running builds, tests or app verification; commits, pushes, pull requests and releases.",
137934
+ supervisor: "Planning or re-planning phases, scope or requirement decisions, reviewing or approving Builder work, answering gates, creating or updating tasks and tickets, tracker comments and closeout, researching before planning, or starting and coordinating other threads.",
137935
+ builder: "Implementation: editing code, configuration or docs; reproducing and fixing defects, including feedback that built work is wrong, slow or not as wanted; running, restarting or verifying apps, builds and tests; commits, pushes, pull requests, merging, shipping, deploying and releases.",
137844
137936
  either: "A question, status report or read-only lookup the receiving half can answer from shared context, which neither changes the plan nor the code."
137845
137937
  }
137846
137938
  };
@@ -139428,7 +139520,7 @@ const stageAnalyticsFact = Effect.fn("AnalyticsFactOutbox.stage")(function* (fac
139428
139520
  const pendingAnalyticsFacts = Effect.fn("AnalyticsFactOutbox.pending")(function* (limit = 16) {
139429
139521
  return yield* (yield* SqlClient.SqlClient)`
139430
139522
  SELECT event_id, payload FROM analytics_fact_outbox WHERE pending = 1
139431
- ORDER BY created_at, event_id LIMIT ${limit}`;
139523
+ ORDER BY created_at, rowid LIMIT ${limit}`;
139432
139524
  });
139433
139525
  /**
139434
139526
  * Mark one fact delivered.
@@ -142472,6 +142564,39 @@ const expandUserInvokedSkill = Effect.fnUntraced(function* (input) {
142472
142564
  //#region src/orchestration/Services/JevToolPrefetch.ts
142473
142565
  var JevToolPrefetch = class extends Context.Service()("@p4code/cli/orchestration/Services/JevToolPrefetch") {};
142474
142566
  //#endregion
142567
+ //#region src/orchestration/prefetch/jevLiveSurface.ts
142568
+ const SURFACES = [
142569
+ "none",
142570
+ "browser",
142571
+ "computer"
142572
+ ];
142573
+ /** Below this, the answer is ignored and the turn keeps the Computer Use note. */
142574
+ const JEV_LIVE_SURFACE_MIN_CONFIDENCE = .7;
142575
+ const JEV_LIVE_SURFACE_HINT_PREFIX = "[jev-surface]";
142576
+ const LIVE_SURFACE_QUESTION = {
142577
+ id: "live-surface",
142578
+ type: "choice",
142579
+ instructions: "The state is one message a user sent a coding agent. Decide which live surface the agent must operate this turn to do what the message asks. Editing code, docs or tests about a surface is not operating it.",
142580
+ criteria: {
142581
+ none: "No app, browser, simulator or device needs to be operated: code changes, questions, reviews, git, builds or tests.",
142582
+ browser: "A web page or web app must be opened, inspected, clicked, filled or screenshotted in a browser.",
142583
+ computer: "A native desktop app, simulator, emulator or connected device must be opened, inspected or driven."
142584
+ }
142585
+ };
142586
+ /** The confident surface in an answer, or nothing. */
142587
+ function readLiveSurface(answer, minConfidence = JEV_LIVE_SURFACE_MIN_CONFIDENCE) {
142588
+ if (answer?.type !== "choice" || answer.confidence < minConfidence) return void 0;
142589
+ return SURFACES.find((surface) => surface === answer.choice);
142590
+ }
142591
+ /** The advice appended to a browser turn; other surfaces add nothing. */
142592
+ function renderLiveSurfaceHint(surface) {
142593
+ return surface === "browser" ? `${JEV_LIVE_SURFACE_HINT_PREFIX} Browser work: use the p4-code preview_* tools, starting with preview_status, not Computer Use browser tabs. Advice only, not authorization.` : void 0;
142594
+ }
142595
+ /** The one-line summary for the consultation row. */
142596
+ function liveSurfaceSummary(surface) {
142597
+ return surface === "none" ? "No live surface" : surface === "browser" ? "Surface: built-in browser" : "Surface: computer";
142598
+ }
142599
+ //#endregion
142475
142600
  //#region src/orchestration/Layers/ProviderCommandReactor.ts
142476
142601
  const isProviderAdapterRequestError = Schema$1.is(ProviderAdapterRequestError);
142477
142602
  const isProviderDriverKind = Schema$1.is(ProviderDriverKind);
@@ -143335,36 +143460,46 @@ const make$8 = Effect.gen(function* () {
143335
143460
  reason: "provider not registered",
143336
143461
  instanceId: modelForTurn.instanceId
143337
143462
  });
143338
- const roleRouteInput = inputWithCompressSuffix !== void 0 && inputWithCompressSuffix.length + 600 + 2 <= 12e4 && activeFusionPair !== void 0 && fusionRole !== void 0 && !isFusionWatcherWakeMessageId(input.messageId) && !input.messageText.trimStart().startsWith("[fusion-") ? {
143463
+ const roleRouteInput = inputWithCompressSuffix !== void 0 && inputWithCompressSuffix.length + 600 + 2 <= 12e4 && activeFusionPair !== void 0 && fusionRole !== void 0 && !isFusionWatcherWakeMessageId(input.messageId) && !input.messageId.startsWith("fusion-evidence-report-repair:") && !input.messageText.trimStart().startsWith("[fusion-") ? {
143339
143464
  pair: activeFusionPair,
143340
143465
  callerRole: fusionRole,
143341
143466
  request: input.messageText,
143342
143467
  computerUseRole
143343
143468
  } : void 0;
143344
- const [prefetch, roleRoute] = yield* Effect.all([inputWithCompressSuffix === void 0 || prefetchProvider === void 0 ? Effect.succeed(void 0) : jevToolPrefetch.hintFor({
143345
- request: input.messageText,
143346
- skills: prefetchProvider.skills,
143347
- ...activeSession?.cwd ? {
143348
- cwd: activeSession.cwd,
143349
- resolveSkills: providerRegistry.getSkillsForCwd(modelForTurn.instanceId, activeSession.cwd)
143350
- } : {},
143351
- compact: compressMode !== "off",
143352
- maxChars: Math.max(0, PROVIDER_SEND_TURN_MAX_INPUT_CHARS - inputWithCompressSuffix.length - 2 - (roleRouteInput === void 0 ? 0 : 602)),
143353
- catalog: [...prefetchProvider.skills.map((skill) => ({
143354
- kind: "skill",
143355
- name: skill.name,
143356
- description: skill.description ?? skill.shortDescription,
143357
- enabled: skill.enabled
143358
- })), ...prefetchProvider.slashCommands.map((command) => ({
143359
- kind: "command",
143360
- name: command.name,
143361
- description: command.description
143362
- }))]
143363
- }), roleRouteInput === void 0 ? Effect.succeed(void 0) : jevRoleRouter.routeFor(roleRouteInput)], { concurrency: "unbounded" });
143469
+ const mcpSession = readMcpProviderSession(input.threadId);
143470
+ const consultLiveSurface = inputWithCompressSuffix !== void 0 && Boolean(mcpSession?.computerUse);
143471
+ const reservedHintChars = (roleRouteInput === void 0 ? 0 : 602) + (consultLiveSurface ? 242 : 0);
143472
+ const [prefetch, roleRoute, answeredSurface] = yield* Effect.all([
143473
+ inputWithCompressSuffix === void 0 || prefetchProvider === void 0 ? Effect.succeed(void 0) : jevToolPrefetch.hintFor({
143474
+ request: input.messageText,
143475
+ skills: prefetchProvider.skills,
143476
+ ...activeSession?.cwd ? {
143477
+ cwd: activeSession.cwd,
143478
+ resolveSkills: providerRegistry.getSkillsForCwd(modelForTurn.instanceId, activeSession.cwd)
143479
+ } : {},
143480
+ compact: compressMode !== "off",
143481
+ maxChars: Math.max(0, PROVIDER_SEND_TURN_MAX_INPUT_CHARS - inputWithCompressSuffix.length - 2 - reservedHintChars),
143482
+ catalog: [...prefetchProvider.skills.map((skill) => ({
143483
+ kind: "skill",
143484
+ name: skill.name,
143485
+ description: skill.description ?? skill.shortDescription,
143486
+ enabled: skill.enabled
143487
+ })), ...prefetchProvider.slashCommands.map((command) => ({
143488
+ kind: "command",
143489
+ name: command.name,
143490
+ description: command.description
143491
+ }))]
143492
+ }),
143493
+ roleRouteInput === void 0 ? Effect.succeed(void 0) : jevRoleRouter.routeFor(roleRouteInput),
143494
+ consultLiveSurface ? jevToolPrefetch.surfaceFor(input.messageText) : Effect.succeed(void 0)
143495
+ ], { concurrency: "unbounded" });
143496
+ const liveSurface = answeredSurface === "browser" && mcpSession?.browserAccess !== true ? void 0 : answeredSurface;
143497
+ const liveSurfaceHint = liveSurface !== void 0 && inputWithCompressSuffix !== void 0 && inputWithCompressSuffix.length + reservedHintChars <= 12e4 ? renderLiveSurfaceHint(liveSurface) : void 0;
143364
143498
  const inputWithPrefetchHint = inputWithCompressSuffix === void 0 ? void 0 : [
143365
143499
  inputWithCompressSuffix,
143366
143500
  prefetch?.hint,
143367
- roleRoute?.hint
143501
+ roleRoute?.hint,
143502
+ liveSurfaceHint
143368
143503
  ].filter((part) => part !== void 0).join("\n\n");
143369
143504
  if (prefetch !== void 0) yield* appendJevConsultedActivity({
143370
143505
  threadId: input.threadId,
@@ -143382,6 +143517,13 @@ const make$8 = Effect.gen(function* () {
143382
143517
  stage: "owner",
143383
143518
  result: roleRouteResult(roleRoute.route)
143384
143519
  });
143520
+ if (liveSurface !== void 0) yield* appendJevConsultedActivity({
143521
+ threadId: input.threadId,
143522
+ turnId: null,
143523
+ createdAt: input.createdAt,
143524
+ feature: "live-surface",
143525
+ summary: liveSurfaceSummary(liveSurface)
143526
+ });
143385
143527
  return {
143386
143528
  threadId: input.threadId,
143387
143529
  ...isChatProject(thread.projectId) && activeSession?.provider === "opencode" ? { systemPrompt: P4_CHAT_SYSTEM_PROMPT } : {},
@@ -143391,7 +143533,8 @@ const make$8 = Effect.gen(function* () {
143391
143533
  ...input.interactionMode !== void 0 ? { interactionMode: input.interactionMode } : {},
143392
143534
  compressMode,
143393
143535
  unpromptedSubagents: thread.unpromptedSubagents,
143394
- ...optimizedFusionPromptDelivery && fusionRole !== void 0 ? { fusionRole } : {}
143536
+ ...optimizedFusionPromptDelivery && fusionRole !== void 0 ? { fusionRole } : {},
143537
+ ...liveSurface !== void 0 && liveSurface !== "computer" ? { computerUseGuidance: false } : {}
143395
143538
  };
143396
143539
  });
143397
143540
  const maybeGenerateAndRenameWorktreeBranchForFirstTurn = Effect.fn("maybeGenerateAndRenameWorktreeBranchForFirstTurn")(function* (input) {
@@ -144605,7 +144748,29 @@ const make$5 = Effect.gen(function* () {
144605
144748
  cause
144606
144749
  })))), Effect.catchCause(() => Effect.succeed(void 0)));
144607
144750
  });
144608
- return { hintFor };
144751
+ const surfaceFor = (request) => Effect.gen(function* () {
144752
+ if (hasDirectCapabilityCall(request)) return void 0;
144753
+ const settings = yield* serverSettings.getSettings.pipe(Effect.catchCause(() => Effect.succeed(void 0)));
144754
+ if (!settings?.enableJevPrefetch) return void 0;
144755
+ const state = buildPrefetchState(request);
144756
+ if (state.length === 0) return void 0;
144757
+ const key = yield* secrets.read("typesafe");
144758
+ if (Option.isNone(key)) return void 0;
144759
+ const startedAt = yield* Clock.currentTimeMillis;
144760
+ return yield* jev.ask({
144761
+ apiKey: key.value.apiKey,
144762
+ model: JEV_PREFETCH_MODEL,
144763
+ state,
144764
+ question: LIVE_SURFACE_QUESTION
144765
+ }).pipe(Effect.map((answer) => readLiveSurface(answer)), Effect.timeout(settings.jevPrefetchTimeoutMs), Effect.tapCause((cause) => Clock.currentTimeMillis.pipe(Effect.flatMap((finishedAt) => Effect.logWarning("jev live surface did not answer", {
144766
+ elapsedMs: finishedAt - startedAt,
144767
+ cause
144768
+ })))), Effect.catchCause(() => Effect.succeed(void 0)));
144769
+ });
144770
+ return {
144771
+ hintFor,
144772
+ surfaceFor
144773
+ };
144609
144774
  });
144610
144775
  const JevToolPrefetchLive = Layer.effect(JevToolPrefetch, make$5);
144611
144776
  //#endregion
@@ -145451,9 +145616,8 @@ const reviewCommandId = (pairId, sequence) => CommandId.make(`server:fusion:${pa
145451
145616
  const cursorCommandId = (pairId, sequence) => CommandId.make(`server:fusion:${pairId}:cursor:${sequence}`);
145452
145617
  const triageCommandId = (pairId, sequence) => CommandId.make(`server:fusion:${pairId}:triage:${sequence}`);
145453
145618
  const reviewMessageId = (pairId, sequence) => MessageId.make(`${FUSION_REVIEW_MESSAGE_ID_PREFIX}${pairId}:${sequence}`);
145454
- const EVIDENCE_REPORT_REPAIR_MESSAGE_ID_PREFIX = "fusion-evidence-report-repair:";
145455
145619
  const evidenceReportRepairCommandId = (pairId, sequence) => CommandId.make(`server:fusion:${pairId}:evidence-report-repair:${sequence}`);
145456
- const evidenceReportRepairMessageId = (pairId, sequence) => MessageId.make(`${EVIDENCE_REPORT_REPAIR_MESSAGE_ID_PREFIX}${pairId}:${sequence}`);
145620
+ const evidenceReportRepairMessageId = (pairId, sequence) => MessageId.make(`${FUSION_EVIDENCE_REPORT_REPAIR_MESSAGE_ID_PREFIX}${pairId}:${sequence}`);
145457
145621
  const gateCommandId = (pairId, gateId, suffix) => CommandId.make(`server:fusion:${pairId}:gate:${gateId}:${suffix}`);
145458
145622
  const gateMessageId = (gateId, round) => MessageId.make(`${FUSION_GATE_MESSAGE_ID_PREFIX}${gateId}:wake:${round}`);
145459
145623
  const gateActivityId = (gateId, threadId, suffix) => EventId.make(`fusion-gate:${gateId}:${suffix}:${threadId}`);
@@ -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{$a as i,$u as a,Ba as o,Cl as s,Cn as c,Dt as l,Eu as ee,Ga as te,Kl as u,Kr as ne,La as d,Qa as f,Qr as re,Sl as p,Vr as m,Wa as h,Xa as ie,Za as g,_t as _,b as v,bu as ae,ct as y,eo as b,gt as x,h as S,hu as C,lu as w,vn as oe,wl as T,xl as E,yt as D}from"./previewAssetResource-CscIFHNv.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 le}from"./toggle-group-C8xCVvsa.js";import{A as ue,Fr as de,J as fe,Lr as pe,M as N,Mr as me,Nr as he,Rr as ge,Y as _e,_ as ve,ar as ye,cr as be,ct as xe,dr as Se,dt as Ce,ft as P,h as we,ir as Te,j as Ee,jr as De,k as Oe,lr as ke,lt as Ae,nr as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rr as Ie,si as Le,sr as Re,st as ze,ut as Be,yr as Ve}from"./index-DYICyvf7.js";import{a as He,n as Ue}from"./fileCommentAnnotations-BRlauqkZ.js";var We=T(`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}y.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Se(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:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,ee=m(Qe),te=m(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let d=m(u),[f,p]=(0,F.useState)(null),[h,ie]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==d||t[7]!==r){let e;t[9]!==h||t[10]!==d||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=d.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(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:ze(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=d,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=d,t[7]=r,t[8]=v}else v=t[8];let ae=v,y;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(y=e=>{p(null),h?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),o=h?_.get(h.fileKey):void 0;if(!n||!o)return;let s=ne({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&ee(a,s),p(null),ie(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=x):x=t[23];let S=x,C;t[24]!==_||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let o=Ue(),s=ne({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=C):C=t[27];let w=C,oe=h!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let D=!oe,se=!oe,k;t[32]!==w||t[33]!==o||t[34]!==se||t[35]!==D?(k={...o,enableGutterUtility:D,enableLineSelection:se,onLineSelectionEnd:w},t[32]=w,t[33]=o,t[34]=se,t[35]=D,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==b||t[40]!==S?(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:()=>b(e.id),onComment:t=>S(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=S,t[41]=j):j=t[41];let M;return t[42]!==ae||t[43]!==f||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(O,{...T,...E,items:ae,selectedLines:f,onSelectedLinesChange:p,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ae,t[43]=f,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,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:w(e,{label:`environment-data:review:diff-preview`,tag:a.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(c);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=`
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{$a as i,$u as a,Ba as o,Cl as s,Cn as c,Dt as l,Eu as ee,Ga as te,Kl as u,Kr as ne,La as d,Qa as f,Qr as re,Sl as p,Vr as m,Wa as h,Xa as ie,Za as g,_t as _,b as v,bu as ae,ct as y,eo as b,gt as x,h as S,hu as C,lu as w,vn as oe,wl as T,xl as E,yt as D}from"./previewAssetResource-TczRnj5K.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 le}from"./toggle-group-Cl99Hffz.js";import{A as ue,Fr as de,J as fe,Lr as pe,M as N,Mr as me,Nr as he,Rr as ge,Y as _e,_ as ve,ar as ye,cr as be,ct as xe,dr as Se,dt as Ce,ft as P,h as we,ir as Te,j as Ee,jr as De,k as Oe,lr as ke,lt as Ae,nr as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rr as Ie,si as Le,sr as Re,st as ze,ut as Be,yr as Ve}from"./index-r03Q2lJJ.js";import{a as He,n as Ue}from"./fileCommentAnnotations-3ySgIWip.js";var We=T(`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}y.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Se(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:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,ee=m(Qe),te=m(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let d=m(u),[f,p]=(0,F.useState)(null),[h,ie]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==d||t[7]!==r){let e;t[9]!==h||t[10]!==d||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=d.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(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:ze(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=d,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=d,t[7]=r,t[8]=v}else v=t[8];let ae=v,y;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(y=e=>{p(null),h?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),o=h?_.get(h.fileKey):void 0;if(!n||!o)return;let s=ne({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&ee(a,s),p(null),ie(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=x):x=t[23];let S=x,C;t[24]!==_||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let o=Ue(),s=ne({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=C):C=t[27];let w=C,oe=h!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let D=!oe,se=!oe,k;t[32]!==w||t[33]!==o||t[34]!==se||t[35]!==D?(k={...o,enableGutterUtility:D,enableLineSelection:se,onLineSelectionEnd:w},t[32]=w,t[33]=o,t[34]=se,t[35]=D,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==b||t[40]!==S?(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:()=>b(e.id),onComment:t=>S(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=S,t[41]=j):j=t[41];let M;return t[42]!==ae||t[43]!==f||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(O,{...T,...E,items:ae,selectedLines:f,onSelectedLinesChange:p,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ae,t[43]=f,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,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:w(e,{label:`environment-data:review:diff-preview`,tag:a.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(c);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],
@@ -95,4 +95,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
95
95
  text-decoration-color: currentColor;
96
96
  }
97
97
  `;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:a}=v(),c=de(),[ne]=(0,F.useState)(n),[re,m]=(0,F.useState)(`stacked`),[y,S]=(0,F.useState)(c.wordWrap),[w,T]=(0,F.useState)(c.diffIgnoreWhitespace),[O,ve]=(0,F.useState)(``),[Se,ze]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=he(r),qe=I?.projectId??null,Je=me(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=u(oe.configValueAtom(I?.environmentId??null)),Xe=Fe(I?.environmentId??null,z?.availableEditors??[]),Ze=l(I!=null&&R!=null?De.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=N(e=>Ee(e.byThreadKey,r,ne===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=ue(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`&&N.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=Se.scopeKey===Y?Se.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:w,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=l(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:w}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=l(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:w}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=l(W===null&&G===`branch`&&I&&X.data?.cwd?De.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),vt=l(W===null&&G===`branch`&&I&&X.data?.cwd?De.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)(()=>Be(Tt,`diff-panel:${a}`,{compactPartialHunkOffsets:W===null}),[a,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>P(e).localeCompare(P(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Pe(e);return{fileDiff:e,filePath:P(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)(()=>Ae(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=Oe({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`&&!C(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ee(ae(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{ze(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)(()=>{ze(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{N.getState().selectTurn(r,e)},zt=e=>{N.getState().selectGitScope(r,e)},Bt=e=>{N.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(_e,{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)(o,{children:[(0,L.jsxs)(i,{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)(p,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(te,{align:`start`,className:`w-60`,children:[(0,L.jsx)(h,{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)(h,{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)(h,{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)(ie,{children:[(0,L.jsx)(f,{children:`Turn`}),(0,L.jsx)(g,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(h,{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)(je,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||ve(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(be,{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)(p,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Re,{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)(ge,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Te,{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=>ve(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)(Ie,{children:`No matching refs.`}),(0,L.jsxs)(Ne,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(ye,{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)(ye,{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)(ke,{"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)(s,{"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)(we,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(x,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(d,{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)(_,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[re],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&m(t)},children:[(0,L.jsx)(le,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(le,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(x,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(le,{"aria-label":y?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:y,onPressedChange:e=>{S(!!e)}}),children:(0,L.jsx)(pe,{className:`size-3`})}),(0,L.jsx)(_,{side:`top`,children:y?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(x,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(le,{"aria-label":w?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:w,onPressedChange:e=>{T(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(_,{side:`top`,children:w?`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=P(e);return(0,L.jsxs)(x,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(`button`,{type:`button`,className:b(`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)(E,{className:`size-4`}):(0,L.jsx)(p,{className:`size-4`})}),(0,L.jsx)(_,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:re===`split`?`split`:`unified`,lineDiffType:`none`,overflow:y?`wrap`:`scroll`,theme:Ce(a),themeType:a,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:b(`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{ve as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-Cq5Tpiyo.js.map
98
+ //# sourceMappingURL=DiffPanel-CoqdrH1m.js.map