@p4code/cli 0.4.17 → 0.4.18

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
@@ -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.17";
263
+ var version$1 = "0.4.18";
264
264
  //#endregion
265
265
  //#region src/config.ts
266
266
  /**
@@ -1549,6 +1549,7 @@ const ServerSelfUpdateCapability = Schema$1.Literals([
1549
1549
  "desktop-managed"
1550
1550
  ]);
1551
1551
  const ExecutionEnvironmentCapabilities = Schema$1.Struct({
1552
+ computerUseControls: Schema$1.optionalKey(Schema$1.Boolean),
1552
1553
  usagePriceOverrides: Schema$1.optionalKey(Schema$1.Boolean),
1553
1554
  projectAutoPull: Schema$1.optionalKey(Schema$1.Boolean),
1554
1555
  sharedProjectModelDefault: Schema$1.optionalKey(Schema$1.Boolean),
@@ -9794,6 +9795,11 @@ const LoadBalancingWeights = Schema$1.Record(TrimmedNonEmptyString, Schema$1.Int
9794
9795
  minimum: 0,
9795
9796
  maximum: 100
9796
9797
  })));
9798
+ const ComputerUsePermissionHosts = Schema$1.Record(TrimmedNonEmptyString, Schema$1.Struct({
9799
+ environmentId: TrimmedNonEmptyString,
9800
+ hostId: TrimmedNonEmptyString,
9801
+ label: Schema$1.optionalKey(TrimmedNonEmptyString)
9802
+ }));
9797
9803
  const ClientSettingsSchema = Schema$1.Struct({
9798
9804
  loadBalancingEnabled: Schema$1.Boolean.pipe(Schema$1.withDecodingDefault(Effect.succeed(false))),
9799
9805
  loadBalancingWeights: LoadBalancingWeights.pipe(Schema$1.withDecodingDefault(Effect.succeed({}))),
@@ -9805,6 +9811,7 @@ const ClientSettingsSchema = Schema$1.Struct({
9805
9811
  confirmThreadDelete: Schema$1.Boolean.pipe(Schema$1.withDecodingDefault(Effect.succeed(true))),
9806
9812
  dismissedProviderUpdateNotificationKeys: Schema$1.Array(TrimmedNonEmptyString).pipe(Schema$1.withDecodingDefault(Effect.succeed([]))),
9807
9813
  diffIgnoreWhitespace: Schema$1.Boolean.pipe(Schema$1.withDecodingDefault(Effect.succeed(true))),
9814
+ computerUsePermissionHosts: ComputerUsePermissionHosts.pipe(Schema$1.withDecodingDefault(Effect.succeed({}))),
9808
9815
  environmentIdentificationMode: EnvironmentIdentificationMode.pipe(Schema$1.withDecodingDefault(Effect.succeed(DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE))),
9809
9816
  glassOpacity: GlassOpacity.pipe(Schema$1.withDecodingDefault(Effect.succeed(80))),
9810
9817
  favorites: Schema$1.Array(Schema$1.Struct({
@@ -10389,6 +10396,7 @@ Schema$1.Struct({
10389
10396
  confirmThreadArchive: Schema$1.optionalKey(Schema$1.Boolean),
10390
10397
  confirmThreadDelete: Schema$1.optionalKey(Schema$1.Boolean),
10391
10398
  diffIgnoreWhitespace: Schema$1.optionalKey(Schema$1.Boolean),
10399
+ computerUsePermissionHosts: Schema$1.optionalKey(ComputerUsePermissionHosts),
10392
10400
  environmentIdentificationMode: Schema$1.optionalKey(EnvironmentIdentificationMode),
10393
10401
  glassOpacity: Schema$1.optionalKey(GlassOpacity),
10394
10402
  favorites: Schema$1.optionalKey(Schema$1.Array(Schema$1.Struct({
@@ -13338,6 +13346,9 @@ const ComputerUseHost = Schema$1.Struct({
13338
13346
  nativeApps: Schema$1.Boolean
13339
13347
  });
13340
13348
  const ComputerUseSession = Schema$1.Struct({
13349
+ generationId: Schema$1.optional(TrimmedNonEmptyString),
13350
+ threadTitle: Schema$1.optional(Schema$1.String),
13351
+ environmentLabel: Schema$1.optional(Schema$1.String),
13341
13352
  environmentId: EnvironmentId,
13342
13353
  threadId: ThreadId,
13343
13354
  providerSessionId: TrimmedNonEmptyString,
@@ -13364,7 +13375,9 @@ const ComputerUseHostRequest = Schema$1.Struct({
13364
13375
  operation: Schema$1.Literals([
13365
13376
  "js",
13366
13377
  "js_reset",
13367
- "close"
13378
+ "close",
13379
+ "stop",
13380
+ "resume"
13368
13381
  ]),
13369
13382
  input: Schema$1.optional(ComputerUseJsInput)
13370
13383
  });
@@ -13376,10 +13389,15 @@ var ComputerUseError = class extends Schema$1.TaggedErrorClass()("ComputerUseErr
13376
13389
  "busy",
13377
13390
  "timeout",
13378
13391
  "reset",
13379
- "execution-failed"
13392
+ "execution-failed",
13393
+ "stopped"
13380
13394
  ]),
13381
13395
  detail: Schema$1.String
13382
- }) {};
13396
+ }) {
13397
+ get message() {
13398
+ return this.detail;
13399
+ }
13400
+ };
13383
13401
  const ComputerUseHostRegistration = Schema$1.Struct({
13384
13402
  hostId: TrimmedNonEmptyString,
13385
13403
  environmentId: EnvironmentId,
@@ -13406,6 +13424,30 @@ const ComputerUseHostResponse = Schema$1.Struct({
13406
13424
  error: ComputerUseError
13407
13425
  })])
13408
13426
  });
13427
+ const ComputerUseHostReport = Schema$1.Struct({
13428
+ hostId: TrimmedNonEmptyString,
13429
+ connectionId: TrimmedNonEmptyString,
13430
+ session: ComputerUseSession,
13431
+ state: Schema$1.Literals([
13432
+ "active",
13433
+ "closed",
13434
+ "stopped"
13435
+ ])
13436
+ });
13437
+ const ComputerUseControlState = Schema$1.Struct({
13438
+ session: ComputerUseSession,
13439
+ host: ComputerUseHost,
13440
+ state: Schema$1.Literals([
13441
+ "active",
13442
+ "stopping",
13443
+ "stopped",
13444
+ "stop-unconfirmed"
13445
+ ])
13446
+ });
13447
+ const ComputerUseControlInput = Schema$1.Struct({
13448
+ threadId: ThreadId,
13449
+ action: Schema$1.Literals(["stop", "resume"])
13450
+ });
13409
13451
  const ComputerUseEnrollmentRequest = Schema$1.Struct({
13410
13452
  environmentId: EnvironmentId,
13411
13453
  desktopSessionId: TrimmedNonEmptyString,
@@ -13465,6 +13507,8 @@ const WS_METHODS = {
13465
13507
  previewReportStatus: "preview.reportStatus",
13466
13508
  computerUseConnect: "computerUse.connect",
13467
13509
  computerUseList: "computerUse.list",
13510
+ computerUseControls: "computerUse.controls",
13511
+ computerUseControl: "computerUse.control",
13468
13512
  computerUseRespond: "computerUse.respond",
13469
13513
  previewAutomationConnect: "previewAutomation.connect",
13470
13514
  previewAutomationRespond: "previewAutomation.respond",
@@ -14488,6 +14532,16 @@ const WsComputerUseListRpc = Rpc.make(WS_METHODS.computerUseList, {
14488
14532
  success: Schema$1.Array(ComputerUseHost),
14489
14533
  error: EnvironmentAuthorizationError
14490
14534
  });
14535
+ const WsComputerUseControlsRpc = Rpc.make(WS_METHODS.computerUseControls, {
14536
+ payload: Schema$1.Struct({}),
14537
+ success: Schema$1.Array(ComputerUseControlState),
14538
+ error: EnvironmentAuthorizationError,
14539
+ stream: true
14540
+ });
14541
+ const WsComputerUseControlRpc = Rpc.make(WS_METHODS.computerUseControl, {
14542
+ payload: ComputerUseControlInput,
14543
+ error: Schema$1.Union([ComputerUseError, EnvironmentAuthorizationError])
14544
+ });
14491
14545
  const WsComputerUseRespondRpc = Rpc.make(WS_METHODS.computerUseRespond, {
14492
14546
  payload: ComputerUseHostResponse,
14493
14547
  error: Schema$1.Union([ComputerUseError, EnvironmentAuthorizationError])
@@ -14594,7 +14648,7 @@ const WsSubscribeAuthAccessRpc = Rpc.make(WS_METHODS.subscribeAuthAccess, {
14594
14648
  error: Schema$1.Union([AuthAccessStreamError, EnvironmentAuthorizationError]),
14595
14649
  stream: true
14596
14650
  });
14597
- const WsRpcGroup = RpcGroup.make(WsDeviceGetStateRpc, WsDeviceListRpc, WsDeviceConfigureRpc, WsDeviceOpenRpc, WsDeviceCloseRpc, WsDeviceDetailRpc, WsDeviceActionRpc, WsSubscribeDevicesRpc, WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerProviderAuthStartRpc, WsServerProviderAuthCompleteRpc, WsServerProviderAuthCancelRpc, WsServerProviderAuthLogoutRpc, WsServerProviderAuthSubscribeRpc, WsServerProviderInstallStartRpc, WsServerProviderInstallCancelRpc, WsServerProviderInstallRemoveRpc, WsServerProviderInstallSubscribeRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetProviderUsageRpc, WsServerGetHostResourcesRpc, WsServerGetResourceTelemetryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsSubscribeResourceTelemetryRpc, WsBtwAskRpc, WsBtwCancelRpc, WsServerGetUsageSummaryRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerSignalProcessRpc, WsPullRequestsListRpc, WsPullRequestsListStatsRpc, WsPullRequestsDetailRpc, WsPullRequestsStackRpc, WsPullRequestsActivityRpc, WsPullRequestsDiffFileContentsRpc, WsPullRequestsRunActionRpc, WsPullRequestsUpdateRpc, WsPullRequestsCommentRpc, WsPullRequestsUpdateCommentRpc, WsPullRequestsSubmitReviewRpc, WsPullRequestsReplyToThreadRpc, WsPullRequestsSetThreadResolutionRpc, WsPullRequestsSetReactionRpc, WsPullRequestsInvalidateRpc, WsPullRequestsReviewerCandidatesRpc, WsPullRequestsRequestReviewersRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, WsSubscribeTerminalEventsRpc, WsSubscribeTerminalMetadataRpc, WsPreviewOpenRpc, WsPreviewNavigateRpc, WsPreviewResizeRpc, WsPreviewRefreshRpc, WsPreviewCloseRpc, WsPreviewListRpc, WsPreviewReportStatusRpc, WsComputerUseConnectRpc, WsComputerUseListRpc, WsComputerUseRespondRpc, WsPreviewAutomationConnectRpc, WsPreviewAutomationRespondRpc, WsPreviewAutomationFocusHostRpc, WsSubscribePreviewEventsRpc, WsSubscribeDiscoveredLocalServersRpc, WsSubscribeServerConfigRpc, WsSubscribeServerLifecycleRpc, WsSubscribeAuthAccessRpc, WsTasksListRpc, WsTasksGetRpc, WsTasksCreateRpc, WsTasksUpdateRpc, WsTasksDeleteRpc, WsTasksStartThreadRpc, WsFeedListRpc, WsFeedRefreshRpc, WsFeedSourcesListRpc, WsFeedSourcesUpsertRpc, WsFeedSourcesDeleteRpc, WsFeedMarkReadRpc, WsFeedCleanupRpc, WsSubscribeTasksRpc, WsHubGetSyncStatusRpc, WsHubConnectRpc, WsHubDisconnectRpc, WsHubSetSyncModeRpc, WsHubSetShareModeRpc, WsHubMintTokenRpc, WsSkillsSyncRpc, WsSkillsPublishRpc, WsSkillsPublishAllRpc, WsSkillsUnpublishRpc, WsAssetsReadRpc, WsAssetsSaveRpc, WsAssetsDeleteRpc, WsAssetsCreateLocalRpc, WsAssetsRemoveLocalRpc, WsSkillRegistrySearchRpc, WsSkillRegistryFetchRpc, WsMcpListRpc, WsMcpSaveRpc, WsMcpRemoveRpc, WsMcpSetSecretRpc, WsMcpOAuthBeginRpc, WsMcpOAuthDisconnectRpc, WsTrackerStatusRpc, WsTrackerSetApiKeyRpc, WsTrackerClearApiKeyRpc, WsOrchestrationDispatchCommandRpc, WsOrchestrationGetTurnDiffRpc, WsOrchestrationGetWorkflowScriptRpc, WsOrchestrationGetFullThreadDiffRpc, WsOrchestrationSearchThreadsRpc, WsOrchestrationGetArchivedShellSnapshotRpc, WsOrchestrationSubscribeShellRpc, WsOrchestrationSubscribeThreadRpc);
14651
+ const WsRpcGroup = RpcGroup.make(WsDeviceGetStateRpc, WsDeviceListRpc, WsDeviceConfigureRpc, WsDeviceOpenRpc, WsDeviceCloseRpc, WsDeviceDetailRpc, WsDeviceActionRpc, WsSubscribeDevicesRpc, WsServerProbeRpc, WsServerGetConfigRpc, WsServerRefreshProvidersRpc, WsServerProviderAuthStartRpc, WsServerProviderAuthCompleteRpc, WsServerProviderAuthCancelRpc, WsServerProviderAuthLogoutRpc, WsServerProviderAuthSubscribeRpc, WsServerProviderInstallStartRpc, WsServerProviderInstallCancelRpc, WsServerProviderInstallRemoveRpc, WsServerProviderInstallSubscribeRpc, WsServerUpdateProviderRpc, WsServerUpdateServerRpc, WsServerUpsertKeybindingRpc, WsServerRemoveKeybindingRpc, WsServerGetSettingsRpc, WsServerUpdateSettingsRpc, WsServerDiscoverSourceControlRpc, WsServerGetProviderUsageRpc, WsServerGetHostResourcesRpc, WsServerGetResourceTelemetryRpc, WsServerGetResourceTelemetryHistoryRpc, WsServerRetryResourceTelemetryRpc, WsSubscribeResourceTelemetryRpc, WsBtwAskRpc, WsBtwCancelRpc, WsServerGetUsageSummaryRpc, WsServerGetTraceDiagnosticsRpc, WsServerGetProcessDiagnosticsRpc, WsServerGetProcessResourceHistoryRpc, WsServerSignalProcessRpc, WsPullRequestsListRpc, WsPullRequestsListStatsRpc, WsPullRequestsDetailRpc, WsPullRequestsStackRpc, WsPullRequestsActivityRpc, WsPullRequestsDiffFileContentsRpc, WsPullRequestsRunActionRpc, WsPullRequestsUpdateRpc, WsPullRequestsCommentRpc, WsPullRequestsUpdateCommentRpc, WsPullRequestsSubmitReviewRpc, WsPullRequestsReplyToThreadRpc, WsPullRequestsSetThreadResolutionRpc, WsPullRequestsSetReactionRpc, WsPullRequestsInvalidateRpc, WsPullRequestsReviewerCandidatesRpc, WsPullRequestsRequestReviewersRpc, WsSourceControlLookupRepositoryRpc, WsSourceControlCloneRepositoryRpc, WsSourceControlPublishRepositoryRpc, WsProjectsListEntriesRpc, WsProjectsReadFileRpc, WsProjectsSearchContentsRpc, WsProjectsSearchEntriesRpc, WsProjectsWriteFileRpc, WsShellOpenInEditorRpc, WsFilesystemBrowseRpc, WsAssetsCreateUrlRpc, WsSubscribeVcsStatusRpc, WsVcsPullRpc, WsVcsRefreshStatusRpc, WsGitRunStackedActionRpc, WsGitResolvePullRequestRpc, WsGitPreparePullRequestThreadRpc, WsVcsListRefsRpc, WsVcsCreateWorktreeRpc, WsVcsRemoveWorktreeRpc, WsVcsCreateRefRpc, WsVcsSwitchRefRpc, WsVcsInitRpc, WsReviewGetDiffPreviewRpc, WsTerminalOpenRpc, WsTerminalAttachRpc, WsTerminalWriteRpc, WsTerminalResizeRpc, WsTerminalClearRpc, WsTerminalRestartRpc, WsTerminalCloseRpc, WsSubscribeTerminalEventsRpc, WsSubscribeTerminalMetadataRpc, WsPreviewOpenRpc, WsPreviewNavigateRpc, WsPreviewResizeRpc, WsPreviewRefreshRpc, WsPreviewCloseRpc, WsPreviewListRpc, WsPreviewReportStatusRpc, WsComputerUseConnectRpc, WsComputerUseListRpc, WsComputerUseControlsRpc, WsComputerUseControlRpc, WsComputerUseRespondRpc, WsPreviewAutomationConnectRpc, WsPreviewAutomationRespondRpc, WsPreviewAutomationFocusHostRpc, WsSubscribePreviewEventsRpc, WsSubscribeDiscoveredLocalServersRpc, WsSubscribeServerConfigRpc, WsSubscribeServerLifecycleRpc, WsSubscribeAuthAccessRpc, WsTasksListRpc, WsTasksGetRpc, WsTasksCreateRpc, WsTasksUpdateRpc, WsTasksDeleteRpc, WsTasksStartThreadRpc, WsFeedListRpc, WsFeedRefreshRpc, WsFeedSourcesListRpc, WsFeedSourcesUpsertRpc, WsFeedSourcesDeleteRpc, WsFeedMarkReadRpc, WsFeedCleanupRpc, WsSubscribeTasksRpc, WsHubGetSyncStatusRpc, WsHubConnectRpc, WsHubDisconnectRpc, WsHubSetSyncModeRpc, WsHubSetShareModeRpc, WsHubMintTokenRpc, WsSkillsSyncRpc, WsSkillsPublishRpc, WsSkillsPublishAllRpc, WsSkillsUnpublishRpc, WsAssetsReadRpc, WsAssetsSaveRpc, WsAssetsDeleteRpc, WsAssetsCreateLocalRpc, WsAssetsRemoveLocalRpc, WsSkillRegistrySearchRpc, WsSkillRegistryFetchRpc, WsMcpListRpc, WsMcpSaveRpc, WsMcpRemoveRpc, WsMcpSetSecretRpc, WsMcpOAuthBeginRpc, WsMcpOAuthDisconnectRpc, WsTrackerStatusRpc, WsTrackerSetApiKeyRpc, WsTrackerClearApiKeyRpc, WsOrchestrationDispatchCommandRpc, WsOrchestrationGetTurnDiffRpc, WsOrchestrationGetWorkflowScriptRpc, WsOrchestrationGetFullThreadDiffRpc, WsOrchestrationSearchThreadsRpc, WsOrchestrationGetArchivedShellSnapshotRpc, WsOrchestrationSubscribeShellRpc, WsOrchestrationSubscribeThreadRpc);
14598
14652
  //#endregion
14599
14653
  //#region ../../packages/contracts/src/deviceCommand.ts
14600
14654
  const MAX_COORDINATE = 32768;
@@ -44553,6 +44607,7 @@ const make$88 = Effect.gen(function* () {
44553
44607
  connectionProbe: true,
44554
44608
  pullRequests: true,
44555
44609
  hostResources: true,
44610
+ computerUseControls: true,
44556
44611
  deviceSessionLeases: true,
44557
44612
  deviceActionLeases: true,
44558
44613
  pullRequestStackActions: true,
@@ -53049,6 +53104,7 @@ const COMPUTER_USE_HELPER_CREDENTIAL_TTL_MS = 300 * 1e3;
53049
53104
  const HELPER_CREDENTIAL_BYTES = 32;
53050
53105
  const MAX_PENDING_REQUESTS = 64;
53051
53106
  const TRANSPORT_GRACE_MS = 2e3;
53107
+ const COMPUTER_USE_CONTROL_ACK_TIMEOUT_MS = 5e3;
53052
53108
  const scopeKey = (scope) => JSON.stringify([
53053
53109
  scope.environmentId,
53054
53110
  scope.threadId,
@@ -53058,14 +53114,26 @@ const scopeKey = (scope) => JSON.stringify([
53058
53114
  const hostSession = (scope) => ({
53059
53115
  environmentId: scope.environmentId,
53060
53116
  threadId: scope.threadId,
53117
+ ...scope.threadTitle ? { threadTitle: scope.threadTitle } : {},
53061
53118
  providerInstanceId: scope.providerInstanceId,
53062
53119
  providerSessionId: scope.providerSessionId
53063
53120
  });
53064
53121
  var ComputerUseBroker = class extends Context.Service()("@p4code/cli/mcp/ComputerUseBroker") {};
53065
53122
  const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53123
+ const serviceScope = yield* Scope.Scope;
53066
53124
  const crypto = yield* Crypto.Crypto;
53067
- const environmentId = yield* (yield* ServerEnvironment).getEnvironmentId;
53125
+ const environment = yield* ServerEnvironment;
53126
+ const environmentId = yield* environment.getEnvironmentId;
53068
53127
  const admission = yield* Semaphore.make(1);
53128
+ const controlAdmission = yield* Semaphore.make(1);
53129
+ const states = /* @__PURE__ */ new Map();
53130
+ const stoppedThreads = /* @__PURE__ */ new Set();
53131
+ const controls = yield* SubscriptionRef.make([]);
53132
+ const publish = () => SubscriptionRef.set(controls, [...states.values()]);
53133
+ const stopped = () => new ComputerUseError({
53134
+ reason: "stopped",
53135
+ detail: "Computer Use was stopped by the user. Ask the user to allow Computer Use again before retrying. Resetting cannot restore access."
53136
+ });
53069
53137
  const connections = /* @__PURE__ */ new Map();
53070
53138
  const helperCredentials = /* @__PURE__ */ new Map();
53071
53139
  const leases = /* @__PURE__ */ new Map();
@@ -53084,6 +53152,15 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53084
53152
  detail: "Computer Use host disconnected. Reset before selecting another host."
53085
53153
  }));
53086
53154
  }
53155
+ for (const [key, state] of states) {
53156
+ if (state.host.connectionId !== connection.host.connectionId) continue;
53157
+ if (state.state === "active") states.delete(key);
53158
+ else if (state.state === "stopping") states.set(key, {
53159
+ ...state,
53160
+ state: "stop-unconfirmed"
53161
+ });
53162
+ }
53163
+ yield* publish();
53087
53164
  yield* Queue.shutdown(connection.queue);
53088
53165
  });
53089
53166
  const revokeHelper = Effect.fn("ComputerUseBroker.revokeHelper")(function* (credential) {
@@ -53143,12 +53220,119 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53143
53220
  requestId,
53144
53221
  hostId: connection.host.hostId,
53145
53222
  connectionId: connection.host.connectionId,
53146
- session: hostSession(scope),
53223
+ session: states.get(key)?.session ?? hostSession(scope),
53147
53224
  operation: "close"
53148
53225
  }
53149
53226
  });
53150
53227
  }
53151
53228
  }, admission.withPermits(1));
53229
+ const stopThread = Effect.fn("ComputerUseBroker.stopThread")(function* (threadId) {
53230
+ stoppedThreads.add(threadId);
53231
+ for (const [key, state] of states) {
53232
+ if (state.session.threadId !== threadId) continue;
53233
+ if (state.state !== "stopped") states.set(key, {
53234
+ ...state,
53235
+ state: "stopping"
53236
+ });
53237
+ leases.delete(key);
53238
+ for (const [id, request] of pending) {
53239
+ if (request.scopeKey !== key) continue;
53240
+ pending.delete(id);
53241
+ yield* Deferred.fail(request.completion, stopped());
53242
+ }
53243
+ }
53244
+ yield* publish();
53245
+ });
53246
+ const sendControl = Effect.fn("ComputerUseBroker.sendControl")(function* (state, action) {
53247
+ const connection = connections.get(state.host.hostId);
53248
+ if (!connection || action === "stop" && connection.host.connectionId !== state.host.connectionId) {
53249
+ if (action === "resume") return yield* new ComputerUseError({
53250
+ reason: "disconnected",
53251
+ detail: "Reconnect this Mac before allowing Computer Use again. Access remains blocked."
53252
+ });
53253
+ if (state.state === "stopped") return;
53254
+ for (const [key, entry] of states) if (entry.session.threadId === state.session.threadId && entry.host.connectionId === state.host.connectionId) states.set(key, {
53255
+ ...entry,
53256
+ state: "stop-unconfirmed"
53257
+ });
53258
+ yield* publish();
53259
+ return yield* new ComputerUseError({
53260
+ reason: "disconnected",
53261
+ detail: "Computer Use host is unreachable. Access is blocked, but the Mac has not confirmed Stop."
53262
+ });
53263
+ }
53264
+ const requestId = yield* crypto.randomUUIDv4.pipe(Effect.orDie);
53265
+ const completion = yield* Deferred.make();
53266
+ pending.set(requestId, {
53267
+ connection,
53268
+ completion,
53269
+ scopeKey: requestId
53270
+ });
53271
+ yield* Effect.gen(function* () {
53272
+ yield* Queue.offer(connection.queue, {
53273
+ type: "request",
53274
+ request: {
53275
+ requestId,
53276
+ hostId: connection.host.hostId,
53277
+ connectionId: connection.host.connectionId,
53278
+ session: state.session,
53279
+ operation: action
53280
+ }
53281
+ });
53282
+ yield* Deferred.await(completion).pipe(Effect.timeout(COMPUTER_USE_CONTROL_ACK_TIMEOUT_MS));
53283
+ }).pipe(Effect.catch(() => disconnect(connection).pipe(Effect.andThen(Effect.fail(new ComputerUseError({
53284
+ reason: "disconnected",
53285
+ detail: "Computer Use host did not confirm the control change. Access remains blocked. Check the Mac before allowing control again."
53286
+ }))))), Effect.ensuring(Effect.sync(() => pending.delete(requestId))));
53287
+ });
53288
+ const report = Effect.fn("ComputerUseBroker.report")(function* (owner, report) {
53289
+ const authorization = yield* authorize(owner);
53290
+ const connection = connections.get(report.hostId);
53291
+ if (!connection || connection.authorization !== authorization || connection.host.connectionId !== report.connectionId || report.session.environmentId !== environmentId) return yield* deny();
53292
+ const key = scopeKey(report.session);
53293
+ const state = states.get(key);
53294
+ if (!state || state.host.connectionId !== report.connectionId || state.session.generationId !== report.session.generationId) return;
53295
+ if (report.state === "stopped") {
53296
+ const others = [...states.values()].filter((entry) => entry.session.threadId === report.session.threadId && entry.state === "active" && entry.host.connectionId !== report.connectionId);
53297
+ yield* stopThread(report.session.threadId);
53298
+ for (const other of new Map(others.map((entry) => [entry.host.connectionId, entry])).values()) yield* sendControl(other, "stop").pipe(Effect.ignore, Effect.forkIn(serviceScope));
53299
+ for (const [entryKey, entry] of states) if (entry.session.threadId === report.session.threadId && entry.host.connectionId === report.connectionId) states.set(entryKey, {
53300
+ ...entry,
53301
+ state: "stopped"
53302
+ });
53303
+ } else if (report.state === "closed") {
53304
+ leases.delete(key);
53305
+ if (state.state === "active") states.delete(key);
53306
+ else states.set(key, {
53307
+ ...state,
53308
+ state: "stopped"
53309
+ });
53310
+ }
53311
+ if (report.state !== "active") yield* publish();
53312
+ }, admission.withPermits(1));
53313
+ const control = Effect.fn("ComputerUseBroker.control")(function* (input) {
53314
+ const targets = yield* admission.withPermits(1)(Effect.gen(function* () {
53315
+ const targets = [...states.values()].filter((state) => state.session.threadId === input.threadId);
53316
+ if (input.action === "stop" && targets.length > 0) yield* stopThread(input.threadId);
53317
+ return targets;
53318
+ }));
53319
+ const hosts = new Map(targets.map((state) => [state.host.connectionId, state]));
53320
+ let failure;
53321
+ yield* Effect.forEach([...hosts.values()], (state) => sendControl(state, input.action).pipe(Effect.catch((error) => Effect.sync(() => {
53322
+ failure = error;
53323
+ }))), { concurrency: "unbounded" });
53324
+ if (failure) return yield* failure;
53325
+ if (input.action === "resume") stoppedThreads.delete(input.threadId);
53326
+ for (const [key, state] of states) {
53327
+ if (state.session.threadId !== input.threadId) continue;
53328
+ if (input.action === "resume") states.delete(key);
53329
+ else states.set(key, {
53330
+ ...state,
53331
+ state: "stopped"
53332
+ });
53333
+ }
53334
+ yield* publish();
53335
+ }, controlAdmission.withPermits(1), Effect.uninterruptible);
53152
53336
  return ComputerUseBroker.of({
53153
53337
  attachVerifiedHelper: (binding) => Effect.gen(function* () {
53154
53338
  if (binding.host.environmentId !== environmentId || !binding.helperIdentity || !binding.desktopSessionId) return yield* deny();
@@ -53210,6 +53394,9 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53210
53394
  expiresAt
53211
53395
  };
53212
53396
  }, admission.withPermits(1)),
53397
+ report,
53398
+ control,
53399
+ controls: SubscriptionRef.changes(controls),
53213
53400
  list: Effect.sync(() => [...connections.values()].map((entry) => entry.host)),
53214
53401
  connect: (owner, host) => authorize(owner).pipe(Effect.as(Stream.unwrap(Effect.acquireRelease(admission.withPermits(1)(acquire(owner, host)), (connection) => revokeHelper(connection.owner)).pipe(Effect.map((connection) => Stream.fromQueue(connection.queue)))))),
53215
53402
  respond: Effect.fn("ComputerUseBroker.respond")(function* (owner, response) {
@@ -53226,6 +53413,7 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53226
53413
  const { requestId, connection, completion, request } = yield* admission.withPermits(1)(Effect.gen(function* () {
53227
53414
  if (scope.authorizationLifetime?.revoked === true || !scope.capabilities.has("computer-use") || scope.environmentId !== environmentId) return yield* deny();
53228
53415
  if (scope.computerUseHostId && hostId !== void 0 && hostId !== scope.computerUseHostId) return yield* deny();
53416
+ if (stoppedThreads.has(scope.threadId)) return yield* stopped();
53229
53417
  const grantedHostId = scope.computerUseHostId ?? hostId;
53230
53418
  const key = scopeKey(scope);
53231
53419
  const existing = leases.get(key);
@@ -53246,6 +53434,20 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53246
53434
  yield* authorize(connection.owner);
53247
53435
  const requestId = yield* crypto.randomUUIDv4.pipe(Effect.orDie);
53248
53436
  const completion = yield* Deferred.make();
53437
+ const descriptor = yield* environment.getDescriptor;
53438
+ const session = existing ? states.get(key)?.session ?? hostSession(scope) : {
53439
+ ...hostSession(scope),
53440
+ environmentLabel: descriptor.label,
53441
+ generationId: requestId
53442
+ };
53443
+ if (!existing) {
53444
+ states.set(key, {
53445
+ session,
53446
+ host: connection.host,
53447
+ state: "active"
53448
+ });
53449
+ yield* publish();
53450
+ }
53249
53451
  leases.set(key, connection);
53250
53452
  pending.set(requestId, {
53251
53453
  connection,
@@ -53260,7 +53462,7 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53260
53462
  requestId,
53261
53463
  hostId: connection.host.hostId,
53262
53464
  connectionId: connection.host.connectionId,
53263
- session: hostSession(scope),
53465
+ session,
53264
53466
  operation: "js",
53265
53467
  input
53266
53468
  }
@@ -53285,7 +53487,7 @@ const layer$67 = Layer.effect(ComputerUseBroker, Effect.gen(function* () {
53285
53487
  pending.delete(requestId);
53286
53488
  })));
53287
53489
  })),
53288
- reset: (scope) => scope.authorizationLifetime?.revoked !== true && scope.environmentId === environmentId && scope.capabilities.has("computer-use") ? revoke(scope) : Effect.fail(deny()),
53490
+ reset: (scope) => scope.authorizationLifetime?.revoked !== true && scope.environmentId === environmentId && scope.capabilities.has("computer-use") ? stoppedThreads.has(scope.threadId) ? Effect.fail(stopped()) : revoke(scope) : Effect.fail(deny()),
53289
53491
  revoke,
53290
53492
  invalidate: (scope) => Effect.sync(() => {
53291
53493
  if (scope.authorizationLifetime) scope.authorizationLifetime.revoked = true;
@@ -53388,6 +53590,14 @@ const respond = HttpRouter.add("POST", "/internal/computer-use/respond", Effect.
53388
53590
  yield* broker.respond(bearer(request), response);
53389
53591
  return HttpServerResponse.empty({ status: 204 });
53390
53592
  }).pipe(Effect.catch(failure$1)));
53593
+ const decodeHostReport = Schema$1.decodeUnknownEffect(ComputerUseHostReport);
53594
+ const report = HttpRouter.add("POST", "/internal/computer-use/report", Effect.gen(function* () {
53595
+ const request = yield* HttpServerRequest.HttpServerRequest;
53596
+ const broker = yield* ComputerUseBroker;
53597
+ const report = yield* decodeHostReport(yield* request.json);
53598
+ yield* broker.report(bearer(request), report);
53599
+ return HttpServerResponse.empty({ status: 204 });
53600
+ }).pipe(Effect.catch(failure$1)));
53391
53601
  const environment = HttpRouter.add("GET", "/internal/computer-use/environment", Effect.gen(function* () {
53392
53602
  const request = yield* HttpServerRequest.HttpServerRequest;
53393
53603
  const binding = yield* resolveDesktopBinding(bearer(request));
@@ -53415,7 +53625,7 @@ const renew = HttpRouter.add("POST", "/internal/computer-use/renew", Effect.gen(
53415
53625
  if (binding.trust) yield* (yield* RemoteComputerUseBindings).touch(bearer(request));
53416
53626
  return HttpServerResponse.empty({ status: 204 });
53417
53627
  }).pipe(Effect.catch(failure$1)));
53418
- const layer$66 = Layer.mergeAll(exchange, hubForward, hubExchange, connect, respond, environment, renew).pipe(Layer.provide(remoteComputerUseBindingsLayer));
53628
+ const layer$66 = Layer.mergeAll(exchange, hubForward, hubExchange, connect, respond, report, environment, renew).pipe(Layer.provide(remoteComputerUseBindingsLayer));
53419
53629
  //#endregion
53420
53630
  //#region src/device/DeviceHubSocketProtocol.ts
53421
53631
  const MAX_DEVICE_INPUT_BYTES = 8 * 1024;
@@ -124607,6 +124817,8 @@ const RPC_REQUIRED_SCOPE = /* @__PURE__ */ new Map([
124607
124817
  [WS_METHODS.previewReportStatus, AuthOrchestrationOperateScope],
124608
124818
  [WS_METHODS.computerUseConnect, AuthOrchestrationOperateScope],
124609
124819
  [WS_METHODS.computerUseList, AuthOrchestrationReadScope],
124820
+ [WS_METHODS.computerUseControls, AuthOrchestrationReadScope],
124821
+ [WS_METHODS.computerUseControl, AuthOrchestrationOperateScope],
124610
124822
  [WS_METHODS.computerUseRespond, AuthOrchestrationOperateScope],
124611
124823
  [WS_METHODS.previewAutomationConnect, AuthOrchestrationOperateScope],
124612
124824
  [WS_METHODS.previewAutomationRespond, AuthOrchestrationOperateScope],
@@ -125644,6 +125856,8 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker, computerUseBrok
125644
125856
  [WS_METHODS.previewList]: (input) => observeRpcEffect$1(WS_METHODS.previewList, previewManager.list(input), { "rpc.aggregate": "preview" }),
125645
125857
  [WS_METHODS.previewReportStatus]: (input) => observeRpcEffect$1(WS_METHODS.previewReportStatus, previewManager.reportStatus(input), { "rpc.aggregate": "preview" }),
125646
125858
  [WS_METHODS.computerUseList]: () => computerUseBroker.list,
125859
+ [WS_METHODS.computerUseControls]: () => computerUseBroker.controls,
125860
+ [WS_METHODS.computerUseControl]: (input) => computerUseBroker.control(input),
125647
125861
  [WS_METHODS.computerUseConnect]: () => Effect.fail(new ComputerUseError({
125648
125862
  reason: "denied",
125649
125863
  detail: "Ordinary environment clients cannot register Computer Use helpers."
@@ -126139,6 +126353,7 @@ const makeWithOptions = Effect.fn("McpSessionRegistry.make")(function* (options
126139
126353
  },
126140
126354
  environmentId,
126141
126355
  threadId,
126356
+ ...request.threadTitle ? { threadTitle: request.threadTitle } : {},
126142
126357
  providerSessionId,
126143
126358
  providerInstanceId: ProviderInstanceId.make(request.providerInstanceId),
126144
126359
  capabilities,
@@ -126494,8 +126709,10 @@ const makeProviderService = Effect.fn("makeProviderService")(function* (options)
126494
126709
  return Option.isSome(thread) ? resolveProjectAgentBrowserAccess(settings, thread.value.projectId) : false;
126495
126710
  })), Effect.catch((cause) => Effect.logWarning("Could not read settings; withholding agent browser access.", { cause }).pipe(Effect.as(false))));
126496
126711
  const computerUseAccess = yield* registry.getInstanceInfo(providerInstanceId).pipe(Effect.map((info) => info.driverKind !== "codex"), Effect.catch(() => Effect.succeed(false)));
126712
+ const threadTitle = Option.isSome(projectionQuery) ? yield* projectionQuery.value.getThreadShellById(threadId).pipe(Effect.map((thread) => Option.isSome(thread) ? thread.value.title : void 0), Effect.catch(() => Effect.succeed(void 0))) : void 0;
126497
126713
  const credential = yield* issueActiveMcpCredential({
126498
126714
  threadId,
126715
+ ...threadTitle ? { threadTitle } : {},
126499
126716
  providerInstanceId,
126500
126717
  browserAccess,
126501
126718
  computerUseAccess,
@@ -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-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=`
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-CTnb3kvX.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-CzGdInUB.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-DmvUg7MB.js";import{a as He,n as Ue}from"./fileCommentAnnotations-BmPYMVTR.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],
@@ -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: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
98
+ //# sourceMappingURL=DiffPanel-Bbzx_GKV.js.map