@p4code/cli 0.6.4 → 0.6.5
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 +125 -35
- package/dist/client/assets/{DiffPanel-DfuqXVpG.js → DiffPanel-J-OdKLva.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-BT2cVEr7.js → FilePreviewPanel-Dv0Lm7S4.js} +2 -2
- package/dist/client/assets/{PreviewPanel-Cvzdihek.js → PreviewPanel-BQboj1x5.js} +2 -2
- package/dist/client/assets/{PullRequestCodeTab-BWT2wgTE.js → PullRequestCodeTab-DrOcpMO3.js} +2 -2
- package/dist/client/assets/{fileCommentAnnotations-j7Nl3tNy.js → fileCommentAnnotations-Dh9DiTM4.js} +2 -2
- package/dist/client/assets/{index-DE12bQJs.js → index-M38Rayrc.js} +11 -7
- package/dist/client/assets/{renderFileChildren-BvcSiOwh.js → renderFileChildren-Bh5AmWA0.js} +2 -2
- package/dist/client/assets/{toggle-group-zU_XUcK4.js → toggle-group-BhSZjDjQ.js} +2 -2
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -266,7 +266,7 @@ const make$122 = () => {
|
|
|
266
266
|
const layer$123 = Layer.sync(NetService, make$122);
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region package.json
|
|
269
|
-
var version$1 = "0.6.
|
|
269
|
+
var version$1 = "0.6.5";
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/config.ts
|
|
272
272
|
/**
|
|
@@ -134926,6 +134926,32 @@ const rawEvidenceReadActivityId = (watchedThreadId, readerTurnId) => EventId.mak
|
|
|
134926
134926
|
* is a last-resort correlation source rather than something that displaces it.
|
|
134927
134927
|
*/
|
|
134928
134928
|
const serverEvidenceReadActivityId = (watchedThreadId, throughSequence) => EventId.make(`fusion-evidence-server:${watchedThreadId}:${throughSequence}`);
|
|
134929
|
+
/**
|
|
134930
|
+
* The Builder's copy of the report the Supervisor filed about it.
|
|
134931
|
+
*
|
|
134932
|
+
* The report row itself lives on the Supervisor thread, keyed by
|
|
134933
|
+
* {@link evidenceReportActivityId}. The Builder needs the same numbers to
|
|
134934
|
+
* settle its own handoff pill - which model wrote the summary, what it cost,
|
|
134935
|
+
* how long it took - and it cannot read another thread's activities, so the
|
|
134936
|
+
* row is mirrored onto the watched thread under its own key.
|
|
134937
|
+
*
|
|
134938
|
+
* Deliberately a different prefix: one activity id addresses one row, and the
|
|
134939
|
+
* two rows sit on different threads with different lifetimes. Keying the mirror
|
|
134940
|
+
* on the watched thread and the same bound keeps it idempotent - a retried or
|
|
134941
|
+
* replayed report replaces the mirror instead of appending beside it.
|
|
134942
|
+
*/
|
|
134943
|
+
const EVIDENCE_REPORT_MIRROR_PREFIX = "fusion-evidence-summary-builder:";
|
|
134944
|
+
const evidenceReportMirrorActivityId = (watchedThreadId, throughSequence) => EventId.make(`${EVIDENCE_REPORT_MIRROR_PREFIX}${watchedThreadId}:${throughSequence}`);
|
|
134945
|
+
/**
|
|
134946
|
+
* Whether a row on the builder's thread is the mirrored report rather than the
|
|
134947
|
+
* builder's own work.
|
|
134948
|
+
*
|
|
134949
|
+
* The mirror exists so the builder can render what the supervisor filed about
|
|
134950
|
+
* it. Feeding it back into the next handoff would hand the supervisor its own
|
|
134951
|
+
* previous summary as if the builder had produced it, and would spend evidence
|
|
134952
|
+
* budget on bookkeeping.
|
|
134953
|
+
*/
|
|
134954
|
+
const isEvidenceReportMirrorActivityId = (activityId) => activityId.startsWith(EVIDENCE_REPORT_MIRROR_PREFIX);
|
|
134929
134955
|
/** One report per review, keyed like the read it reports on so a retry replaces. */
|
|
134930
134956
|
const evidenceReportActivityId = (watchedThreadId, throughSequence) => EventId.make(`fusion-evidence-summary:${watchedThreadId}:${throughSequence}`);
|
|
134931
134957
|
/**
|
|
@@ -137037,9 +137063,13 @@ const recordEvidenceRead = Effect.fn("mcp.watch.recordEvidenceRead")(function* (
|
|
|
137037
137063
|
* `thread_watch_events` is the generic polling tool, so an orchestrator reading
|
|
137038
137064
|
* a thread it spawned goes through it too. Only a Fusion watcher is reading
|
|
137039
137065
|
* builder evidence, and only its work log should grow a row saying so.
|
|
137066
|
+
*
|
|
137067
|
+
* A failed lookup fails this effect rather than answering no: "unknown" and
|
|
137068
|
+
* "not paired" cost different things at different call sites, so the caller
|
|
137069
|
+
* decides which way to lean.
|
|
137040
137070
|
*/
|
|
137041
137071
|
const watchesAsFusionSupervisor = Effect.fn("mcp.watch.watchesAsFusionSupervisor")(function* (readerThreadId, watchedThreadId) {
|
|
137042
|
-
return (yield* (yield* ProjectionSnapshotQuery).getActiveThreadPairs()
|
|
137072
|
+
return (yield* (yield* ProjectionSnapshotQuery).getActiveThreadPairs()).some((pair) => pair.watcherThreadId === readerThreadId && pair.implementerThreadId === watchedThreadId);
|
|
137043
137073
|
});
|
|
137044
137074
|
/** Bounded so one report cannot dominate a thread's activity storage. */
|
|
137045
137075
|
const clip$1 = (value, limit) => {
|
|
@@ -137081,37 +137111,64 @@ const WatchToolkitHandlersLive = WatchToolkit.toLayer({
|
|
|
137081
137111
|
const summary = clip$1(input.summary, THREAD_EVIDENCE_REPORT_MAX_CHARS);
|
|
137082
137112
|
const reason = clip$1(input.reason, 500);
|
|
137083
137113
|
const outcome = summary === null && input.outcome === "summarized" ? "failed" : input.outcome;
|
|
137084
|
-
|
|
137085
|
-
|
|
137086
|
-
|
|
137087
|
-
|
|
137088
|
-
|
|
137114
|
+
const payload = {
|
|
137115
|
+
watchedThreadId: input.threadId,
|
|
137116
|
+
firstSequence: input.firstSequence,
|
|
137117
|
+
lastSequence: input.lastSequence,
|
|
137118
|
+
throughSequence: input.throughSequence,
|
|
137119
|
+
outcome,
|
|
137120
|
+
summary,
|
|
137121
|
+
model: clip$1(input.model, MODEL_ID_MAX_CHARS),
|
|
137122
|
+
reason: reason ?? (outcome === "summarized" ? null : "the supervisor gave no reason"),
|
|
137123
|
+
context,
|
|
137124
|
+
timing
|
|
137125
|
+
};
|
|
137126
|
+
const tone = outcome === "failed" ? "error" : "info";
|
|
137127
|
+
const dispatched = yield* engine.dispatch({
|
|
137128
|
+
type: "thread.activity.append",
|
|
137129
|
+
commandId: CommandId.make(yield* crypto.randomUUIDv4.pipe(Effect.orDie)),
|
|
137130
|
+
threadId: invocation.threadId,
|
|
137131
|
+
createdAt,
|
|
137132
|
+
activity: {
|
|
137133
|
+
id: evidenceReportActivityId(input.threadId, input.throughSequence),
|
|
137089
137134
|
createdAt,
|
|
137090
|
-
|
|
137091
|
-
|
|
137092
|
-
|
|
137093
|
-
|
|
137094
|
-
|
|
137095
|
-
|
|
137096
|
-
|
|
137097
|
-
|
|
137098
|
-
|
|
137099
|
-
|
|
137100
|
-
|
|
137101
|
-
|
|
137102
|
-
|
|
137103
|
-
|
|
137104
|
-
|
|
137105
|
-
|
|
137106
|
-
|
|
137107
|
-
|
|
137108
|
-
|
|
137109
|
-
|
|
137110
|
-
|
|
137111
|
-
|
|
137112
|
-
|
|
137113
|
-
|
|
137114
|
-
|
|
137135
|
+
tone,
|
|
137136
|
+
kind: "fusion.evidence.summary",
|
|
137137
|
+
summary: REPORT_HEADING[outcome],
|
|
137138
|
+
turnId: null,
|
|
137139
|
+
payload
|
|
137140
|
+
}
|
|
137141
|
+
}).pipe(Effect.as(true), Effect.catchCause((cause) => Effect.logWarning("could not record the supervisor's evidence report", {
|
|
137142
|
+
readerThreadId: invocation.threadId,
|
|
137143
|
+
watchedThreadId: input.threadId,
|
|
137144
|
+
cause
|
|
137145
|
+
}).pipe(Effect.as(false))));
|
|
137146
|
+
const paired = dispatched && input.threadId !== invocation.threadId ? yield* watchesAsFusionSupervisor(invocation.threadId, input.threadId).pipe(Effect.catchCause((cause) => Effect.logWarning("could not tell whether this reader is the builder's supervisor", {
|
|
137147
|
+
readerThreadId: invocation.threadId,
|
|
137148
|
+
watchedThreadId: input.threadId,
|
|
137149
|
+
cause
|
|
137150
|
+
}).pipe(Effect.as(null)))) : false;
|
|
137151
|
+
const mirrored = paired ? yield* engine.dispatch({
|
|
137152
|
+
type: "thread.activity.append",
|
|
137153
|
+
commandId: CommandId.make(yield* crypto.randomUUIDv4.pipe(Effect.orDie)),
|
|
137154
|
+
threadId: input.threadId,
|
|
137155
|
+
createdAt,
|
|
137156
|
+
activity: {
|
|
137157
|
+
id: evidenceReportMirrorActivityId(input.threadId, input.throughSequence),
|
|
137158
|
+
createdAt,
|
|
137159
|
+
tone,
|
|
137160
|
+
kind: "fusion.evidence.summary",
|
|
137161
|
+
summary: REPORT_HEADING[outcome],
|
|
137162
|
+
turnId: null,
|
|
137163
|
+
payload
|
|
137164
|
+
}
|
|
137165
|
+
}).pipe(Effect.as(true), Effect.catchCause((cause) => Effect.logWarning("could not mirror the evidence report to the builder", {
|
|
137166
|
+
readerThreadId: invocation.threadId,
|
|
137167
|
+
watchedThreadId: input.threadId,
|
|
137168
|
+
cause
|
|
137169
|
+
}).pipe(Effect.as(false)))) : paired === false;
|
|
137170
|
+
return {
|
|
137171
|
+
recorded: dispatched && mirrored,
|
|
137115
137172
|
context
|
|
137116
137173
|
};
|
|
137117
137174
|
}),
|
|
@@ -137126,7 +137183,7 @@ const WatchToolkitHandlersLive = WatchToolkit.toLayer({
|
|
|
137126
137183
|
detail: cause.message
|
|
137127
137184
|
})));
|
|
137128
137185
|
const lastSequence = page.events.at(-1)?.sequence;
|
|
137129
|
-
if (lastSequence !== void 0 && (yield* watchesAsFusionSupervisor(invocation.threadId, input.threadId))) {
|
|
137186
|
+
if (lastSequence !== void 0 && (yield* watchesAsFusionSupervisor(invocation.threadId, input.threadId).pipe(Effect.orElseSucceed(() => false)))) {
|
|
137130
137187
|
const projections = yield* ProjectionSnapshotQuery;
|
|
137131
137188
|
const turnId = yield* projections.getActiveTurnId(invocation.threadId).pipe(Effect.orElseSucceed(() => Option.none()), Effect.map(Option.getOrNull));
|
|
137132
137189
|
if (turnId !== null) {
|
|
@@ -142794,6 +142851,7 @@ function describeHandoffEvent(event, implementerThreadId, clip) {
|
|
|
142794
142851
|
if (event.payload.threadId !== implementerThreadId) return null;
|
|
142795
142852
|
const activity = event.payload.activity;
|
|
142796
142853
|
if (NON_EVIDENCE_ACTIVITY_KINDS.has(activity.kind)) return null;
|
|
142854
|
+
if (isEvidenceReportMirrorActivityId(activity.id)) return null;
|
|
142797
142855
|
const payload = asRecord(activity.payload);
|
|
142798
142856
|
const parts = [`#${event.sequence} ${activity.kind}`];
|
|
142799
142857
|
const summary = clip(activity.summary);
|
|
@@ -144119,6 +144177,7 @@ const make$3 = Effect.gen(function* () {
|
|
|
144119
144177
|
preparedAt: input.preparedAt,
|
|
144120
144178
|
sentAt: input.sentAt,
|
|
144121
144179
|
contextAtRead: input.contextAtRead,
|
|
144180
|
+
summary: handoff?.summary ?? null,
|
|
144122
144181
|
agentName: handoff?.agentName ?? null,
|
|
144123
144182
|
requestedModel: handoff?.requestedModel ?? null,
|
|
144124
144183
|
acknowledgedModel: handoff?.acknowledgedModel ?? null,
|
|
@@ -144731,7 +144790,7 @@ const make$3 = Effect.gen(function* () {
|
|
|
144731
144790
|
...completion.payload.turnId === null ? {} : { fallbackReadActivityId: rawEvidenceReadActivityId(latest.watchedThreadId, completion.payload.turnId) },
|
|
144732
144791
|
closedAt: completion.occurredAt
|
|
144733
144792
|
});
|
|
144734
|
-
|
|
144793
|
+
const receipt = yield* orchestrationEngine.dispatch({
|
|
144735
144794
|
type: "thread.activity.append",
|
|
144736
144795
|
commandId: CommandId.make(`server:fusion:${pair.id}:evidence-unreported:${latest.throughSequence}`),
|
|
144737
144796
|
threadId: pair.watcherThreadId,
|
|
@@ -144756,7 +144815,38 @@ const make$3 = Effect.gen(function* () {
|
|
|
144756
144815
|
timing
|
|
144757
144816
|
}
|
|
144758
144817
|
}
|
|
144759
|
-
})
|
|
144818
|
+
});
|
|
144819
|
+
yield* orchestrationEngine.dispatch({
|
|
144820
|
+
type: "thread.activity.append",
|
|
144821
|
+
commandId: CommandId.make(`server:fusion:${pair.id}:evidence-unreported-builder:${latest.throughSequence}`),
|
|
144822
|
+
threadId: latest.watchedThreadId,
|
|
144823
|
+
createdAt: completion.occurredAt,
|
|
144824
|
+
activity: {
|
|
144825
|
+
id: evidenceReportMirrorActivityId(latest.watchedThreadId, latest.throughSequence),
|
|
144826
|
+
createdAt: completion.occurredAt,
|
|
144827
|
+
tone: "error",
|
|
144828
|
+
kind: "fusion.evidence.summary",
|
|
144829
|
+
summary: "Evidence never reported",
|
|
144830
|
+
turnId: null,
|
|
144831
|
+
payload: {
|
|
144832
|
+
watchedThreadId: latest.watchedThreadId,
|
|
144833
|
+
firstSequence: evidenceWindowFirstSequence(latest),
|
|
144834
|
+
lastSequence: latest.throughSequence,
|
|
144835
|
+
throughSequence: latest.throughSequence,
|
|
144836
|
+
outcome: "unreported",
|
|
144837
|
+
summary: null,
|
|
144838
|
+
model: null,
|
|
144839
|
+
reason: "the supervisor ended its turn without reporting on the evidence it read",
|
|
144840
|
+
context,
|
|
144841
|
+
timing
|
|
144842
|
+
}
|
|
144843
|
+
}
|
|
144844
|
+
}).pipe(Effect.catchCause((cause) => Effect.logWarning("could not mirror the unreported evidence row to the builder", {
|
|
144845
|
+
watchedThreadId: latest.watchedThreadId,
|
|
144846
|
+
throughSequence: latest.throughSequence,
|
|
144847
|
+
cause
|
|
144848
|
+
})));
|
|
144849
|
+
return receipt.sequence;
|
|
144760
144850
|
});
|
|
144761
144851
|
/**
|
|
144762
144852
|
* Gives one omitted report one exact, persisted repair turn.
|
|
@@ -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{Ba as i,Dt as a,Ia as o,Ja as s,Ka as c,Ll as ee,Na as te,Sn as l,Va as u,Wr as d,Wu as f,Xa as p,Xr as ne,Ya as re,_t as m,_u as ie,b as h,ct as g,du as _,eu as v,fl as y,gt as b,h as x,hl as S,ml as C,ou as ae,pl as w,qa as T,vn as E,yt as D,zr as oe}from"./previewAssetResource-x8WpJWsS.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-
|
|
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{Ba as i,Dt as a,Ia as o,Ja as s,Ka as c,Ll as ee,Na as te,Sn as l,Va as u,Wr as d,Wu as f,Xa as p,Xr as ne,Ya as re,_t as m,_u as ie,b as h,ct as g,du as _,eu as v,fl as y,gt as b,h as x,hl as S,ml as C,ou as ae,pl as w,qa as T,vn as E,yt as D,zr as oe}from"./previewAssetResource-x8WpJWsS.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-BhSZjDjQ.js";import{A as le,Fr as ue,J as de,Lr as fe,M as P,Mr as pe,Nr as me,Rr as he,Y as ge,_ as _e,_r as ve,cr as ye,ct as be,dr as xe,dt as Se,fr as Ce,ft as we,h as Te,hr as Ee,j as De,jr as Oe,k as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,si as Ie,sr as Le,st as Re,ur as ze,ut as Be,yr as Ve}from"./index-M38Rayrc.js";import{a as He,n as Ue}from"./fileCommentAnnotations-Dh9DiTM4.js";var We=S(`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}g.getState().openFile(e,t);return}r(n?x(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Ee(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:ee}=e,te=oe(Qe),l=oe(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let f=oe(u),[p,re]=(0,F.useState)(null),[m,ie]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Ze)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==m||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==m||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ne(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=m?.fileKey===i?[...o,m.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Re(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=m,t[10]=f,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=m,t[5]=n,t[6]=f,t[7]=r,t[8]=_}else _=t[8];let v=_,y;t[13]!==a||t[14]!==m?.annotation||t[15]!==l?(y=e=>{re(null),m?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):l(a,e)},t[13]=a,t[14]=m?.annotation,t[15]=l,t[16]=y):y=t[16];let b=y,x;t[17]!==te||t[18]!==a||t[19]!==m||t[20]!==g||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=m?.annotation.metadata.entries.find(t=>t.id===e),o=m?g.get(m.fileKey):void 0;if(!n||!o)return;let s=d({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&te(a,s),re(null),ie(null)},t[17]=te,t[18]=a,t[19]=m,t[20]=g,t[21]=r,t[22]=i,t[23]=x):x=t[23];let S=x,C;t[24]!==g||t[25]!==r||t[26]!==i?(C=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=g.get(n.id);if(!a)return;let o=Ue(),s=d({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=g,t[25]=r,t[26]=i,t[27]=C):C=t[27];let ae=C,w=m!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let D=!w,se=!w,k;t[32]!==ae||t[33]!==o||t[34]!==se||t[35]!==D?(k={...o,enableGutterUtility:D,enableLineSelection:se,onLineSelectionEnd:ae},t[32]=ae,t[33]=o,t[34]=se,t[35]=D,t[36]=k):k=t[36];let A;t[37]===ee?A=t[38]:(A=e=>e.type===`diff`?ee(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=ee,t[38]=A);let j;t[39]!==b||t[40]!==S?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>b(e.id),onComment:t=>S(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=S,t[41]=j):j=t[41];let M;return t[42]!==v||t[43]!==p||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(O,{...T,...E,items:v,selectedLines:p,onSelectedLinesChange:re,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=v,t[43]=p,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:v(e,{label:`environment-data:review:diff-preview`,tag:f.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:l}=h(),d=ue(),[f]=(0,F.useState)(n),[ne,g]=(0,F.useState)(`stacked`),[v,x]=(0,F.useState)(d.wordWrap),[S,oe]=(0,F.useState)(d.diffIgnoreWhitespace),[O,_e]=(0,F.useState)(``),[Ee,Re]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=me(r),qe=I?.projectId??null,Je=pe(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=ee(E.configValueAtom(I?.environmentId??null)),Xe=ve(I?.environmentId??null,z?.availableEditors??[]),Ze=a(I!=null&&R!=null?Oe.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>De(e.byThreadKey,r,f===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=le(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=Ee.scopeKey===Y?Ee.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:S,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=a(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=a(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:S}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=a(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),vt=a(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...O.trim().length>0?{query:O.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,O),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...O.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>Be(Tt,`diff-panel:${l}`,{compactPartialHunkOffsets:W===null}),[l,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>we(e).localeCompare(we(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Pe(e);return{fileDiff:e,filePath:we(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)(()=>je(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=ke({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`&&!ae(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ie(_(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Re(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)(()=>{Re(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)(ge,{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)(re,{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)(w,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(u,{align:`start`,className:`w-60`,children:[(0,L.jsx)(i,{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)(i,{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)(i,{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)(c,{children:[(0,L.jsx)(s,{children:`Turn`}),(0,L.jsx)(T,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(i,{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,d.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)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||_e(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ce,{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)(w,{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)(he,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(ye,{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=>_e(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)(Le,{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)(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)(C,{"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)(Te,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(te,{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)(m,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[ne],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&g(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)(D,{render:(0,L.jsx)(N,{"aria-label":v?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:v,onPressedChange:e=>{x(!!e)}}),children:(0,L.jsx)(fe,{className:`size-3`})}),(0,L.jsx)(m,{side:`top`,children:v?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(N,{"aria-label":S?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:S,onPressedChange:e=>{oe(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(m,{side:`top`,children:S?`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=we(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(D,{render:(0,L.jsx)(`button`,{type:`button`,className:p(`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`,be(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(y,{className:`size-4`}):(0,L.jsx)(w,{className:`size-4`})}),(0,L.jsx)(m,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:ne===`split`?`split`:`unified`,lineDiffType:`none`,overflow:v?`wrap`:`scroll`,theme:Se(l),themeType:l,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:p(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,v?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(de,{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{_e as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-
|
|
98
|
+
//# sourceMappingURL=DiffPanel-J-OdKLva.js.map
|