@p4code/cli 0.6.55 → 0.7.0
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 +237 -21
- package/dist/client/assets/{DiffPanel-BYPQGCQT.js → DiffPanel-Q2wpcGXf.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-6b4o__bp.js → FilePreviewPanel-Cyst20U8.js} +2 -2
- package/dist/client/assets/{PreviewPanel-HrbPS-5I.js → PreviewPanel-D1Pve7sy.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-DMwCNuOz.js → PullRequestCodeTab-LaUWqYLN.js} +2 -2
- package/dist/client/assets/{fileCommentAnnotations-ClQq9bDS.js → fileCommentAnnotations-BPbcgWjJ.js} +2 -2
- package/dist/client/assets/{index-Cb4eQ3A4.js → index-CgIIi3gc.js} +11 -6
- package/dist/client/assets/{renderFileChildren-duImZqo2.js → renderFileChildren-DsQhidLI.js} +2 -2
- package/dist/client/assets/{toggle-group-DKavoKRh.js → toggle-group-BY2-0xBw.js} +2 -2
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -52,12 +52,12 @@ import * as SqlClient from "effect/unstable/sql/SqlClient";
|
|
|
52
52
|
import * as SqlSchema from "effect/unstable/sql/SqlSchema";
|
|
53
53
|
import * as PlatformError from "effect/PlatformError";
|
|
54
54
|
import * as Migrator from "effect/unstable/sql/Migrator";
|
|
55
|
+
import * as Clock from "effect/Clock";
|
|
55
56
|
import * as NodeUtil from "node:util";
|
|
56
57
|
import * as Cause from "effect/Cause";
|
|
57
58
|
import * as Exit from "effect/Exit";
|
|
58
59
|
import * as NodeReadline from "node:readline";
|
|
59
60
|
import * as NodeFSP from "node:fs/promises";
|
|
60
|
-
import * as Clock from "effect/Clock";
|
|
61
61
|
import * as Headers$1 from "effect/unstable/http/Headers";
|
|
62
62
|
import * as HttpRouter$1 from "effect/unstable/http/HttpRouter";
|
|
63
63
|
import * as NodeStream from "@effect/platform-node/NodeStream";
|
|
@@ -263,7 +263,7 @@ const make$123 = () => {
|
|
|
263
263
|
const layer$124 = Layer.sync(NetService, make$123);
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region package.json
|
|
266
|
-
var version$1 = "0.
|
|
266
|
+
var version$1 = "0.7.0";
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region ../../packages/shared/src/serverInstance.ts
|
|
269
269
|
/**
|
|
@@ -18807,6 +18807,14 @@ var _065_ProjectionThreadsParentThread_default = Effect.gen(function* () {
|
|
|
18807
18807
|
`;
|
|
18808
18808
|
});
|
|
18809
18809
|
//#endregion
|
|
18810
|
+
//#region src/persistence/Migrations/066_OrchestrationEventTypeSequenceIndex.ts
|
|
18811
|
+
var _066_OrchestrationEventTypeSequenceIndex_default = Effect.gen(function* () {
|
|
18812
|
+
yield* (yield* SqlClient.SqlClient)`
|
|
18813
|
+
CREATE INDEX IF NOT EXISTS idx_orchestration_events_type_sequence
|
|
18814
|
+
ON orchestration_events(event_type, sequence)
|
|
18815
|
+
`;
|
|
18816
|
+
});
|
|
18817
|
+
//#endregion
|
|
18810
18818
|
//#region src/persistence/Migrations/001_OrchestrationEvents.ts
|
|
18811
18819
|
var _001_OrchestrationEvents_default = Effect.gen(function* () {
|
|
18812
18820
|
const sql = yield* SqlClient.SqlClient;
|
|
@@ -21013,6 +21021,11 @@ const migrationEntries = [
|
|
|
21013
21021
|
65,
|
|
21014
21022
|
"ProjectionThreadsParentThread",
|
|
21015
21023
|
_065_ProjectionThreadsParentThread_default
|
|
21024
|
+
],
|
|
21025
|
+
[
|
|
21026
|
+
66,
|
|
21027
|
+
"OrchestrationEventTypeSequenceIndex",
|
|
21028
|
+
_066_OrchestrationEventTypeSequenceIndex_default
|
|
21016
21029
|
]
|
|
21017
21030
|
];
|
|
21018
21031
|
const makeMigrationLoader = (throughId) => Migrator.fromRecord(Object.fromEntries(migrationEntries.filter(([id]) => throughId === void 0 || id <= throughId).map(([id, name, migration]) => [`${id}_${name}`, migration])));
|
|
@@ -21074,14 +21087,25 @@ const runGuardedMigrations = Effect.fn("runGuardedMigrations")(function* (input)
|
|
|
21074
21087
|
appliedMigrationId: appliedId,
|
|
21075
21088
|
targetMigrationId: targetId
|
|
21076
21089
|
}));
|
|
21090
|
+
const snapshotStartedAt = yield* Clock.currentTimeMillis;
|
|
21077
21091
|
yield* captureDatabaseSnapshot(input.dbPath).pipe(Effect.tapCause((cause) => Effect.logError("Refusing to migrate without a database snapshot").pipe(Effect.annotateLogs({
|
|
21078
21092
|
dbPath: input.dbPath,
|
|
21079
21093
|
cause
|
|
21080
21094
|
}))));
|
|
21095
|
+
yield* Effect.logInfo("database migration snapshot completed", {
|
|
21096
|
+
durationMs: (yield* Clock.currentTimeMillis) - snapshotStartedAt,
|
|
21097
|
+
appliedMigrationId: appliedId,
|
|
21098
|
+
targetMigrationId: targetId
|
|
21099
|
+
});
|
|
21100
|
+
const migrationStartedAt = yield* Clock.currentTimeMillis;
|
|
21081
21101
|
const executed = yield* runMigrations(input.options).pipe(Effect.tapCause(() => markDatabaseRestorePending(input.dbPath).pipe(Effect.andThen(Effect.logError("Migration failed; the database will be restored on the next start").pipe(Effect.annotateLogs({
|
|
21082
21102
|
appliedMigrationId: appliedId,
|
|
21083
21103
|
targetMigrationId: targetId
|
|
21084
21104
|
}))), Effect.tapError((cause) => Effect.logError("Could not mark the database for restore").pipe(Effect.annotateLogs({ cause }))), Effect.ignore)));
|
|
21105
|
+
yield* Effect.logInfo("database migrations completed", {
|
|
21106
|
+
durationMs: (yield* Clock.currentTimeMillis) - migrationStartedAt,
|
|
21107
|
+
executed: executed.length
|
|
21108
|
+
});
|
|
21085
21109
|
yield* discardSnapshotQuietly(input.dbPath);
|
|
21086
21110
|
return executed;
|
|
21087
21111
|
});
|
|
@@ -36212,15 +36236,18 @@ const OrchestrationEventPersistedRowSchema = Schema$1.Struct({
|
|
|
36212
36236
|
});
|
|
36213
36237
|
const ReadFromSequenceRequestSchema = Schema$1.Struct({
|
|
36214
36238
|
sequenceExclusive: NonNegativeInt,
|
|
36239
|
+
throughSequence: NonNegativeInt,
|
|
36215
36240
|
limit: Schema$1.Number
|
|
36216
36241
|
});
|
|
36217
36242
|
const ReadFromSequenceOfTypesRequestSchema = Schema$1.Struct({
|
|
36218
36243
|
sequenceExclusive: NonNegativeInt,
|
|
36244
|
+
throughSequence: NonNegativeInt,
|
|
36219
36245
|
limit: Schema$1.Number,
|
|
36220
36246
|
eventTypes: Schema$1.Array(OrchestrationEventType)
|
|
36221
36247
|
});
|
|
36222
36248
|
const ReadFromSequenceOfThreadRequestSchema = Schema$1.Struct({
|
|
36223
36249
|
sequenceExclusive: NonNegativeInt,
|
|
36250
|
+
throughSequence: NonNegativeInt,
|
|
36224
36251
|
limit: Schema$1.Number,
|
|
36225
36252
|
threadId: Schema$1.String
|
|
36226
36253
|
});
|
|
@@ -36340,6 +36367,7 @@ const makeEventStore = Effect.gen(function* () {
|
|
|
36340
36367
|
metadata_json AS "metadata"
|
|
36341
36368
|
FROM orchestration_events
|
|
36342
36369
|
WHERE sequence > ${request.sequenceExclusive}
|
|
36370
|
+
AND sequence <= ${request.throughSequence}
|
|
36343
36371
|
ORDER BY sequence ASC
|
|
36344
36372
|
LIMIT ${request.limit}
|
|
36345
36373
|
`
|
|
@@ -36361,10 +36389,21 @@ const makeEventStore = Effect.gen(function* () {
|
|
|
36361
36389
|
payload_json AS "payload",
|
|
36362
36390
|
metadata_json AS "metadata"
|
|
36363
36391
|
FROM orchestration_events
|
|
36364
|
-
WHERE sequence
|
|
36365
|
-
|
|
36392
|
+
WHERE sequence IN (
|
|
36393
|
+
SELECT sequence FROM (
|
|
36394
|
+
${sql.join(" UNION ALL ")(request.eventTypes.map((eventType) => sql`
|
|
36395
|
+
SELECT sequence FROM (
|
|
36396
|
+
SELECT sequence FROM orchestration_events
|
|
36397
|
+
WHERE event_type = ${eventType}
|
|
36398
|
+
AND sequence > ${request.sequenceExclusive}
|
|
36399
|
+
AND sequence <= ${request.throughSequence}
|
|
36400
|
+
ORDER BY sequence ASC LIMIT ${request.limit}
|
|
36401
|
+
)
|
|
36402
|
+
`))}
|
|
36403
|
+
)
|
|
36404
|
+
ORDER BY sequence ASC LIMIT ${request.limit}
|
|
36405
|
+
)
|
|
36366
36406
|
ORDER BY sequence ASC
|
|
36367
|
-
LIMIT ${request.limit}
|
|
36368
36407
|
`
|
|
36369
36408
|
});
|
|
36370
36409
|
const readEventRowsFromSequenceOfThread = SqlSchema.findAll({
|
|
@@ -36387,6 +36426,7 @@ const makeEventStore = Effect.gen(function* () {
|
|
|
36387
36426
|
WHERE aggregate_kind = 'thread'
|
|
36388
36427
|
AND stream_id = ${request.threadId}
|
|
36389
36428
|
AND sequence > ${request.sequenceExclusive}
|
|
36429
|
+
AND sequence <= ${request.throughSequence}
|
|
36390
36430
|
ORDER BY sequence ASC
|
|
36391
36431
|
LIMIT ${request.limit}
|
|
36392
36432
|
`
|
|
@@ -36449,6 +36489,7 @@ const makeEventStore = Effect.gen(function* () {
|
|
|
36449
36489
|
});
|
|
36450
36490
|
const readPage = (cursor, remaining) => Stream.fromEffect(readRows({
|
|
36451
36491
|
sequenceExclusive: cursor,
|
|
36492
|
+
throughSequence: options?.throughSequence ?? Number.MAX_SAFE_INTEGER,
|
|
36452
36493
|
limit: Math.min(remaining, READ_PAGE_SIZE)
|
|
36453
36494
|
}).pipe(Effect.mapError(toPersistenceSqlOrDecodeError$4("OrchestrationEventStore.readFromSequence:query", "OrchestrationEventStore.readFromSequence:decodeRows")), Effect.flatMap((rows) => Effect.forEach(rows, (row) => decodeEvent(row).pipe(Effect.mapError(toPersistenceDecodeError("OrchestrationEventStore.readFromSequence:rowToEvent"))))))).pipe(Stream.flatMap((events) => {
|
|
36454
36495
|
if (events.length === 0) return Stream.empty;
|
|
@@ -39993,7 +40034,12 @@ const makeOrchestrationEngine = Effect.gen(function* () {
|
|
|
39993
40034
|
})));
|
|
39994
40035
|
};
|
|
39995
40036
|
yield* projectionPipeline.bootstrap;
|
|
40037
|
+
const readModelStartedAt = yield* Clock.currentTimeMillis;
|
|
39996
40038
|
commandReadModel = yield* projectionSnapshotQuery.getCommandReadModel();
|
|
40039
|
+
yield* Effect.logInfo("orchestration command read model loaded", {
|
|
40040
|
+
durationMs: (yield* Clock.currentTimeMillis) - readModelStartedAt,
|
|
40041
|
+
sequence: commandReadModel.snapshotSequence
|
|
40042
|
+
});
|
|
39997
40043
|
const worker = Effect.forever(Queue.take(commandQueue).pipe(Effect.flatMap(processEnvelope)));
|
|
39998
40044
|
yield* Effect.forkScoped(worker);
|
|
39999
40045
|
yield* Effect.logDebug("orchestration engine started").pipe(Effect.annotateLogs({ sequence: commandReadModel.snapshotSequence }));
|
|
@@ -42740,74 +42786,210 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
|
|
|
42740
42786
|
const projectors = [
|
|
42741
42787
|
{
|
|
42742
42788
|
name: ORCHESTRATION_PROJECTOR_NAMES.projects,
|
|
42789
|
+
eventTypes: [
|
|
42790
|
+
"project.created",
|
|
42791
|
+
"project.meta-updated",
|
|
42792
|
+
"project.deleted"
|
|
42793
|
+
],
|
|
42743
42794
|
apply: applyProjectsProjection
|
|
42744
42795
|
},
|
|
42745
42796
|
{
|
|
42746
42797
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadPairs,
|
|
42798
|
+
eventTypes: [
|
|
42799
|
+
"thread.message-sent",
|
|
42800
|
+
"thread-pair.created",
|
|
42801
|
+
"thread-pair.gate-opened",
|
|
42802
|
+
"thread-pair.gate-advanced",
|
|
42803
|
+
"thread-pair.gate-resolved",
|
|
42804
|
+
"thread-pair.detached",
|
|
42805
|
+
"thread-pair.cursor-advanced",
|
|
42806
|
+
"thread-pair.triage-advanced"
|
|
42807
|
+
],
|
|
42747
42808
|
apply: applyThreadPairsProjection
|
|
42748
42809
|
},
|
|
42749
42810
|
{
|
|
42750
42811
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadMessages,
|
|
42812
|
+
eventTypes: [
|
|
42813
|
+
"thread.created",
|
|
42814
|
+
"thread.message-sent",
|
|
42815
|
+
"thread.reverted"
|
|
42816
|
+
],
|
|
42751
42817
|
apply: applyThreadMessagesProjection
|
|
42752
42818
|
},
|
|
42753
42819
|
{
|
|
42754
42820
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadProposedPlans,
|
|
42821
|
+
eventTypes: ["thread.proposed-plan-upserted", "thread.reverted"],
|
|
42755
42822
|
apply: applyThreadProposedPlansProjection
|
|
42756
42823
|
},
|
|
42757
42824
|
{
|
|
42758
42825
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadScheduledTasks,
|
|
42826
|
+
eventTypes: [
|
|
42827
|
+
"thread.scheduled-task.created",
|
|
42828
|
+
"thread.scheduled-task.cancelled",
|
|
42829
|
+
"thread.scheduled-task.fired"
|
|
42830
|
+
],
|
|
42759
42831
|
apply: applyThreadScheduledTasksProjection
|
|
42760
42832
|
},
|
|
42761
42833
|
{
|
|
42762
42834
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadQueuedMessages,
|
|
42835
|
+
eventTypes: [
|
|
42836
|
+
"thread.message-queued",
|
|
42837
|
+
"thread.queued-message-removed",
|
|
42838
|
+
"thread.deleted"
|
|
42839
|
+
],
|
|
42763
42840
|
apply: applyThreadQueuedMessagesProjection
|
|
42764
42841
|
},
|
|
42765
42842
|
{
|
|
42766
42843
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadActivities,
|
|
42844
|
+
eventTypes: ["thread.activity-appended", "thread.reverted"],
|
|
42767
42845
|
apply: applyThreadActivitiesProjection
|
|
42768
42846
|
},
|
|
42769
42847
|
{
|
|
42770
42848
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadSessions,
|
|
42849
|
+
eventTypes: ["thread.session-set"],
|
|
42771
42850
|
apply: applyThreadSessionsProjection
|
|
42772
42851
|
},
|
|
42773
42852
|
{
|
|
42774
42853
|
name: ORCHESTRATION_PROJECTOR_NAMES.threadTurns,
|
|
42854
|
+
eventTypes: [
|
|
42855
|
+
"thread.turn-start-requested",
|
|
42856
|
+
"thread.activity-appended",
|
|
42857
|
+
"thread.session-set",
|
|
42858
|
+
"thread.message-sent",
|
|
42859
|
+
"thread.turn-interrupt-requested",
|
|
42860
|
+
"thread.turn-diff-completed",
|
|
42861
|
+
"thread.reverted"
|
|
42862
|
+
],
|
|
42775
42863
|
apply: applyThreadTurnsProjection
|
|
42776
42864
|
},
|
|
42777
42865
|
{
|
|
42778
42866
|
name: ORCHESTRATION_PROJECTOR_NAMES.checkpoints,
|
|
42867
|
+
eventTypes: [],
|
|
42779
42868
|
apply: applyCheckpointsProjection
|
|
42780
42869
|
},
|
|
42781
42870
|
{
|
|
42782
42871
|
name: ORCHESTRATION_PROJECTOR_NAMES.pendingApprovals,
|
|
42872
|
+
eventTypes: ["thread.activity-appended", "thread.approval-response-requested"],
|
|
42783
42873
|
apply: applyPendingApprovalsProjection
|
|
42784
42874
|
},
|
|
42785
42875
|
{
|
|
42786
42876
|
name: ORCHESTRATION_PROJECTOR_NAMES.threads,
|
|
42877
|
+
eventTypes: [
|
|
42878
|
+
"thread.created",
|
|
42879
|
+
"thread.archived",
|
|
42880
|
+
"thread.unarchived",
|
|
42881
|
+
"thread.settled",
|
|
42882
|
+
"thread.unsettled",
|
|
42883
|
+
"thread.snoozed",
|
|
42884
|
+
"thread.unsnoozed",
|
|
42885
|
+
"thread.pinned",
|
|
42886
|
+
"thread.unpinned",
|
|
42887
|
+
"thread.pin-reordered",
|
|
42888
|
+
"thread.meta-updated",
|
|
42889
|
+
"thread.runtime-mode-set",
|
|
42890
|
+
"thread.interaction-mode-set",
|
|
42891
|
+
"thread.compress-mode-set",
|
|
42892
|
+
"thread.unprompted-subagents-set",
|
|
42893
|
+
"thread.pull-requests-updated",
|
|
42894
|
+
"thread.computer-use-grant-set",
|
|
42895
|
+
"thread.deleted",
|
|
42896
|
+
"thread.message-sent",
|
|
42897
|
+
"thread.proposed-plan-upserted",
|
|
42898
|
+
"thread.activity-appended",
|
|
42899
|
+
"thread.approval-response-requested",
|
|
42900
|
+
"thread.user-input-response-requested",
|
|
42901
|
+
"thread.session-set",
|
|
42902
|
+
"thread.turn-diff-completed",
|
|
42903
|
+
"thread.reverted"
|
|
42904
|
+
],
|
|
42787
42905
|
apply: applyThreadsProjection
|
|
42788
42906
|
}
|
|
42789
42907
|
];
|
|
42790
|
-
const
|
|
42908
|
+
const runProjectorBatch = Effect.fn("runProjectorBatch")(function* (projector, events) {
|
|
42909
|
+
const lastEvent = events.at(-1);
|
|
42910
|
+
if (lastEvent === void 0) return;
|
|
42791
42911
|
const attachmentSideEffects = {
|
|
42792
42912
|
deletedThreadIds: /* @__PURE__ */ new Set(),
|
|
42793
42913
|
prunedThreadRelativePaths: /* @__PURE__ */ new Map()
|
|
42794
42914
|
};
|
|
42795
|
-
yield* sql.withTransaction(
|
|
42796
|
-
|
|
42797
|
-
|
|
42798
|
-
|
|
42799
|
-
|
|
42915
|
+
yield* sql.withTransaction(Effect.gen(function* () {
|
|
42916
|
+
for (const event of events) yield* projector.apply(event, attachmentSideEffects);
|
|
42917
|
+
yield* projectionStateRepository.upsert({
|
|
42918
|
+
projector: projector.name,
|
|
42919
|
+
lastAppliedSequence: lastEvent.sequence,
|
|
42920
|
+
updatedAt: lastEvent.occurredAt
|
|
42921
|
+
});
|
|
42922
|
+
}));
|
|
42800
42923
|
yield* runAttachmentSideEffects(attachmentSideEffects).pipe(Effect.catch((cause) => Effect.logWarning("failed to apply projected attachment side-effects", {
|
|
42801
42924
|
projector: projector.name,
|
|
42925
|
+
sequence: lastEvent.sequence,
|
|
42926
|
+
cause
|
|
42927
|
+
})));
|
|
42928
|
+
});
|
|
42929
|
+
const bootstrapProjector = Effect.fn("bootstrapProjector")(function* (projector, head) {
|
|
42930
|
+
const stateRow = yield* projectionStateRepository.getByProjector({ projector: projector.name });
|
|
42931
|
+
const cursor = Option.isSome(stateRow) ? stateRow.value.lastAppliedSequence : 0;
|
|
42932
|
+
if (cursor >= head.sequence) return;
|
|
42933
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
42934
|
+
let replayedEvents = 0;
|
|
42935
|
+
yield* eventStore.readFromSequence(cursor, Number.MAX_SAFE_INTEGER, {
|
|
42936
|
+
eventTypes: projector.eventTypes,
|
|
42937
|
+
throughSequence: head.sequence
|
|
42938
|
+
}).pipe(Stream.grouped(500), Stream.runForEach((events) => Effect.gen(function* () {
|
|
42939
|
+
let batch = [];
|
|
42940
|
+
for (const event of events) if (event.type === "thread.created" || event.type === "thread.archived" || event.type === "thread.reverted" || event.type === "thread.deleted") {
|
|
42941
|
+
yield* runProjectorBatch(projector, batch);
|
|
42942
|
+
batch = [];
|
|
42943
|
+
yield* runProjectorBatch(projector, [event]);
|
|
42944
|
+
} else batch.push(event);
|
|
42945
|
+
yield* runProjectorBatch(projector, batch);
|
|
42946
|
+
replayedEvents += events.length;
|
|
42947
|
+
})), Effect.withTracerEnabled(false));
|
|
42948
|
+
yield* projectionStateRepository.upsert({
|
|
42949
|
+
projector: projector.name,
|
|
42950
|
+
lastAppliedSequence: head.sequence,
|
|
42951
|
+
updatedAt: head.occurredAt
|
|
42952
|
+
});
|
|
42953
|
+
yield* Effect.logInfo("orchestration projection replay completed", {
|
|
42954
|
+
projector: projector.name,
|
|
42955
|
+
fromSequence: cursor,
|
|
42956
|
+
throughSequence: head.sequence,
|
|
42957
|
+
replayedEvents,
|
|
42958
|
+
durationMs: (yield* Clock.currentTimeMillis) - startedAt
|
|
42959
|
+
});
|
|
42960
|
+
});
|
|
42961
|
+
const projectEvent = (event) => Effect.gen(function* () {
|
|
42962
|
+
const attachmentSideEffects = {
|
|
42963
|
+
deletedThreadIds: /* @__PURE__ */ new Set(),
|
|
42964
|
+
prunedThreadRelativePaths: /* @__PURE__ */ new Map()
|
|
42965
|
+
};
|
|
42966
|
+
yield* sql.withTransaction(Effect.gen(function* () {
|
|
42967
|
+
for (const projector of projectors) if (projector.eventTypes.includes(event.type)) yield* projector.apply(event, attachmentSideEffects);
|
|
42968
|
+
yield* sql`
|
|
42969
|
+
INSERT INTO projection_state ${sql.insert(projectors.map((projector) => ({
|
|
42970
|
+
projector: projector.name,
|
|
42971
|
+
last_applied_sequence: event.sequence,
|
|
42972
|
+
updated_at: event.occurredAt
|
|
42973
|
+
})))}
|
|
42974
|
+
ON CONFLICT(projector) DO UPDATE SET
|
|
42975
|
+
last_applied_sequence = excluded.last_applied_sequence,
|
|
42976
|
+
updated_at = excluded.updated_at
|
|
42977
|
+
`;
|
|
42978
|
+
}));
|
|
42979
|
+
yield* runAttachmentSideEffects(attachmentSideEffects).pipe(Effect.catch((cause) => Effect.logWarning("failed to apply projected attachment side-effects", {
|
|
42802
42980
|
sequence: event.sequence,
|
|
42803
42981
|
eventType: event.type,
|
|
42804
42982
|
cause
|
|
42805
42983
|
})));
|
|
42806
|
-
});
|
|
42807
|
-
|
|
42808
|
-
|
|
42809
|
-
|
|
42810
|
-
|
|
42984
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.provideService(Path$1.Path, path), Effect.provideService(ServerConfig$1, serverConfig), Effect.catchTag("SqlError", (sqlError) => Effect.fail(toPersistenceSqlError("ProjectionPipeline.projectEvent:query")(sqlError))));
|
|
42985
|
+
return {
|
|
42986
|
+
bootstrap: Effect.gen(function* () {
|
|
42987
|
+
const head = (yield* sql`
|
|
42988
|
+
SELECT sequence, occurred_at AS "occurredAt"
|
|
42989
|
+
FROM orchestration_events ORDER BY sequence DESC LIMIT 1
|
|
42990
|
+
`)[0];
|
|
42991
|
+
if (head !== void 0) for (const projector of projectors) yield* bootstrapProjector(projector, head);
|
|
42992
|
+
}).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.provideService(Path$1.Path, path), Effect.provideService(ServerConfig$1, serverConfig), Effect.tap(() => Effect.logDebug("orchestration projection pipeline bootstrapped", { projectors: projectors.length })), Effect.catchTag("SqlError", (sqlError) => Effect.fail(toPersistenceSqlError("ProjectionPipeline.bootstrap:query")(sqlError)))),
|
|
42811
42993
|
projectEvent
|
|
42812
42994
|
};
|
|
42813
42995
|
});
|
|
@@ -67731,7 +67913,7 @@ function parseCpaModelDefinitions(json, provider) {
|
|
|
67731
67913
|
id,
|
|
67732
67914
|
name: stringOr(raw.display_name) ?? id,
|
|
67733
67915
|
family: familyOf(id),
|
|
67734
|
-
...created ? { releaseDate: (
|
|
67916
|
+
...created ? { releaseDate: DateTime.formatIso(DateTime.makeUnsafe(created * 1e3)) } : {},
|
|
67735
67917
|
...contextTokens ? { contextTokens } : {},
|
|
67736
67918
|
...Array.isArray(levels) ? { effort: levels.filter((level) => typeof level === "string") } : {}
|
|
67737
67919
|
}];
|
|
@@ -67790,7 +67972,7 @@ function parseOpenRouter(json) {
|
|
|
67790
67972
|
id,
|
|
67791
67973
|
name: (stringOr(raw.name) ?? id).replace(/^[^:]+:\s*/, ""),
|
|
67792
67974
|
family: familyOf(id),
|
|
67793
|
-
...created ? { releaseDate: (
|
|
67975
|
+
...created ? { releaseDate: DateTime.formatIso(DateTime.makeUnsafe(created * 1e3)) } : {},
|
|
67794
67976
|
...contextTokens ? { contextTokens } : {}
|
|
67795
67977
|
});
|
|
67796
67978
|
}
|
|
@@ -143871,12 +144053,30 @@ Layer.effect(RuntimeReceiptBus, makeRuntimeReceiptBusTest);
|
|
|
143871
144053
|
* the scope closes. A finalizer shuts down the queue.
|
|
143872
144054
|
*
|
|
143873
144055
|
* @param process - The effect to run for each queued item.
|
|
144056
|
+
* @param mergeAdjacent - Optional pure merge of adjacent queued items. Returning
|
|
144057
|
+
* undefined preserves the next item as a processing boundary. No item waits
|
|
144058
|
+
* for another to arrive; each dequeue merges at most 64 already queued items.
|
|
143874
144059
|
* @returns A `DrainableWorker` with `queue` and `drain`.
|
|
143875
144060
|
*/
|
|
143876
|
-
const makeDrainableWorker = (process) => Effect.gen(function* () {
|
|
144061
|
+
const makeDrainableWorker = (process, mergeAdjacent) => Effect.gen(function* () {
|
|
143877
144062
|
const queue = yield* Effect.acquireRelease(TxQueue.unbounded(), TxQueue.shutdown);
|
|
143878
144063
|
const outstanding = yield* TxRef.make(0);
|
|
143879
|
-
yield*
|
|
144064
|
+
yield* Effect.gen(function* () {
|
|
144065
|
+
let item = yield* TxQueue.take(queue);
|
|
144066
|
+
let count = 1;
|
|
144067
|
+
if (mergeAdjacent !== void 0) while (count < 64 && !(yield* TxQueue.isEmpty(queue))) {
|
|
144068
|
+
const next = yield* TxQueue.peek(queue);
|
|
144069
|
+
const merged = mergeAdjacent(item, next);
|
|
144070
|
+
if (merged === void 0) break;
|
|
144071
|
+
yield* TxQueue.take(queue);
|
|
144072
|
+
item = merged;
|
|
144073
|
+
count += 1;
|
|
144074
|
+
}
|
|
144075
|
+
return {
|
|
144076
|
+
item,
|
|
144077
|
+
count
|
|
144078
|
+
};
|
|
144079
|
+
}).pipe(Effect.tx).pipe(Effect.tap(({ item, count }) => Effect.ensuring(process(item), TxRef.update(outstanding, (n) => n - count))), Effect.forever, Effect.forkScoped);
|
|
143880
144080
|
const drain = TxRef.get(outstanding).pipe(Effect.tap((n) => n > 0 ? Effect.txRetry : Effect.void), Effect.tx);
|
|
143881
144081
|
const enqueue = (element) => TxQueue.offer(queue, element).pipe(Effect.tap(() => TxRef.update(outstanding, (n) => n + 1)), Effect.tx);
|
|
143882
144082
|
return {
|
|
@@ -143964,6 +144164,22 @@ const COMPRESS_MODE_BY_THREAD_CACHE_CAPACITY = 1e4;
|
|
|
143964
144164
|
const COMPRESS_MODE_BY_THREAD_TTL = Duration.minutes(120);
|
|
143965
144165
|
const MAX_BUFFERED_ASSISTANT_CHARS = 24e3;
|
|
143966
144166
|
const STRICT_PROVIDER_LIFECYCLE_GUARD = process.env.P4CODE_STRICT_PROVIDER_LIFECYCLE_GUARD !== "0";
|
|
144167
|
+
function coalesceAssistantDeltas(left, right) {
|
|
144168
|
+
if (left.source !== "runtime" || right.source !== "runtime") return void 0;
|
|
144169
|
+
const a = left.event;
|
|
144170
|
+
const b = right.event;
|
|
144171
|
+
if (a.type !== "content.delta" || b.type !== "content.delta" || a.payload.streamKind !== "assistant_text" || b.payload.streamKind !== "assistant_text" || a.turnId === void 0 || a.itemId === void 0 || a.provider !== b.provider || a.providerInstanceId !== b.providerInstanceId || a.threadId !== b.threadId || a.turnId !== b.turnId || a.itemId !== b.itemId || a.requestId !== b.requestId || a.payload.contentIndex !== b.payload.contentIndex || a.payload.summaryIndex !== b.payload.summaryIndex || a.providerRefs?.providerTurnId !== b.providerRefs?.providerTurnId || a.providerRefs?.providerItemId !== b.providerRefs?.providerItemId || a.providerRefs?.providerRequestId !== b.providerRefs?.providerRequestId || a.payload.delta.length + b.payload.delta.length > MAX_BUFFERED_ASSISTANT_CHARS) return void 0;
|
|
144172
|
+
return {
|
|
144173
|
+
source: "runtime",
|
|
144174
|
+
event: {
|
|
144175
|
+
...a,
|
|
144176
|
+
payload: {
|
|
144177
|
+
...a.payload,
|
|
144178
|
+
delta: a.payload.delta + b.payload.delta
|
|
144179
|
+
}
|
|
144180
|
+
}
|
|
144181
|
+
};
|
|
144182
|
+
}
|
|
143967
144183
|
function toTurnId$1(value) {
|
|
143968
144184
|
return value === void 0 ? void 0 : TurnId.make(String(value));
|
|
143969
144185
|
}
|
|
@@ -145002,7 +145218,7 @@ const make$9 = Effect.gen(function* () {
|
|
|
145002
145218
|
cause: Cause.pretty(cause)
|
|
145003
145219
|
});
|
|
145004
145220
|
}));
|
|
145005
|
-
const worker = yield* makeDrainableWorker(processInputSafely);
|
|
145221
|
+
const worker = yield* makeDrainableWorker(processInputSafely, coalesceAssistantDeltas);
|
|
145006
145222
|
const start = () => Effect.gen(function* () {
|
|
145007
145223
|
yield* Effect.forkScoped(Stream.runForEach(providerService.streamEvents, (event) => worker.enqueue({
|
|
145008
145224
|
source: "runtime",
|
|
@@ -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,Ia as a,Jr as o,Ku as s,Qa as c,Tn as l,Ua as u,Ur as d,Wa as ee,Xa as te,Ya as f,Za as p,_l as m,bn as ne,cu as h,ei as g,g as _,gl as re,hl as v,kt as y,ml as ie,nu as b,pu as x,ut as S,vt as C,x as w,xt as T,yt as E,yu as D,za as O,zl as ae}from"./previewAssetResource-6mhfd1nG.js";import{a as k,c as oe,i as A,n as j,o as M,r as N,s as se,t as ce}from"./toggle-group-
|
|
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,Ia as a,Jr as o,Ku as s,Qa as c,Tn as l,Ua as u,Ur as d,Wa as ee,Xa as te,Ya as f,Za as p,_l as m,bn as ne,cu as h,ei as g,g as _,gl as re,hl as v,kt as y,ml as ie,nu as b,pu as x,ut as S,vt as C,x as w,xt as T,yt as E,yu as D,za as O,zl as ae}from"./previewAssetResource-6mhfd1nG.js";import{a as k,c as oe,i as A,n as j,o as M,r as N,s as se,t as ce}from"./toggle-group-BY2-0xBw.js";import{A as P,D as le,Lr as ue,O as de,Q as fe,Rr as pe,Sr as me,Ur as he,Vr as ge,Wr as _e,Z as ve,_r as ye,cr as be,dr as xe,dt as Se,fi as Ce,fr as we,ft as Te,gr as Ee,h as De,ht as Oe,k as ke,lr as Ae,lt as je,mr as Me,mt as Ne,or as Pe,p as Fe,pi as Ie,pt as Le,sr as Re,ur as ze,ut as Be,zr as Ve}from"./index-CgIIi3gc.js";import{a as He,n as Ue}from"./fileCommentAnnotations-BPbcgWjJ.js";var We=m(`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}S.getState().openFile(e,t);return}r(n?_(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Me(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:c,className:l,renderHeaderPrefix:u}=e,ee=d(Qe),te=d(B),f;t[0]===a?f=t[1]:(f=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=f);let p=d(f),[m,ne]=(0,F.useState)(null),[h,_]=(0,F.useState)(null),re;t[2]===n?re=t[3]:(re=new Map(n.map(Ze)),t[2]=n,t[3]=re);let v=re,y;if(t[4]!==h||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==h||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=g(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:Be(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=p,t[11]=r,t[12]=e):e=t[12],y=n.map(e),t[4]=h,t[5]=n,t[6]=p,t[7]=r,t[8]=y}else y=t[8];let ie=y,b;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(b=e=>{ne(null),h?.annotation.metadata.entries.some(t=>t.id===e)?_(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=b):b=t[16];let x=b,S;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==v||t[21]!==r||t[22]!==i?(S=(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&&ee(a,c),ne(null),_(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=v,t[21]=r,t[22]=i,t[23]=S):S=t[23];let C=S,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&&_({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,E=h!==null,D;t[28]===c?D=t[29]:(D=c?{ref:c}:{},t[28]=c,t[29]=D);let O;t[30]===l?O=t[31]:(O=l?{className:l}:{},t[30]=l,t[31]=O);let ae=!E,oe=!E,A;t[32]!==T||t[33]!==s||t[34]!==oe||t[35]!==ae?(A={...s,enableGutterUtility:ae,enableLineSelection:oe,onLineSelectionEnd:T},t[32]=T,t[33]=s,t[34]=oe,t[35]=ae,t[36]=A):A=t[36];let j;t[37]===u?j=t[38]:(j=e=>e.type===`diff`?u(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=u,t[38]=j);let M;t[39]!==x||t[40]!==C?(M=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:()=>x(e.id),onComment:t=>C(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=C,t[41]=M):M=t[41];let N;return t[42]!==ie||t[43]!==m||t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==D||t[48]!==O?(N=(0,L.jsx)(k,{...D,...O,items:ie,selectedLines:m,onSelectedLinesChange:ne,options:A,renderHeaderPrefix:j,renderAnnotation:M}),t[42]=ie,t[43]=m,t[44]=A,t[45]=j,t[46]=M,t[47]=D,t[48]=O,t[49]=N):N=t[49],N}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:b(e,{label:`environment-data:review:diff-preview`,tag:s.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(l);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}=w(),s=ge(),[l]=(0,F.useState)(n),[d,m]=(0,F.useState)(`stacked`),[g,_]=(0,F.useState)(s.wordWrap),[b,S]=(0,F.useState)(s.diffIgnoreWhitespace),[k,De]=(0,F.useState)(``),[Me,Be]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=Ve(r),qe=I?.projectId??null,Je=pe(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=ae(ne.configValueAtom(I?.environmentId??null)),Xe=Ee(I?.environmentId??null,z?.availableEditors??[]),Ze=y(I!=null&&R!=null?ue.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>ke(e.byThreadKey,r,l===`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=Me.scopeKey===Y?Me.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:b,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=y(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:b}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=y(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:b}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=y(W===null&&G===`branch`&&I&&X.data?.cwd?ue.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),vt=y(W===null&&G===`branch`&&I&&X.data?.cwd?ue.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,k),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...k.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)(()=>Le(Tt,`diff-panel:${o}`,{compactPartialHunkOffsets:W===null}),[o,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>Oe(e).localeCompare(Oe(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=je(e);return{fileDiff:e,filePath:Oe(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=N(jt,ut),Nt=(0,F.useMemo)(()=>Te(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`&&!h(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...D(x(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Be(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)(()=>{Be(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:A(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)(fe,{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)(c,{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)(v,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(ee,{align:`start`,className:`w-60`,children:[(0,L.jsx)(u,{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)(u,{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)(u,{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)(f,{children:[(0,L.jsx)(p,{children:`Turn`}),(0,L.jsx)(te,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(u,{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:me(e.completedAt,s.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)(Ie,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Pe,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||De(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(we,{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)(v,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(xe,{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)(be,{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:k,onChange:e=>De(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)(ze,{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)(ye,{"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)(re,{"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)(Fe,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(a,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Ce,{className:`size-3`}):(0,L.jsx)(oe,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(j,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[d],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&m(t)},children:[(0,L.jsx)(ce,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(M,{className:`size-3`})}),(0,L.jsx)(ce,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(se,{className:`size-3`})})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":g?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:g,onPressedChange:e=>{_(!!e)}}),children:(0,L.jsx)(he,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:g?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":b?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:b,onPressedChange:e=>{S(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(E,{side:`top`,children:b?`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=Oe(e);return(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(`button`,{type:`button`,className:i(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,Se(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(ie,{className:`size-4`}):(0,L.jsx)(v,{className:`size-4`})}),(0,L.jsx)(E,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:d===`split`?`split`:`unified`,lineDiffType:`none`,overflow:g?`wrap`:`scroll`,theme:Ne(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:i(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,g?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(ve,{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{De as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-
|
|
98
|
+
//# sourceMappingURL=DiffPanel-Q2wpcGXf.js.map
|