@pi-chamber/web 1.0.4-rc.1 → 1.0.4-rc.2
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/assets/{DiagramView-DfZMQkXY.js → DiagramView-GKGxPczP.js} +1 -1
- package/dist/assets/{DiffView-BjWUdbL5.js → DiffView-Cay8VAqL.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-u5L4k_5k.js → FileSaveConflictDialog-BRM9TJo0.js} +1 -1
- package/dist/assets/{FilesView-qP1ypN9J.js → FilesView-CEeQzjc6.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-zCKCy5OJ.js → GitHubDetailScaffold-q4YP8iyJ.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-CwxKY3lN.js → GitHubLinkPicker-B9xgIW8y.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-Ck3zllel.js → GitHubListPrimitives-XkALat1v.js} +1 -1
- package/dist/assets/{GitView-y2k2i4gR.js → GitView-DV3d0oSJ.js} +3 -3
- package/dist/assets/{IssuesSurface-HWgR87N3.js → IssuesSurface-OTyt9f3A.js} +3 -3
- package/dist/assets/{JsonTreeView-DSuC4naV.js → JsonTreeView-X2Auiy_q.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-CT5ln9em.js → MarkdownRendererImpl-1HameF6j.js} +12 -12
- package/dist/assets/{PatchDiff-DArTeWeK.js → PatchDiff-GMQAv4en.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DQKujzLb.js → PierreDiffViewer-0X__nypk.js} +2 -2
- package/dist/assets/PullRequestsSurface-Dec20SIg.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DEGJyZBl.js → SessionSwitcherContent-DEw4nz7K.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-cC9wVBH7.js → SessionSwitcherDropdown-DmLhbRzE.js} +2 -2
- package/dist/assets/SessionUnreadDot-CJFawQpo.js +1 -0
- package/dist/assets/SettingsView-CwSspvq-.js +6 -0
- package/dist/assets/{SettingsWindow-CZM1dmVb.js → SettingsWindow-DkPv9MaU.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DClOSbJc.js → ToolOutputDialog-DDwbOpTO.js} +3 -3
- package/dist/assets/{ToolPartDiffPreview-BaFiGUDE.js → ToolPartDiffPreview-DZRP7p-Q.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-D6KbvKc6.js → VirtualizedFileDiff-CUWx7JVZ.js} +1 -1
- package/dist/assets/{collapsible-DhV9d4dT.js → collapsible-Ce85nuXX.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CeMpF2xC.js → computeVirtualFileMetrics-3PpRLd5B.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-Ck5u_kAP.js → contextFileOpenGuard-PoBklHMz.js} +1 -1
- package/dist/assets/{gitStatusPredicates-DEBSqUNE.js → gitStatusPredicates-BvzxqidP.js} +1 -1
- package/dist/assets/{githubLink-DT7i2NlH.js → githubLink-iQ51wqRa.js} +1 -1
- package/dist/assets/{index-eDf4LKLY.js → index-CkMnC_GK.js} +1 -1
- package/dist/assets/{index-6IO1AcJI.js → index-Dd2OcIUY.js} +9 -9
- package/dist/assets/index-DvN8zlLT.css +1 -0
- package/dist/assets/{main-BczEScAA.js → main-FasHq7Ck.js} +2 -2
- package/dist/assets/{main-CHLNMYeJ.js → main-PSCt716b.js} +8 -8
- package/dist/assets/{markdownCore-C4Gk5Zht.js → markdownCore-BH56o6Wu.js} +1 -1
- package/dist/assets/{miniChat-Do3hE87Z.js → miniChat-BzfobBDq.js} +2 -2
- package/dist/assets/{mobile-CTnihwfa.js → mobile-DAzZE2EL.js} +2 -2
- package/dist/assets/{pi-session-focus-preference-LDVCJ_YR.js → pi-session-focus-preference-D2-1HWmY.js} +3 -3
- package/dist/assets/{renderDiffWithHighlighter-CDsgOnkH.js → renderDiffWithHighlighter-l8hZWWBO.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DSa3gYqR.js → renderElectronMiniChatApp-DGYSIihR.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-TpKRyfCY.js → renderFileWithHighlighter-BvDoP7ob.js} +1 -1
- package/dist/assets/renderMobileApp-CwgWG0lU.js +11 -0
- package/dist/assets/runtimeEndpointReset-CmI6dBKM.js +62 -0
- package/dist/assets/{runtimeSurface-DW_Ia4q3.js → runtimeSurface-B1GRkkKC.js} +1 -1
- package/dist/assets/{useAppFontEffects-CG3_yteE.js → useAppFontEffects--lKKtKVo.js} +62 -62
- package/dist/assets/{useFilesViewSearch-C_LzYIgD.js → useFilesViewSearch-D1jsGQrN.js} +3 -3
- package/dist/assets/{useGitHubRemoteSearch-DsxWOzKZ.js → useGitHubRemoteSearch-zNgy2bSt.js} +1 -1
- package/dist/assets/{useSwitcherItems-BmoCnS9W.js → useSwitcherItems-OCRYcHeu.js} +1 -1
- package/dist/assets/{web-components-CH3-XV-n.js → web-components-v9fuidaX.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +21 -8
- package/server/lib/pi/session-daemon/builtin-extensions.js +37 -0
- package/server/lib/pi/session-daemon/daemon-process.js +6 -0
- package/server/lib/pi/session-daemon/extension-theme.js +75 -0
- package/server/lib/pi/session-daemon/extension-theme.test.js +47 -0
- package/server/lib/pi/session-daemon/prompt-operations.test.js +3 -3
- package/server/lib/pi/session-daemon/prompt-preflight.test.js +12 -14
- package/server/lib/pi/session-daemon/sdk-upgrade.test.js +118 -2
- package/server/lib/pi/session-daemon/send-operation-dedup.test.js +1 -1
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +1 -1
- package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +638 -0
- package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +437 -0
- package/server/lib/pi/session-daemon/session-daemon.js +61 -42
- package/server/lib/pi/session-daemon/session-daemon.test.js +53 -5
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +1 -1
- package/server/lib/pi/session-daemon/session-replay.test.js +1 -1
- package/server/lib/pi/session-persistence-gap.test.js +2 -3
- package/server/lib/pi/ui-settings-store.js +1 -0
- package/server/lib/pi/ui-settings-store.test.js +27 -0
- package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +0 -2
- package/dist/assets/SessionUnreadDot-CELKNVIM.js +0 -1
- package/dist/assets/SettingsView-CZvRRgJe.js +0 -6
- package/dist/assets/index-BAmzAlNx.css +0 -1
- package/dist/assets/renderMobileApp-CPE-3uMl.js +0 -11
- package/dist/assets/runtimeEndpointReset-CzJfovWI.js +0 -62
|
@@ -68,7 +68,7 @@ class FakeSession {
|
|
|
68
68
|
|
|
69
69
|
async prompt(text, options) {
|
|
70
70
|
this.promptCalls.push({ text, options });
|
|
71
|
-
options?.preflightResult?.(
|
|
71
|
+
options?.preflightResult?.('started');
|
|
72
72
|
const deliverAs = options?.streamingBehavior;
|
|
73
73
|
this.sent.push({ text, options: deliverAs ? { deliverAs } : undefined });
|
|
74
74
|
}
|
|
@@ -2594,6 +2594,54 @@ describe('Pi session daemon spike', () => {
|
|
|
2594
2594
|
await client.close();
|
|
2595
2595
|
});
|
|
2596
2596
|
|
|
2597
|
+
it('skips publishing tool execution events for nested tool calls carrying parentToolCallId', async () => {
|
|
2598
|
+
const root = await mkdtemp(join(tmpdir(), 'pichamber-pi-daemon-nested-tool-'));
|
|
2599
|
+
const endpoint = testDaemonEndpoint(root);
|
|
2600
|
+
const session = new FakeSession('pi-session-nested-tool');
|
|
2601
|
+
daemon = createSessionDaemon({ endpoint, credential, cwd: root, createRuntime: async () => ({ session, async dispose() {} }) });
|
|
2602
|
+
await daemon.start();
|
|
2603
|
+
const client = connectClient(endpoint);
|
|
2604
|
+
await client.authenticate();
|
|
2605
|
+
await client.request('sessions.create', { cwd: root });
|
|
2606
|
+
|
|
2607
|
+
const parentToolStartPromise = client.next((frame) => frame.event === 'session.tool.start' && frame.payload?.partId?.includes('parent-call'));
|
|
2608
|
+
const parentToolEndPromise = client.next((frame) => frame.event === 'session.tool.end' && frame.payload?.partId?.includes('parent-call'));
|
|
2609
|
+
const unexpectedNestedEvent = client.next((frame) =>
|
|
2610
|
+
(frame.event === 'session.tool.start' || frame.event === 'session.tool.delta' || frame.event === 'session.tool.end')
|
|
2611
|
+
&& frame.payload?.partId?.includes('nested-call'),
|
|
2612
|
+
);
|
|
2613
|
+
|
|
2614
|
+
session.emit({ type: 'message_start', message: { role: 'user', content: 'run tool', timestamp: 0 } });
|
|
2615
|
+
session.emit({ type: 'message_start', message: { role: 'assistant', timestamp: 1 } });
|
|
2616
|
+
session.emit({
|
|
2617
|
+
type: 'message_end',
|
|
2618
|
+
message: {
|
|
2619
|
+
role: 'assistant',
|
|
2620
|
+
content: [
|
|
2621
|
+
{ type: 'toolCall', id: 'parent-call', name: 'parent_tool', arguments: {} },
|
|
2622
|
+
],
|
|
2623
|
+
},
|
|
2624
|
+
});
|
|
2625
|
+
|
|
2626
|
+
// Parent tool starts
|
|
2627
|
+
session.emit({ type: 'tool_execution_start', toolCallId: 'parent-call', toolName: 'parent_tool', args: {} });
|
|
2628
|
+
|
|
2629
|
+
// Nested tool events with parentToolCallId
|
|
2630
|
+
session.emit({ type: 'tool_execution_start', toolCallId: 'nested-call', parentToolCallId: 'parent-call', toolName: 'nested_tool', args: {} });
|
|
2631
|
+
session.emit({ type: 'tool_execution_update', toolCallId: 'nested-call', parentToolCallId: 'parent-call', toolName: 'nested_tool', delta: 'nested output' });
|
|
2632
|
+
session.emit({ type: 'tool_execution_end', toolCallId: 'nested-call', parentToolCallId: 'parent-call', toolName: 'nested_tool', result: { content: [{ type: 'text', text: 'nested done' }] } });
|
|
2633
|
+
|
|
2634
|
+
// Parent tool ends
|
|
2635
|
+
session.emit({ type: 'tool_execution_end', toolCallId: 'parent-call', toolName: 'parent_tool', result: { content: [{ type: 'text', text: 'parent done' }] } });
|
|
2636
|
+
|
|
2637
|
+
await expect(parentToolStartPromise).resolves.toBeDefined();
|
|
2638
|
+
await expect(parentToolEndPromise).resolves.toBeDefined();
|
|
2639
|
+
await expect(unexpectedNestedEvent).rejects.toThrow(/Timed out/);
|
|
2640
|
+
|
|
2641
|
+
session.emit({ type: 'agent_settled' });
|
|
2642
|
+
await client.close();
|
|
2643
|
+
});
|
|
2644
|
+
|
|
2597
2645
|
it('rejects non-local endpoints and unauthenticated clients before a request can reach the runtime', async () => {
|
|
2598
2646
|
expect(() => createSessionDaemon({
|
|
2599
2647
|
endpoint: 'http://127.0.0.1:3000',
|
|
@@ -2817,7 +2865,7 @@ describe('Pi session daemon spike', () => {
|
|
|
2817
2865
|
let finishTurn;
|
|
2818
2866
|
session.prompt = (text, options) => {
|
|
2819
2867
|
session.promptCalls.push({ text, options });
|
|
2820
|
-
options?.preflightResult?.(
|
|
2868
|
+
options?.preflightResult?.('started');
|
|
2821
2869
|
const deliverAs = options?.streamingBehavior;
|
|
2822
2870
|
session.sent.push({ text, options: deliverAs ? { deliverAs } : undefined });
|
|
2823
2871
|
return new Promise((resolve) => {
|
|
@@ -2860,7 +2908,7 @@ describe('Pi session daemon spike', () => {
|
|
|
2860
2908
|
const finishSends = [];
|
|
2861
2909
|
session.prompt = (text, options) => {
|
|
2862
2910
|
session.promptCalls.push({ text, options });
|
|
2863
|
-
options?.preflightResult?.(
|
|
2911
|
+
options?.preflightResult?.('started');
|
|
2864
2912
|
const deliverAs = options?.streamingBehavior;
|
|
2865
2913
|
session.sent.push({ text, options: deliverAs ? { deliverAs } : undefined });
|
|
2866
2914
|
return new Promise((resolve) => finishSends.push(resolve));
|
|
@@ -2968,7 +3016,7 @@ describe('Pi session daemon spike', () => {
|
|
|
2968
3016
|
let sendCount = 0;
|
|
2969
3017
|
session.prompt = (text, options) => {
|
|
2970
3018
|
session.promptCalls.push({ text, options });
|
|
2971
|
-
options?.preflightResult?.(
|
|
3019
|
+
options?.preflightResult?.('started');
|
|
2972
3020
|
session.sent.push({ text, options: options?.streamingBehavior ? { deliverAs: options.streamingBehavior } : undefined });
|
|
2973
3021
|
sendCount += 1;
|
|
2974
3022
|
if (sendCount === 1) return new Promise((_, reject) => { rejectFirst = reject; });
|
|
@@ -3003,7 +3051,7 @@ describe('Pi session daemon spike', () => {
|
|
|
3003
3051
|
const session = new FakeSession('session-1', sessionFile);
|
|
3004
3052
|
session.prompt = (text, options) => {
|
|
3005
3053
|
session.promptCalls.push({ text, options });
|
|
3006
|
-
options?.preflightResult?.(
|
|
3054
|
+
options?.preflightResult?.('started');
|
|
3007
3055
|
session.sent.push({ text, options: options?.streamingBehavior ? { deliverAs: options.streamingBehavior } : undefined });
|
|
3008
3056
|
session.isStreaming = true;
|
|
3009
3057
|
return Promise.reject(new Error('Stream ended without finish_reason'));
|
|
@@ -88,7 +88,7 @@ class FakeSession {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
async prompt(text, options) {
|
|
91
|
-
options?.preflightResult?.(
|
|
91
|
+
options?.preflightResult?.('started');
|
|
92
92
|
const deliverAs = options?.streamingBehavior;
|
|
93
93
|
this.sent.push({ text, options: deliverAs ? { deliverAs } : undefined });
|
|
94
94
|
if (this.pendingSend) {
|
|
@@ -36,7 +36,7 @@ import { resolveSessionLeaseFile } from './session-daemon/session-lease.js';
|
|
|
36
36
|
*
|
|
37
37
|
* Seam notes (existing injection only, no new DI):
|
|
38
38
|
* - `createRuntime` fakes Pi's session surface so prompt rejection
|
|
39
|
-
* (
|
|
39
|
+
* (prompt error + `INVALID_MODEL`) exercises the real daemon
|
|
40
40
|
* idle-disposal and event path against temp dirs.
|
|
41
41
|
* - One-request-per-connection IPC (like production `requestSessionDaemon`)
|
|
42
42
|
* so prompt rejections resolve as error frames with preserved codes.
|
|
@@ -235,10 +235,9 @@ class FakeSession {
|
|
|
235
235
|
async prompt(text, options) {
|
|
236
236
|
this.promptCalls += 1;
|
|
237
237
|
if (this.rejectPrompt) {
|
|
238
|
-
options?.preflightResult?.(false);
|
|
239
238
|
throw rejectedPromptError();
|
|
240
239
|
}
|
|
241
|
-
options?.preflightResult?.(
|
|
240
|
+
options?.preflightResult?.('started');
|
|
242
241
|
}
|
|
243
242
|
|
|
244
243
|
async navigateTree() {
|
|
@@ -37,6 +37,7 @@ const PORTABLE_FIELDS = new Set([
|
|
|
37
37
|
'zenModel', 'gitProviderId', 'gitModelId',
|
|
38
38
|
'timeFormatPreference',
|
|
39
39
|
'weekStartPreference',
|
|
40
|
+
'sidebarViewMode',
|
|
40
41
|
'expandedEditorToolbar',
|
|
41
42
|
'fontSize', 'terminalFontSize', 'editorFontSize', 'uiFont', 'monoFont', 'padding',
|
|
42
43
|
'cornerRadius', 'inputBarOffset', 'shortcutOverrides', 'commandTriggers',
|
|
@@ -238,6 +238,33 @@ describe('Pi UI settings store', () => {
|
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
|
|
241
|
+
it('persists sidebarViewMode in portable settings and drops unknown keys', async () => {
|
|
242
|
+
const { file, runtimeFile, store } = await makeStore();
|
|
243
|
+
|
|
244
|
+
const writeResult = await store.write({ sidebarViewMode: 'folder', unknownField: 'drop-me' });
|
|
245
|
+
expect(writeResult).toEqual({ sidebarViewMode: 'folder' });
|
|
246
|
+
|
|
247
|
+
const readResult = await store.read();
|
|
248
|
+
expect(readResult).toEqual({ sidebarViewMode: 'folder' });
|
|
249
|
+
|
|
250
|
+
const portable = await readJson(file);
|
|
251
|
+
expect(portable).toEqual({
|
|
252
|
+
__pichamberSettingsScope: 'portable-v1',
|
|
253
|
+
sidebarViewMode: 'folder',
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const runtime = await readJson(runtimeFile);
|
|
257
|
+
expect(runtime).toEqual({});
|
|
258
|
+
|
|
259
|
+
const updatedResult = await store.write({ sidebarViewMode: 'timeline' });
|
|
260
|
+
expect(updatedResult).toEqual({ sidebarViewMode: 'timeline' });
|
|
261
|
+
expect(await store.read()).toEqual({ sidebarViewMode: 'timeline' });
|
|
262
|
+
expect(await readJson(file)).toEqual({
|
|
263
|
+
__pichamberSettingsScope: 'portable-v1',
|
|
264
|
+
sidebarViewMode: 'timeline',
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
241
268
|
it('preserves failure behavior for malformed and oversized payloads', async () => {
|
|
242
269
|
const { file, store } = await makeStore();
|
|
243
270
|
await writeFile(file, '{broken');
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/useAppFontEffects-CG3_yteE.js","assets/index-6IO1AcJI.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BAmzAlNx.css","assets/vendor-boot-DyL2td56.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/runtimeSurface-DW_Ia4q3.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Ne}from"./vendor-vite-runtime-DD1OZmLC.js";import{j as e,bR as Ye,bS as Qe,bT as Xe,bU as Ze,bV as et}from"./vendor-boot-DyL2td56.js";import{R as o}from"./vendor-react-DASdDPIk.js";import{u as le,a as Le,b as ht,c as ft,G as xt,d as pt,e as gt,f as bt,r as vt,g as tt,t as yt,h as ce,i as jt,j as wt,k as kt,l as Ct,m as Nt,n as St,o as Rt}from"./useGitHubRemoteSearch-DsxWOzKZ.js";import{p as Ee,t as H,a5 as Lt,B as P,I as z,b3 as Et,ai as st,a8 as Me,ab as ze,ad as Ae,cu as Ft,cv as Pt,o as Se,af as we,ag as Tt,n as Mt}from"./useAppFontEffects-CG3_yteE.js";import{P as O,Z as zt,_ as At,Q as Dt,$ as $t,a0 as Gt,a1 as Ht,a2 as qt,a3 as It,a4 as De,a5 as Ot,a6 as Bt,a7 as _t,a8 as Ut,a9 as Vt,aa as Kt,ab as Jt,ac as Wt}from"./runtimeEndpointReset-CzJfovWI.js";import{c as Yt,d as Qt,s as Xt,m as Zt,g as nt,e as es,f as ts,h as ge,l as ss,G as ns,i as te,j as as,k as ls,n as os,o as is,b as fe,u as rs,p as cs,q as ds,r as us,t as $e,w as ke,x as Ce,y as ms,z as Ge,A as He,B as qe,C as at,D as hs,E as Ie,F as fs,H as xs,I as ps,J as gs,K as bs,P as be,L as he,M as vs,a as ys,N as Oe,O as js,Q as ws}from"./GitHubDetailScaffold-zCKCy5OJ.js";import{o as xe,aP as ks,A as Cs,t as Ns,v as Ss}from"./index-6IO1AcJI.js";import{S as ve,G as Rs}from"./GitHubListPrimitives-Ck3zllel.js";import{P as Ls}from"./PierreDiffViewer-DQKujzLb.js";import{c as Es,p as Fs}from"./vendor-zustand-CUi8eEds.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-DW_Ia4q3.js";import"./SessionUnreadDot-CELKNVIM.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./vendor-dompurify-r8glNMJW.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-CH3-XV-n.js";import"./computeVirtualFileMetrics-CeMpF2xC.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./VirtualizedFileDiff-D6KbvKc6.js";import"./renderDiffWithHighlighter-CDsgOnkH.js";import"./vendor-diff-C3JhlQdm.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";const Fe=()=>{const t=Ee(),[s,n]=o.useState(null);return{send:o.useCallback(async l=>{const d=t.github;if(!d)return H.error("GitHub is not available in this runtime"),!1;n(l.key);try{const c=await d.agentContext(l.directory,l.repo,l.contextType,l.number,l.contextOptions),r=Yt({kind:l.kind,repo:l.repo,number:l.number,detail:l.detail}),x=Qt({kind:l.kind,repo:l.repo,number:l.number,contextText:c.text}),p=Lt.getState();p.setPendingInputText(r,"append");const k=p.pendingSyntheticParts??[];return p.setPendingSyntheticParts([...k,{text:x,synthetic:!0}]),H.success("Added to composer"),!0}catch(c){return H.error(c instanceof Error?c.message:"Failed to fetch GitHub context"),!1}finally{n(null)}},[t.github]),sendingKey:s}},Ps=800,Ts=3,Pe={added:{icon:"add-circle",letter:"A",tint:"text-[var(--status-success)]"},removed:{icon:"subtract",letter:"D",tint:"text-[var(--status-error)]"},modified:{icon:"pencil",letter:"M",tint:"text-[var(--status-warning)]"},renamed:{icon:"expand-up-down",letter:"R",tint:"text-[var(--status-info)]"},other:{icon:"file",letter:"•",tint:"text-muted-foreground"}},lt=t=>{switch((t??"").toLowerCase()){case"added":return"added";case"removed":return"removed";case"modified":return"modified";case"renamed":return"renamed";default:return"other"}},ot=t=>Pe[t].icon,Ms=t=>Pe[t].letter,Re=t=>Pe[t].tint,it=t=>{const s=t.lastIndexOf("/");return s<0?{dir:"",base:t}:{dir:t.slice(0,s),base:t.slice(s+1)}},rt=t=>{const s=typeof t.additions=="number"?t.additions:0,n=typeof t.deletions=="number"?t.deletions:0;return s!==0||n!==0?s+n:typeof t.changes=="number"?t.changes:0},ct=t=>rt(t)>Ps,zs=t=>{const s=new Map;for(const a of t){const l=a.filename.lastIndexOf("/"),d=l<0?"":a.filename.slice(0,l),c=s.get(d);c?c.push(a):s.set(d,[a])}const n=[...s.entries()].map(([a,l])=>({folder:a,files:[...l].sort((d,c)=>d.filename.localeCompare(c.filename,void 0,{sensitivity:"base"}))}));return n.sort((a,l)=>a.folder===""?1:l.folder===""?-1:a.folder.localeCompare(l.folder,void 0,{sensitivity:"base"})),n},As=t=>{let s=0,n=0;for(const a of t)s+=typeof a.additions=="number"?a.additions:0,n+=typeof a.deletions=="number"?a.deletions:0;return{additions:s,deletions:n}},Ds=t=>{const s={};return t.forEach((n,a)=>{s[n.filename]=a>=Ts||ct(n)}),s},$s=(t,s,n)=>{if(!s)return null;const a=t.split("/");if(a.length!==3||a.some(r=>r.length===0))return null;const[l,d,c]=a;return`https://${l}/${d}/${c}/blob/${s}/${n}`},Gs=({comment:t,onRemove:s})=>e.jsxs("div",{className:"rounded-md border border-dashed border-border p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"chat-1",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{children:"Pending — sent when you submit the review"}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard this comment",title:"Discard this comment",onClick:s,className:"ml-auto size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})})]}),e.jsx("p",{className:"mt-1.5 whitespace-pre-wrap break-words",children:t.body})]}),Be=({thread:t,replyAllowed:s,replyDisabledReason:n,resolveAllowed:a,resolveDisabledReason:l,busy:d,onReply:c,onToggleResolved:r})=>{const[x,p]=o.useState(!t.resolved),[k,m]=o.useState(!1),[b,h]=o.useState(""),[A,F]=o.useState(!1),T=t.comments.length,j=async()=>{const g=b.trim();if(!(g.length===0||A||d)){F(!0);try{await c(g)&&(h(""),m(!1))}finally{F(!1)}}};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5 typography-ui text-foreground",contentEditable:!1,onPointerDown:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:t.resolved?"check":"chat-1",className:xe("size-3.5 shrink-0",t.resolved?"text-[var(--status-success)]":""),"aria-hidden":"true"}),e.jsxs("button",{type:"button",className:"hover:text-foreground","aria-expanded":x,onClick:()=>p(g=>!g),children:[t.resolved?"Resolved":"Open"," · ",T," ",T===1?"comment":"comments"]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:!a||d,title:l??(t.resolved?"Reopen this conversation":"Resolve this conversation"),"aria-label":t.resolved?"Reopen conversation":"Resolve conversation",onClick:r,children:t.resolved?"Unresolve":"Resolve"})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 flex flex-col gap-2",children:t.comments.map((g,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"typography-micro text-muted-foreground",children:g.author?.login??"ghost"}),e.jsx(ns,{markdown:g.body,html:g.bodyHtml??null,fallbackUrl:g.url})]},g.id??`${t.id}-${i}`))}),s?k?e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{autoFocus:!0,value:b,rows:2,placeholder:"Reply","aria-label":"Reply to this conversation",disabled:A||d,onChange:g=>h(g.target.value),onKeyDown:g=>{g.nativeEvent.isComposing||(g.key==="Escape"&&(g.preventDefault(),m(!1)),g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&!g.shiftKey&&!g.altKey&&!g.repeat&&(g.preventDefault(),g.stopPropagation(),j()))},className:"min-h-12 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex justify-end gap-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>m(!1),children:"Cancel"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:A||d||b.trim().length===0,onClick:()=>{j()},children:A?"Replying…":"Reply"})]})]}):e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"mt-2",onClick:()=>m(!0),children:"Reply"}):n?e.jsxs("p",{className:"mt-2 typography-micro text-muted-foreground",title:n,children:["Reply unavailable — ",n.charAt(0).toLowerCase()+n.slice(1)]}):null]}):null]})},Hs=({path:t,line:s,sendingToAgent:n,onCancel:a,onAddToReview:l,onSendToAgent:d})=>{const[c,r]=o.useState(""),x=o.useRef(null),p=c.trim();o.useLayoutEffect(()=>{const m=window.requestAnimationFrame(()=>{x.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(m)},[]);const k=()=>{p&&l(p)};return e.jsxs("div",{className:"rounded-md border border-border/60 bg-[var(--surface-elevated)] p-2.5",contentEditable:!1,onPointerDown:m=>m.stopPropagation(),children:[e.jsxs("p",{className:"truncate font-mono typography-micro text-muted-foreground",title:`${t}:${s}`,children:[t,":",s]}),e.jsx("textarea",{ref:x,value:c,rows:3,placeholder:"Add a comment…","aria-label":`Comment on ${t} line ${s}`,onChange:m=>r(m.target.value),onFocus:m=>{const b=m.currentTarget.value.length;m.currentTarget.setSelectionRange(b,b)},onKeyDown:m=>{m.nativeEvent.isComposing||(m.key==="Escape"&&(m.preventDefault(),a()),m.key==="Enter"&&(m.metaKey||m.ctrlKey)&&!m.shiftKey&&!m.altKey&&!m.repeat&&(m.preventDefault(),m.stopPropagation(),k()))},className:"mt-1.5 min-h-16 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"mr-auto typography-micro text-muted-foreground",children:"Ctrl/Cmd+Enter to add"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Cancel"}),e.jsx(P,{type:"button",variant:"outline",size:"xs",disabled:!p||n,title:"Send this line to the agent",onClick:()=>d(p),children:n?"Sending…":"Send to agent"}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:!p,onClick:k,children:"Add to review"})]})]})},qs=({file:t,collapsed:s,onToggleCollapse:n,viewed:a,onToggleViewed:l,blobUrl:d,threads:c,directory:r,repo:x,number:p,github:k,access:m,onThreadsChanged:b})=>{const h=O(w=>w.threadAction),A=le(w=>w.removeComment),F=le(w=>w.addComment),T=Le(x,p),[j,g]=o.useState(null),[i,C]=o.useState(!1),{send:L,sendingKey:f}=Fe(),{original:N,modified:E}=o.useMemo(()=>Xt(t.patch),[t.patch]),M=o.useMemo(()=>Zt(t.patch),[t.patch]),B=`pr-${p}-file-${t.filename}`,V=nt(m),S=es(m),$=ts(m),K=o.useCallback(w=>{if(!w||!V.allowed)return;const q=(w.endSide??w.side??"additions")==="deletions"?"deletions":"additions",ie=q==="deletions"?M.syntheticToOld.get(w.end):M.syntheticToNew.get(w.end);if(ie==null){H.error("That line is outside the rendered hunks");return}g({synthLine:w.end,side:q,realLine:ie,realSide:q==="deletions"?"LEFT":"RIGHT"})},[V.allowed,M]),_=lt(t.status),{dir:X,base:R}=it(t.filename),I=ct(t),[y,de]=o.useState(!1),Q=I&&!y&&!a&&t.patch!=null,ee=c.filter(w=>!w.resolved).length,Z=o.useMemo(()=>T.filter(w=>w.path===t.filename),[T,t.filename]),{annotations:se,orphans:ne}=o.useMemo(()=>{const w=new Map,G=[],q=(D,U)=>{const W=`${D}:${U}`;let J=w.get(W);return J||(J={side:D,synthLine:U,threads:[],pendings:[]},w.set(W,J)),J};for(const D of c){const U=D.line??D.originalLine??null;if(U==null){G.push(D);continue}let W,J;if(D.diffSide==="LEFT"?(J="deletions",W=M.oldToSynthetic.get(U)):D.diffSide==="RIGHT"?(J="additions",W=M.newToSynthetic.get(U)):(W=M.newToSynthetic.get(U),J="additions",W==null&&(W=M.oldToSynthetic.get(U),J="deletions")),W==null){G.push(D);continue}q(J,W).threads.push(D)}for(const D of Z){if(D.line==null)continue;const U=D.side==="LEFT"?"deletions":"additions",W=U==="deletions"?M.oldToSynthetic.get(D.line):M.newToSynthetic.get(D.line);W!=null&&q(U,W).pendings.push(D)}return j&&q(j.side,j.synthLine),{annotations:[...w.values()].sort((D,U)=>D.synthLine-U.synthLine).map(D=>({side:D.side,lineNumber:D.synthLine,metadata:{threads:D.threads,pendings:D.pendings,draft:j&&j.side===D.side&&j.synthLine===D.synthLine?{realLine:j.realLine,realSide:j.realSide}:null}})),orphans:G}},[c,Z,j,M]),oe=o.useCallback(async(w,G)=>{const q=w.comments[w.comments.length-1]?.id??null;if(typeof q!="number")return H.error("Cannot reply to this thread yet"),!1;if(i)return!1;C(!0);try{return(await h(r,x,p,w.id,{action:"reply",body:G,commentId:q},k)).ok?(H.success("Reply posted"),b(),!0):(H.error("Failed to post reply"),!1)}finally{C(!1)}},[r,x,p,k,h,i,b]),ae=o.useCallback(w=>{i||(C(!0),h(r,x,p,w.id,w.resolved?{action:"unresolve"}:{action:"resolve"},k).then(G=>{G.ok?(H.success(w.resolved?"Thread reopened":"Thread resolved"),b()):H.error("Failed to update thread")}).finally(()=>C(!1)))},[r,x,p,k,h,i,b]),ue=o.useCallback(w=>e.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",contentEditable:!1,onPointerDown:G=>G.stopPropagation(),children:[w.metadata.threads.map(G=>e.jsx(Be,{thread:G,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:q=>oe(G,q),onToggleResolved:()=>ae(G)},G.id)),w.metadata.pendings.map(G=>e.jsx(Gs,{comment:G,onRemove:()=>A(x,p,G.id)},G.id)),w.metadata.draft?e.jsx(Hs,{path:t.filename,line:w.metadata.draft.realLine,sendingToAgent:f===`${B}-draft-agent`,onCancel:()=>g(null),onAddToReview:G=>{const q=w.metadata.draft;q&&(F(x,p,{path:t.filename,body:G,line:q.realLine,side:q.realSide}),g(null),H.success("Added to review"))},onSendToAgent:G=>{const q=w.metadata.draft;q&&L({key:`${B}-draft-agent`,kind:"lines",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:`${t.filename} line ${q.realLine} ("${G.trim()}")`})}}):null]}),[S.allowed,S.reason,$.allowed,$.reason,i,oe,ae,A,F,x,p,t.filename,B,f,r,L]);return e.jsxs("article",{className:"overflow-hidden rounded-md border border-border/60",children:[e.jsxs("div",{className:"sticky top-8 z-[5] flex items-center gap-1.5 bg-[var(--surface-muted)] px-2 py-1.5",children:[e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:()=>n(t.filename),"aria-label":s?`Expand ${t.filename}`:`Collapse ${t.filename}`,title:s?"Expand":"Collapse",className:"size-6",children:e.jsx(z,{name:s?"arrow-right-s":"arrow-down-s",className:"size-4"})}),e.jsx(z,{name:ot(_),className:xe("size-3.5 shrink-0",Re(_)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",title:t.filename,children:[X?e.jsxs("span",{className:"text-muted-foreground",children:[X,"/"]}):null,e.jsx("span",{className:"text-foreground",children:R})]}),_!=="other"?e.jsx("span",{className:xe("shrink-0 rounded px-1 font-mono typography-micro",Re(_)),title:t.status??void 0,children:Ms(_)}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),c.length>0||Z.length>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground",title:`${c.length} ${c.length===1?"conversation":"conversations"}${Z.length>0?`, ${Z.length} pending`:""}`,children:[e.jsx(z,{name:"chat-1",className:"size-3.5","aria-hidden":"true"}),c.length>0?e.jsx("span",{className:"tabular-nums",children:ee>0?ee:c.length}):null,Z.length>0?e.jsxs("span",{className:"tabular-nums",children:["+",Z.length]}):null]}):null,e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",onClick:w=>w.stopPropagation(),children:[e.jsx(Et,{checked:a,onChange:w=>l(t.filename,w),ariaLabel:a?`Mark ${t.filename} as not viewed`:`Mark ${t.filename} as viewed`}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Viewed"})]}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{L({key:`${B}-agent`,kind:"file",directory:r,repo:x,number:p,contextType:"pr",contextOptions:{includeDiff:!0},detail:t.filename})},disabled:f===`${B}-agent`,"aria-label":`Send ${t.filename} to agent`,children:"Send to agent"})]}),s?null:e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[ne.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md bg-[var(--surface-muted)] px-2 py-2",children:[e.jsxs("p",{className:"typography-micro text-muted-foreground",children:["Other conversations (",ne.length,") — ",ne.length===1?"this line is":"these lines are"," no longer in the diff"]}),ne.map(w=>e.jsx(Be,{thread:w,replyAllowed:S.allowed,replyDisabledReason:S.reason,resolveAllowed:$.allowed,resolveDisabledReason:$.reason,busy:i,onReply:G=>oe(w,G),onToggleResolved:()=>ae(w)},w.id))]}):null,Q?e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Large diff — ",rt(t)," changed lines"]}),e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>de(!0),children:"Load diff"})]}):t.patch?e.jsx("div",{className:"min-h-24 overflow-hidden",children:e.jsx(Ls,{original:N,modified:E,language:ss(t.filename),fileName:t.filename,renderSideBySide:!1,layout:"inline",enableGutterUtility:V.allowed&&j===null,enableLineSelection:V.allowed&&j===null,onGutterUtilityClick:K,onLineSelectionEnd:K,lineAnnotations:se,renderAnnotation:w=>ue(w)})}):e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-[var(--surface-muted)] px-3 py-3 typography-ui",children:[e.jsx(z,{name:"file",className:"size-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),e.jsx("p",{className:"min-w-0 flex-1 text-muted-foreground",children:"Diff not available for this file."}),d?e.jsx(P,{type:"button",variant:"link",size:"sm",asChild:!0,children:e.jsx("a",{href:d,target:"_blank",rel:"noreferrer",children:"Open on GitHub"})}):null]})]})]})},Is=o.memo(qs),Os=({directory:t,repo:s,number:n,github:a,pr:l,access:d,onCommented:c})=>{const r=O(i=>i.addComment),x=O(i=>i.performAction),p=le(i=>i.clearCommentDraft),{draft:k,onDraftChange:m,flushDraft:b}=ht(s,n),{busy:h,error:A,submit:F}=ft({postComment:i=>r(t,s,n,i,a),runFollowUp:i=>x(t,s,n,i,a),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{m(""),p(s,n),c()}}),T=nt(d),j=l.state==="open"?"close":l.state==="closed"?"reopen":null,g=j?te(j,l,d):null;return T.allowed?e.jsx(xt,{draft:k,onDraftChange:m,onDraftBlur:b,ariaLabel:"Leave a comment on this pull request",busy:h,error:A,disabledReason:T.reason,followUp:j?{id:j,label:j==="close"?"Close with comment":"Reopen with comment",busyLabel:j==="close"?"Closing…":"Reopening…",onRun:()=>{F(j,k)},allowed:g?.allowed===!0,reason:g?.reason}:null,onSubmitComment:()=>{F("comment",k)}}):null},Bs={comment:"Comment",approve:"Approve","request-changes":"Request changes"},_s=({repo:t,number:s,verdicts:n,summary:a,verdict:l,pendingCount:d,busy:c,textareaRef:r,onSubmit:x})=>{const p=le(h=>h.setSummary),k=le(h=>h.setVerdict),m=n.includes(l)?l:n[0]??"comment",b=ls({verdict:m,summary:a,pendingCount:d});return e.jsxs("div",{children:[e.jsx(zt,{ref:r,rows:3,value:a,placeholder:"Summarize your review (optional)","aria-label":"Review summary",disabled:c,onChange:h=>p(t,s,h.target.value),onKeyDown:h=>{h.nativeEvent.isComposing||h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&!h.shiftKey&&!h.altKey&&!h.repeat&&(h.preventDefault(),h.stopPropagation(),b&&!c&&x())}}),e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[e.jsxs("label",{className:"inline-flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"sr-only",children:"Review verdict"}),e.jsx("select",{value:m,disabled:c,onChange:h=>k(t,s,h.target.value),"aria-label":"Review verdict",className:"h-7 max-w-40 truncate rounded-md border border-border bg-[var(--surface-elevated)] px-1.5 typography-micro text-foreground",children:n.map(h=>e.jsx("option",{value:h,children:Bs[h]},h))})]}),e.jsx(P,{type:"button",variant:"default",size:"xs",disabled:c||!b,title:b?`Submit review${d>0?` with ${d} ${d===1?"line comment":"line comments"}`:""}`:"Add a summary or a line comment first",onClick:x,children:c?"Submitting…":"Submit review"})]})]})},dt=({directory:t,repo:s,number:n,github:a,access:l,size:d="sm",onReviewSubmitted:c})=>{const r=O(M=>M.submitReview),x=le(M=>M.removeComments),p=le(M=>M.clearSummary),k=le(M=>M.clearComments),m=Le(s,n),b=pt(s,n),h=gt(s,n),[A,F]=o.useState(!1),[T,j]=o.useState(!1),g=o.useRef(null),i=o.useMemo(()=>as(l),[l]),C=i.includes(h)?h:i[0]??"comment",L=m.length,f=L>0||b.trim().length>0;if(o.useEffect(()=>{if(!A)return;const M=window.requestAnimationFrame(()=>g.current?.focus({preventScroll:!0}));return()=>window.cancelAnimationFrame(M)},[A]),i.length===0)return null;const N=async()=>{if(T)return;const M=b,B=[...m];j(!0);try{const V=B.map($=>({path:$.path,body:$.body,...$.line!=null?{line:$.line}:{},...$.side?{side:$.side}:{}})),S=await r(t,s,n,{event:C,body:M.trim()?M:void 0,comments:V},a);if(!S.ok){H.error(S.error?.kind==="failed"?S.error.message:"Failed to submit review");return}x(s,n,B.map($=>$.id)),p(s,n,M),H.success(C==="approve"?"Pull request approved":C==="request-changes"?"Changes requested":"Review submitted"),F(!1),c?.()}finally{j(!1)}},E=L>0?`Review · ${L}`:"Review";return e.jsxs(Ye,{open:A,onOpenChange:F,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:L>0?"default":"outline",size:d,className:"shrink-0","aria-label":L>0?`Review pull request, ${L} ${L===1?"line comment":"line comments"} pending`:"Review pull request",title:f?"Finish your review":"Approve, request changes, or comment with a review"}),children:[e.jsx(z,{name:"file-check",className:"size-3.5","aria-hidden":"true"}),E]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"top",align:"end",sideOffset:8,collisionPadding:8,children:e.jsxs(et,{"aria-label":"Review pull request",className:"w-[min(24rem,calc(100vw-2rem))] rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-3 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 truncate typography-ui-label text-foreground",children:L>0?`Review · ${L} ${L===1?"line comment":"line comments"}`:"Review pull request"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[L>0?e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Discard pending line comments",title:"Discard pending line comments",disabled:T,onClick:()=>k(s,n),className:"size-6",children:e.jsx(z,{name:"delete-bin",className:"size-3.5"})}):null,e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":"Close review",onClick:()=>F(!1),className:"size-6",children:e.jsx(z,{name:"close",className:"size-3.5"})})]})]}),e.jsx(_s,{repo:s,number:n,verdicts:i,summary:b,verdict:C,pendingCount:L,busy:T,textareaRef:g,onSubmit:()=>{N()}})]})})})]})},ye=(t,s)=>`${t}#${s}`,_e=50,Us=Object.freeze([]),Ue=(t,s)=>{const n=Object.keys(t);if(n.length<=_e)return t;const a={};for(const l of n.slice(n.length-_e))a[l]=t[l];if(!(s in a)&&s in t){const l=Object.keys(a)[0];delete a[l],a[s]=t[s]}return a},pe=Es()(Fs((t,s)=>({entries:{},setViewed:(n,a,l,d)=>{const c=ye(n,a);(s().entries[c]?.viewed.includes(l)??!1)!==d&&t(p=>{const k=p.entries[c]??{viewed:[],headSha:null},m=d?[...k.viewed,l]:k.viewed.filter(b=>b!==l);return{entries:Ue({...p.entries,[c]:{...k,viewed:m}},c)}})},syncHeadSha:(n,a,l)=>{const d=ye(n,a),c=s().entries[d];c&&c.headSha===(l??null)||t(r=>({entries:Ue({...r.entries,[d]:{viewed:[],headSha:l??null}},d)}))},resetForRuntimeSwitch:()=>t({entries:{}})}),{name:"pichamber:github-viewed-files",version:1,storage:ks(),partialize:t=>({entries:t.entries})}));typeof window<"u"&&Cs(()=>{pe.getState().resetForRuntimeSwitch()});const Vs=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed??Us),Ks=(t,s)=>pe(n=>n.entries[ye(t,s)]?.viewed.length??0),Ve=20,Js=[],Ws=[],Ke=t=>`pr-file-${encodeURIComponent(t)}`,ut=o.memo(({file:t,viewed:s,threadCount:n,pendingCount:a,showDir:l,onSelectFile:d})=>{const c=lt(t.status),{dir:r,base:x}=it(t.filename);return e.jsxs("button",{type:"button",onClick:()=>d(t.filename),title:t.filename,"aria-label":`Go to ${t.filename}`,className:"flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-left hover:bg-interactive-hover",children:[e.jsx(z,{name:ot(c),className:xe("size-3.5 shrink-0",Re(c)),"aria-hidden":"true"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono typography-micro",children:[l&&r?e.jsxs("span",{className:"text-muted-foreground",children:[r,"/"]}):null,e.jsx("span",{className:"text-foreground",children:x})]}),e.jsx(ge,{additions:t.additions,deletions:t.deletions,className:"typography-micro"}),n>0?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro text-muted-foreground",title:`${n} ${n===1?"conversation":"conversations"}`,children:[e.jsx(z,{name:"chat-1",className:"size-3","aria-hidden":"true"}),e.jsx("span",{className:"tabular-nums",children:n})]}):null,a>0?e.jsxs("span",{className:"shrink-0 tabular-nums typography-micro text-muted-foreground",title:`${a} pending`,children:["+",a]}):null,s?e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]","aria-label":"Viewed"}):null]})});ut.displayName="FileJumpRow";const mt=({files:t,viewedPaths:s,threadCounts:n,pendingCounts:a,onSelectFile:l})=>{const[d,c]=o.useState(""),r=o.useMemo(()=>zs(t),[t]),x=o.useMemo(()=>new Set(s),[s]),p=d.trim().toLowerCase(),k=o.useMemo(()=>p?r.map(m=>({...m,files:m.files.filter(b=>b.filename.toLowerCase().includes(p))})).filter(m=>m.files.length>0):r,[r,p]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-1",children:[e.jsx(st,{value:d,onChange:m=>c(m.target.value),placeholder:"Filter files","aria-label":"Filter files",className:"h-7 shrink-0 typography-micro"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",role:"list","aria-label":"Changed files",children:k.length===0?e.jsx("p",{className:"px-1.5 py-2 typography-micro text-muted-foreground",children:t.length===0?"No changed files":"No files match"}):k.map(m=>e.jsxs("div",{role:"group","aria-label":m.folder||"Repository root",children:[r.length>1?e.jsx("p",{className:"truncate px-1.5 pt-1.5 pb-0.5 typography-micro text-muted-foreground",title:m.folder||"/",children:m.folder||"/"}):null,m.files.map(b=>e.jsx(ut,{file:b,viewed:x.has(b.filename),threadCount:n.get(b.filename)??0,pendingCount:a.get(b.filename)??0,showDir:r.length<=1,onSelectFile:l},b.filename))]},m.folder))})]})},Ys=t=>{const[s,n]=o.useState(!1),{onSelectFile:a}=t,l=o.useCallback(d=>{n(!1),a(d)},[a]);return e.jsxs(Ye,{open:s,onOpenChange:n,children:[e.jsxs(Qe,{render:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0","aria-label":`Jump to file, ${t.files.length} ${t.files.length===1?"file":"files"}`,title:"Jump to file"}),children:[e.jsx(z,{name:"file",className:"size-3.5","aria-hidden":"true"}),"Files"]}),e.jsx(Xe,{children:e.jsx(Ze,{className:"z-50",side:"bottom",align:"start",sideOffset:4,collisionPadding:8,children:e.jsx(et,{"aria-label":"Jump to file",className:"flex max-h-[min(28rem,calc(100dvh-4rem))] w-[min(22rem,calc(100vw-2rem))] flex-col rounded-lg border border-border/60 bg-[var(--surface-elevated)] p-1.5 shadow-lg",children:e.jsx(mt,{...t,onSelectFile:l})})})})]})},Qs=48,Xs=(t,s)=>{const[n,a]=o.useState(null);return o.useLayoutEffect(()=>{if(!s)return;const l=t.current?.closest("[data-diff-virtual-root]");if(!(l instanceof HTMLElement))return;const d=()=>{const r=Math.max(160,Math.floor(l.clientHeight-Qs));a(x=>x===r?x:r)};if(d(),typeof ResizeObserver>"u")return;const c=new ResizeObserver(d);return c.observe(l),()=>c.disconnect()},[t,s]),n},Zs=t=>{const{directory:s,repo:n,number:a,github:l,access:d,headSha:c=null}=t,r=t.files?.files??Js,x=Vs(n,a),p=Ks(n,a),k=Le(n,a);o.useEffect(()=>{pe.getState().syncHeadSha(n,a,c)},[n,a,c]);const m=o.useMemo(()=>Ds(r),[r]),b=o.useRef(m);b.current=m;const h=o.useRef(r);h.current=r;const[A,F]=o.useState({}),[T,j]=o.useState(Ve),g=o.useMemo(()=>As(r),[r]),i=o.useMemo(()=>{const R=new Map;for(const I of t.threads){if(!I.path)continue;const y=R.get(I.path)??[];y.push(I),R.set(I.path,y)}return R},[t.threads]),C=o.useMemo(()=>{const R=new Map;for(const[I,y]of i)R.set(I,y.length);return R},[i]),L=o.useMemo(()=>{const R=new Map;for(const I of k)R.set(I.path,(R.get(I.path)??0)+1);return R},[k]),f=o.useCallback(R=>{F(I=>({...I,[R]:!(I[R]??b.current[R]??!1)}))},[]),N=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!1])))},[]),E=o.useCallback(()=>{F(Object.fromEntries(h.current.map(R=>[R.filename,!0])))},[]),M=o.useCallback((R,I)=>{pe.getState().setViewed(n,a,R,I),F(y=>({...y,[R]:I}))},[n,a]),B=o.useCallback(R=>{F(y=>y[R]??b.current[R]??!1?{...y,[R]:!1}:y);const I=h.current.findIndex(y=>y.filename===R);I>=0&&j(y=>I<y?y:I+1),requestAnimationFrame(()=>{document.getElementById(Ke(R))?.scrollIntoView({block:"start"})})},[]),V=o.useMemo(()=>r.slice(0,T),[r,T]),S=o.useRef(null),$=Xs(S,V.length>0),K=o.useMemo(()=>new Set(x),[x]),_=r.length===1?"1 file":`${r.length} files`,X=r.length===0?"Nothing viewed yet":`${p}/${r.length} viewed`;return e.jsxs("section",{"aria-label":"Changed files",className:"@container flex flex-col gap-2","data-diff-virtual-content":!0,children:[e.jsx(ve,{error:t.filesError,onRetry:t.onRetryFiles,label:"Changed files"}),e.jsx(ve,{error:t.threadsError,onRetry:t.onRetryDetail,label:"Review threads"}),e.jsxs("div",{className:"sticky top-0 z-10 flex h-8 shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--surface-background)] px-1 text-[12px]",children:[e.jsx("span",{className:"shrink-0 text-muted-foreground",children:_}),e.jsx(ge,{additions:g.additions,deletions:g.deletions}),e.jsxs("span",{className:"shrink-0 tabular-nums text-muted-foreground","aria-label":X,children:[p,"/",r.length," viewed"]}),e.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:d,size:"xs",onReviewSubmitted:t.onReviewSubmitted}),e.jsx("span",{className:"@4xl:hidden",children:e.jsx(Ys,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:N,"aria-label":"Expand all files",title:"Expand all files",className:"size-7",children:e.jsx(z,{name:"expand-up-down",className:"size-3.5"})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon",onClick:E,"aria-label":"Collapse all files",title:"Collapse all files",className:"size-7",children:e.jsx(z,{name:"collapse-vertical",className:"size-3.5"})})]})]}),t.filesLoading&&V.length===0?e.jsx(Rs,{rows:5,label:"Loading changed files"}):null,!t.filesLoading&&V.length===0?e.jsx("p",{className:"px-1 py-4 typography-micro text-muted-foreground",children:"No changed files"}):null,V.length>0?e.jsxs("div",{className:"flex min-h-0 items-start gap-3",children:[e.jsx("aside",{ref:S,"aria-label":"Changed files",style:$!=null?{height:$}:void 0,className:"sticky top-10 hidden max-h-[calc(100dvh-10rem)] w-60 shrink-0 flex-col @4xl:flex",children:e.jsx(mt,{files:r,viewedPaths:x,threadCounts:C,pendingCounts:L,onSelectFile:B})}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:V.map(R=>e.jsx("div",{id:Ke(R.filename),className:"scroll-mt-12",children:e.jsx(Is,{file:R,collapsed:A[R.filename]??m[R.filename]??!1,onToggleCollapse:f,viewed:K.has(R.filename),onToggleViewed:M,blobUrl:$s(n,c,R.filename),threads:i.get(R.filename)??Ws,directory:s,repo:n,number:a,github:l,access:d,onThreadsChanged:t.onRetryDetail})},R.filename))})]}):null,r.length>T?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>j(T+Ve),children:"Show more files"})}):null,t.filesHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreFiles,children:"Load more files"})}):null]})},en=({directory:t,repo:s,number:n,github:a,checks:l,checksError:d,checksLoading:c,onRetryChecks:r,onOpenFilesAtLine:x})=>{const[p,k]=o.useState({}),[m,b]=o.useState({}),{send:h,sendingKey:A}=Fe(),F=os(l);return e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-1 py-1",children:[e.jsx("p",{className:"min-w-0 flex-1 typography-micro text-muted-foreground","aria-live":"polite",children:F?F.text:c?"Loading checks…":"No checks reported for this pull request."}),F&&F.failed>0?e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{h({key:`pr-${n}-failed-checks`,kind:"checks",directory:t,repo:s,number:n,contextType:"checks"})},disabled:A===`pr-${n}-failed-checks`,"aria-label":"Send failed checks to agent",title:"Send failed checks to agent",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5"}),"Send failures to agent"]}):null,e.jsxs(P,{type:"button",variant:"ghost",size:"xs",onClick:r,"aria-label":"Refresh checks",title:"Refresh checks",children:[e.jsx(z,{name:"refresh",className:xe("size-3.5",c&&"animate-spin")}),"Refresh"]})]}),e.jsx(ve,{error:d,onRetry:r,label:"Checks"}),l?e.jsx(tn,{checks:l,directory:t,repo:s,number:n,github:a,expandedJobs:p,onToggleJob:T=>k(j=>({...j,[T]:!j[T]})),jobSteps:m,setJobSteps:b,sendingKey:A,send:h,onOpenFilesAtLine:x}):null]})},tn=({checks:t,directory:s,repo:n,number:a,github:l,expandedJobs:d,onToggleJob:c,jobSteps:r,setJobSteps:x,sendingKey:p,send:k,onOpenFilesAtLine:m})=>{const b=O(i=>i.rerunFailedChecks),[h,A]=o.useState({}),F=async i=>{const C=`run-${i.id??i.name}`;if(c(C),!(d[C]||r[C]||i.id==null)){x(L=>({...L,[C]:{steps:[],loading:!0}}));try{const f=(await l.checkJobs(s,n,i.runId??null,i.id)).jobs[0];x(E=>({...E,[C]:{steps:f?.steps??[],loading:!1}}));const N=await l.checkAnnotations(s,n,i.id).catch(()=>null);N&&A(E=>({...E,[i.id]:{loading:!1,items:N.annotations}}))}catch{x(L=>({...L,[C]:{steps:[],loading:!1}}))}}},T=async i=>{(await b(s,n,i,l)).ok?H.success("Re-run requested"):H.error("Re-run failed")},j=i=>{const C=`run-${i.id??i.name}`,L=d[C]??!1,f=r[C],N=is(i);return e.jsxs("div",{className:"rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(fe,{state:i.conclusion??i.status}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.name,children:i.name}),i.conclusion?e.jsx("span",{className:"typography-micro text-muted-foreground",children:i.conclusion}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{F(i)},"aria-expanded":L,"aria-label":`${L?"Collapse":"Expand"} ${i.name}`,children:"Details"}),N&&i.runId!=null?e.jsx(P,{type:"button",variant:"outline",size:"xs",onClick:()=>{T(i.runId)},children:"Re-run"}):null,N?e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{k({key:`${C}-agent`,kind:"check",directory:s,repo:n,number:a,contextType:"checks",detail:i.name})},disabled:p===`${C}-agent`,"aria-label":`Send ${i.name} to agent`,children:"Send to agent"}):null]}),L?e.jsxs("div",{className:"mt-1.5 flex flex-col gap-1 border-t border-border/60 pt-1.5",children:[f?.loading?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Loading steps…"}):null,(f?.steps??[]).map((E,M)=>e.jsxs("div",{className:"flex items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(fe,{state:E.conclusion??E.status}),e.jsx("span",{className:"truncate",children:E.name}),E.conclusion?e.jsxs("span",{children:["· ",E.conclusion]}):null]},`${E.name}-${M}`)),i.id!=null&&h[i.id]?.items?.length?e.jsx("div",{className:"flex flex-col gap-1",children:h[i.id]?.items.map((E,M)=>e.jsxs("div",{className:"typography-micro text-muted-foreground",children:[E.path&&E.startLine&&m?e.jsxs("button",{type:"button",className:"font-mono underline",onClick:()=>m(E.path,E.startLine),children:[E.path,":",E.startLine]}):e.jsxs("span",{className:"font-mono",children:[E.path,E.startLine?`:${E.startLine}`:""]})," ",E.title?e.jsxs("span",{className:"text-foreground",children:[E.title," — "]}):null,E.message]},M))}):null]}):null]},C)},g=(i,C)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md px-2 py-2 hover:bg-interactive-hover",children:[e.jsx(fe,{state:i.state}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui text-foreground",title:i.context,children:i.context}),i.description?e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:i.description}):null]},`${i.context}-${C}`);return e.jsxs("div",{className:"flex flex-col gap-1",children:[t.sectionErrors?.runs||t.sectionErrors?.statuses?e.jsx("div",{className:"rounded-md border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-2 py-1 typography-micro text-foreground",role:"alert",children:"Some check sources failed to load; counts below are partial, not empty."}):null,t.runs.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Check runs",children:t.runs.map(j)}):null,t.statuses.length>0?e.jsx("div",{className:"flex flex-col","aria-label":"Commit statuses",children:t.statuses.map(g)}):null,t.runs.length===0&&t.statuses.length===0?e.jsx("p",{className:"typography-ui text-muted-foreground",children:"No checks reported for this pull request."}):null]})},Je=({pr:t})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(at,{login:t.author?.login,avatarUrl:t.author?.avatarUrl,size:"xs"}),t.author?.login??"ghost"]}),t.updatedAt?` · updated ${bs(t.updatedAt)}`:"",t.draft?" · Draft":""]}),We=({pr:t,filesCount:s})=>e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"shrink-0 truncate",title:t.base,children:t.base}),e.jsx("span",{className:"shrink-0","aria-label":"receives changes from",children:"←"}),e.jsx("code",{className:"min-w-0 flex-1 truncate",title:t.head,children:t.head}),typeof s=="number"?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 tabular-nums",children:[e.jsx(z,{name:"file-code",className:"size-3 shrink-0","aria-hidden":"true"}),s," ",s===1?"file":"files"]}):null,e.jsx(ge,{additions:t.additions,deletions:t.deletions})]}),sn=({repo:t,pr:s,access:n,acting:a,mergeMethod:l,onMergeMethodChange:d,onRun:c,checkingOut:r,onCheckout:x,onCopyLink:p,askSending:k,onAskAgent:m})=>{const b=O(N=>N.setMergeMethod),h=s.state==="open",A=be.filter(N=>te(N.id,s,n).allowed),F=A.some(N=>N.id===l)?l:A[0]?.id??l,T=te(F,s,n),j=te("ready",s,n),g=te("draft",s,n),i=te("close",s,n),C=te("reopen",s,n),L=be.find(N=>N.id===F)??be[0],f=A.length===0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Pull request actions",children:[h&&!s.draft?e.jsxs("span",{role:"group","aria-label":"Merge pull request",className:"inline-flex shrink-0 items-center gap-1",children:[e.jsx(ce,{copy:he(F,s.base,s.head),busy:a,disabled:!T.allowed,disabledReason:T.reason??`Merge via ${L.label}`,label:F==="merge"?"Merge pull request":L.label,icon:e.jsx(z,{name:"git-merge",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c(F)}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"default",size:"xs",className:"shrink-0 px-1.5",title:"Merge options","aria-label":"Merge options",disabled:f,children:e.jsx(z,{name:"arrow-down-s",className:"size-3.5"})})}),e.jsx(Ae,{align:"start",className:"w-72",children:e.jsx(Ft,{value:F,onValueChange:N=>{const E=N;d(E),b(t,E)},children:be.map(N=>{const E=te(N.id,s,n);return e.jsx(Pt,{value:N.id,disabled:!E.allowed,title:E.reason??N.description,children:e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"truncate",children:N.label}),e.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:N.description})]})},N.id)})})})]})]}):null,h&&s.draft?e.jsx(ce,{copy:he("ready",s.base,s.head),busy:a,disabled:!j.allowed,disabledReason:j.reason??"Ready for review",label:"Ready for review",icon:e.jsx(z,{name:"git-pull-request",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("ready")}):null,h&&!s.draft?e.jsx(ce,{copy:he("draft",s.base,s.head),busy:a,variant:"outline",disabled:!g.allowed,disabledReason:g.reason??"Convert to draft",label:"Convert to draft",icon:e.jsx(z,{name:"pencil",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("draft")}):null,h?e.jsx(ce,{copy:he("close",s.base,s.head),busy:a,destructive:!0,variant:"outline",disabled:!i.allowed,disabledReason:i.reason??"Close pull request",label:"Close",icon:e.jsx(z,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>c("close")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>c("reopen"),disabled:!C.allowed||a,title:C.reason??"Reopen pull request","aria-label":"Reopen pull request",children:[e.jsx(z,{name:"history",className:"size-3.5","aria-hidden":"true"}),"Reopen"]}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>x("worktree"),disabled:r,title:"Check out in a new worktree","aria-label":"Check out in a new worktree",children:[e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),r?"Checking out…":"Check out"]}),e.jsx(ce,{copy:{title:"Check out this branch here?",detail:"This switches your current checkout to the PR branch. Uncommitted work may be disrupted.",confirm:"Check out here",progress:"Checking out…"},busy:r,variant:"outline",label:"Check out here",icon:e.jsx(z,{name:"git-branch",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>x("current")}),e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:m,disabled:k,title:"Send pull request context to the agent composer","aria-label":"Ask agent about this pull request",children:[e.jsx(z,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),k?"Asking…":"Ask agent"]}),e.jsxs(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{Se(s.url)},title:"Review on GitHub","aria-label":"Review on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Review on GitHub"]}),e.jsxs(Me,{modal:!1,children:[e.jsx(ze,{asChild:!0,children:e.jsx(P,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More pull request actions",title:"More pull request actions",children:e.jsx(z,{name:"more-2",className:"size-4"})})}),e.jsxs(Ae,{align:"end",className:"w-60",children:[e.jsxs(we,{onClick:()=>{Se(s.url)},children:[e.jsx(z,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),e.jsxs(we,{onClick:p,children:[e.jsx(z,{name:"file-copy",className:"size-3.5"}),"Copy link"]}),e.jsx(Tt,{}),e.jsxs(we,{onClick:()=>x("worktree"),disabled:r,children:[e.jsx(z,{name:"git-branch",className:"size-3.5"}),"Check out in new worktree"]})]})]})]})},nn=({pr:t,access:s,acting:n,onRun:a})=>{const l=vs(t);if(!l)return null;const d=te("update-branch",t,s),c=l.tone==="error"?"border-[var(--status-error-border)] bg-[var(--status-error-background)] text-foreground":"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-foreground",r=l.tone==="error"?"text-[var(--status-error)]":"text-[var(--status-warning)]";return e.jsxs("div",{className:`mx-3 mb-2 flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-md border px-2.5 py-2 ${c}`,role:"status",children:[e.jsx(z,{name:l.icon,className:`size-4 shrink-0 ${r}`,"aria-hidden":"true"}),e.jsxs("p",{className:"min-w-0 flex-1 basis-48",children:[e.jsxs("span",{className:"typography-ui-label font-medium",children:[l.title," ",e.jsx("code",{className:"font-mono",children:t.base})]}),e.jsx("span",{className:"block typography-micro text-muted-foreground",children:l.detail})]}),l.canUpdate?e.jsx(ce,{copy:he("update-branch",t.base,t.head),busy:n,variant:"outline",disabled:!d.allowed,disabledReason:d.reason??"Update branch",label:"Update branch",icon:e.jsx(z,{name:"refresh",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>a("update-branch")}):e.jsxs(P,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:()=>{Se(t.url)},title:"Resolve conflicts on GitHub","aria-label":"Resolve conflicts on GitHub",children:[e.jsx(z,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Resolve on GitHub"]})]})},an=t=>{const{directory:s,repo:n,number:a,github:l,detail:d}=t,c=O(u=>u.performAction),r=O(u=>u.updateTitleBody),x=O(u=>u.checkout),[p,k]=o.useState("summary"),[m,b]=o.useState(!1),[h,A]=o.useState(()=>At(n)??"merge"),[F,T]=o.useState(!1),[j,g]=o.useState(""),[i,C]=o.useState(!1),[L,f]=o.useState(""),[N,E]=o.useState("newest"),[M,B]=o.useState(1),[V,S]=o.useState(!1),[$,K]=o.useState(null),_=bt(n,a),{send:X,sendingKey:R}=Fe(),I=rs(s,n),y=d?.pr??null,de=d?.sectionErrors??null,Q=o.useMemo(()=>({capabilities:d?.capabilities??null,isAuthor:cs(y?.author?.login,d?.viewerLogin),permissionFallback:d?.viewerPermission?.fallback===!0}),[d?.capabilities,d?.viewerLogin,d?.viewerPermission?.fallback,y?.author?.login]),ee=ds(y,Q);o.useEffect(()=>{k("summary"),T(!1),C(!1),B(1),K(null)},[n,a]);const Z=o.useCallback(async u=>{b(!0);try{const Y=await c(s,n,a,u,l);if(!Y.ok){H.error(Y.error?.kind==="failed"?Y.error.message:"Action failed");return}u==="close"?H.success("Pull request closed"):u==="reopen"?H.success("Pull request reopened"):u==="update-branch"?H.success("Branch update requested"):u==="ready"?H.success("Marked as ready for review"):u==="draft"?H.success("Converted to draft"):H.success("Pull request merged")}finally{b(!1)}},[s,n,a,l,c]),se=o.useCallback(()=>{X({key:`pr-${a}-ask`,kind:"pr",directory:s,repo:n,number:a,contextType:"pr"})},[X,s,n,a]),ne=o.useCallback(async()=>{if(!j.trim()){H.error("Enter a title");return}const u=await r(s,n,a,{title:j.trim()},l);u.ok?(H.success("Title updated"),T(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update title")},[j,s,n,a,l,r]),oe=o.useCallback(async()=>{const u=await r(s,n,a,{body:L},l);u.ok?(H.success("Description updated"),C(!1)):H.error(u.error?.kind==="failed"?u.error.message:"Failed to update description")},[L,s,n,a,l,r]),ae=Ee().git,ue=o.useCallback(async u=>{if(u==="current"){const Y=await Ne(()=>import("./useAppFontEffects-CG3_yteE.js").then(re=>re.dV),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(re=>re.useGitStore.getState().directories.get(s)?.status??null).catch(()=>null);if(Y&&!Y.isClean){H.error("Working tree has uncommitted changes. Commit or stash first, or use New worktree.");return}}S(!0);try{const Y=await x(s,n,a,u,l);Y.ok?(await vt(s,ae),K({path:Y.path??null,branch:Y.branch??""}),H.success(u==="worktree"?"Worktree created":"Branch checked out")):H.error(Y.error?.kind==="failed"?Y.error.message:"Checkout failed")}finally{S(!1)}},[s,n,a,l,ae,x]),w=o.useCallback(()=>{$?.path&&Ne(async()=>{const{useSessionUIStore:u}=await import("./useAppFontEffects-CG3_yteE.js").then(Y=>Y.dS);return{useSessionUIStore:u}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({useSessionUIStore:u})=>{u.getState().openNewSessionDraft({directoryOverride:$.path}),Ns.getState().setActiveMainTab("chat")})},[$]),G=us(y?.url),q=o.useMemo(()=>{const u=[...t.comments];return u.sort((Y,je)=>{const re=Y.createdAt?Date.parse(Y.createdAt):0,Te=je.createdAt?Date.parse(je.createdAt):0;return N==="newest"?Te-re:re-Te}),u},[t.comments,N]),D=q.slice(0,M*20),U=D.filter(u=>!$e(u.author?.login)),W=D.filter(u=>$e(u.author?.login));if(t.detailError&&!d)return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,openLabel:`Open pull request #${a} on GitHub`,title:`Pull request #${a}`}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(tt,{info:yt(t.detailError),onRetry:t.onRetryDetail})});if(!y){const u=t.seed&&t.seed.number===a?t.seed:null;return e.jsx(ke,{header:e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:a,url:u?.url??null,numberTintClass:u?He("pr",u.state,u.draft):void 0,statePill:u?e.jsx(Ge,{kind:"pr",state:u.state,draft:u.draft}):void 0,openLabel:`Open pull request #${a} on GitHub`,title:u?.title??null,meta:u?e.jsx(Je,{pr:u}):void 0,branches:u?e.jsx(We,{pr:u,filesCount:u.changedFiles??null}):void 0}),tabs:[],activeTab:"",onTabChange:()=>{},children:e.jsx(ms,{label:"Loading pull request"})})}const J=t.checks?.summary??null,me=t.files?.files.length??y.changedFiles??0,v=_>0&&!t.hideFilesTab?`${me} · ${_} pending`:String(me);return e.jsx(ke,{header:e.jsxs(e.Fragment,{children:[e.jsx(Ce,{onBack:t.onBack,backLabel:"Back to pull requests",repoName:I,number:y.number,url:y.url,numberTintClass:He("pr",y.state,y.draft),statePill:e.jsx(Ge,{kind:"pr",state:y.state,draft:y.draft}),openLabel:`Open pull request #${y.number} on GitHub`,title:y.title,onEditTitle:()=>{g(y.title),T(!0)},editTitleLabel:"Edit pull request title",editTitleDisabledReason:ee.allowed?null:ee.reason,meta:e.jsx(Je,{pr:y}),branches:e.jsx(We,{pr:y,filesCount:me})}),e.jsx(sn,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,acting:m,mergeMethod:h,onMergeMethodChange:A,onRun:u=>{Z(u)},checkingOut:V,onCheckout:u=>{ue(u)},onCopyLink:G,askSending:R===`pr-${a}-ask`,onAskAgent:se}),e.jsx(nn,{pr:y,access:Q,acting:m,onRun:u=>{Z(u)}})]}),tabs:[{id:"summary",label:"Summary"},...t.hideFilesTab?[]:[{id:"files",label:"Code",hint:v}],{id:"checks",label:"Checks",hint:J?`${J.success}/${J.total}`:void 0,glyph:J?e.jsx(fe,{state:J.state}):void 0}],activeTab:p,onTabChange:u=>k(u),children:e.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[t.detailStale?e.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved details — last refresh failed."," ",e.jsx("button",{type:"button",className:"underline",onClick:t.onRetryDetail,children:"Retry"})]}):null,Q.permissionFallback?e.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"Permissions could not be loaded — actions stay enabled and any failure will be shown after you act."}):null,F?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[e.jsx(st,{value:j,onChange:u=>g(u.target.value),"aria-label":"Pull request title",className:"h-7"}),e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:()=>{ne()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>T(!1),children:"Cancel"})]}):null,$?e.jsxs("p",{className:"flex flex-wrap items-center gap-1.5 typography-micro text-muted-foreground",children:[e.jsx(z,{name:"check",className:"size-3.5 shrink-0 text-[var(--status-success)]"}),e.jsxs("span",{children:["Ready on ",$.branch,$.path?` at ${$.path}`:"","."]}),$.path?e.jsx(P,{type:"button",variant:"default",size:"xs",onClick:w,children:"Open session here"}):null,e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>K(null),"aria-label":"Dismiss checkout result",children:"Dismiss"})]}):null,p==="summary"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[e.jsx(qe,{icon:"user",label:"Reviewers",children:e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[y.requestedReviewers.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.requestedReviewers.map(u=>e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[e.jsx(at,{login:u.login,avatarUrl:u.avatarUrl,size:"xs"}),e.jsx("span",{className:"truncate",children:u.login})]},u.login)),e.jsxs("span",{className:"typography-micro tabular-nums text-muted-foreground",children:[y.reviewSummary.approvals," approvals · ",y.reviewSummary.changesRequested," changes requested ·"," ",y.reviewSummary.commented," commented"]})]})}),e.jsx(qe,{icon:"list-unordered",label:"Labels",children:e.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:y.labels.length===0?e.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):y.labels.map(u=>e.jsx(hs,{name:u.name,color:u.color},u.name))})})]}),e.jsx(Ie,{id:`pr-${a}-description`,title:"Description",action:i?void 0:e.jsx(P,{type:"button",variant:"ghost",size:"xs",onClick:()=>{f(y.body??""),C(!0)},"aria-label":"Edit description",title:ee.reason??"Edit description",disabled:!ee.allowed,children:"Edit"}),children:i?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("textarea",{value:L,onChange:u=>f(u.target.value),rows:6,"aria-label":"Pull request description",className:"min-h-24 w-full rounded-md border border-border bg-[var(--surface-elevated)] p-2 typography-ui text-foreground"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(P,{type:"button",variant:"default",size:"sm",onClick:()=>{oe()},children:"Save"}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",onClick:()=>C(!1),children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{markdown:y.body??"",html:y.bodyHtml??null,fallbackUrl:y.url,label:"pull request description"}),y.body?.trim()?null:e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description provided."})]})}),e.jsx(Ie,{id:`pr-${a}-comments`,title:`Comments${q.length?` (${q.length})`:""}`,action:e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[t.hideFilesTab?e.jsx(dt,{directory:s,repo:n,number:a,github:l,access:Q,size:"xs",onReviewSubmitted:t.onRetryDetail}):null,e.jsx(gs,{order:N,onToggle:()=>E(N==="newest"?"oldest":"newest")})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(ve,{error:t.commentsError,onRetry:t.onRetryComments,label:"Comments"}),U.map(u=>e.jsx(xs,{comment:u},u.id)),e.jsx(ps,{comments:W}),t.commentsLoading&&q.length===0&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,q.length===0&&!t.commentsLoading&&!t.commentsError?e.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):null,q.length>D.length?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:()=>B(M+1),children:"Show older comments"})}):t.commentsHasMore?e.jsx("div",{children:e.jsx(P,{type:"button",variant:"outline",size:"sm",onClick:t.onLoadMoreComments,disabled:t.commentsLoading,children:t.commentsLoading?"Loading…":"Load older comments"})}):null,e.jsx(Os,{directory:s,repo:n,number:a,github:l,pr:y,access:Q,onCommented:()=>{t.onRetryComments(),t.onRetryDetail()}})]})})]}):null,p==="files"&&!t.hideFilesTab?e.jsx(Zs,{files:t.files,filesLoading:t.filesLoading,filesError:t.filesError,filesHasMore:t.filesHasMore,onLoadMoreFiles:t.onLoadMoreFiles,onRetryFiles:t.onRetryFiles,threads:t.threads,threadsError:de?.threads??null,onRetryDetail:t.onRetryDetail,directory:s,repo:n,number:a,github:l,access:Q,headSha:y.headSha??null,onReviewSubmitted:t.onRetryDetail},`${n}#${a}`):null,p==="checks"?e.jsx(en,{directory:s,repo:n,number:a,github:l,checks:t.checks,checksError:t.checksError,checksLoading:t.checksLoading,onRetryChecks:t.onRetryChecks,onOpenFilesAtLine:t.onOpenFilesAtLine}):null]})})},ln=({items:t,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,filters:r,checksByUrl:x,countComplete:p=!0,incompleteNotice:k=null,remote:m=null,numberJump:b=null,onFiltersChange:h,onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j,headerActionsSlot:g=null,headerActionsPresentation:i="drawer"})=>{const C=r.state==="open"&&r.involvement==="all"&&!r.search.trim(),L=o.useCallback(f=>e.jsx("li",{role:"listitem",children:e.jsx(jt,{glyph:e.jsx(ys,{kind:"pr",state:f.state,draft:f.draft}),glyphBelow:e.jsx(fe,{state:(f.url?x[f.url]:void 0)??null}),number:`#${f.number}`,title:f.title,status:e.jsx(ge,{additions:f.additions,deletions:f.deletions,className:"typography-micro"}),meta:e.jsxs(e.Fragment,{children:[e.jsx(wt,{login:f.author?.login,avatarUrl:f.author?.avatarUrl}),e.jsx(kt,{head:f.head,base:f.base}),f.draft?e.jsx("span",{className:"shrink-0 rounded bg-[var(--surface-muted)] px-1 typography-micro text-muted-foreground",children:"Draft"}):null]}),updatedAt:f.updatedAt,onOpen:()=>j(f.number),ariaLabel:`Open pull request #${f.number} ${f.title}`})},f.number),[x,j]);return e.jsx(Ct,{items:t,renderRow:L,hasMore:s,isLoadingMore:n,isLoading:a,isRefreshing:l,stale:d,error:c,searchValue:r.search,onSearchChange:f=>h({search:f}),searchPlaceholder:"Search pull requests, or label:bug",searchAriaLabel:"Search pull requests",toolbarControls:e.jsx(Nt,{stateValue:r.state,stateOptions:Oe.map(f=>({id:f.id,label:f.label})),onStateChange:f=>h({state:f}),involvementValue:r.involvement,involvementOptions:ws.map(f=>({id:f.id,label:f.label})),onInvolvementChange:f=>h({involvement:f}),sortValue:r.sort,sortOptions:js.map(f=>({id:f.id,label:f.label})),onSortChange:f=>h({sort:f}),sortAriaLabel:"Sort pull requests"}),headerActionsSlot:g,headerActionsPresentation:i,isDefaultFilters:C,stateLabel:Oe.find(f=>f.id===r.state)?.label??r.state,kindSingular:"pull request",kindPlural:"pull requests",noItemsTitle:r.state==="open"?"No open pull requests":"No pull requests yet",noItemsBody:"Pull requests for this repository appear here.",noItemsIcon:"git-pull-request",listAriaLabel:"Pull requests",skeletonLabel:"Loading pull requests",updatedAtOf:f=>f.updatedAt,countComplete:p,incompleteNotice:k,remote:m,numberJump:b,numberJumpKind:"pull request",onClearFilters:A,onLoadMore:F,onRetry:T,onOpen:j})},on=t=>{const s=Dt(n=>n.results);return o.useMemo(()=>{const n=$t(s),a={};for(const l of t){if(!l.url)continue;const d=n.get(l.url);d!==void 0&&(a[l.url]=d)}return a},[t,s])},ra=({hideFilesTab:t=!1,headerActionsSlot:s=null,headerActionsPresentation:n="drawer"})=>{const a=Mt()??"";return a?e.jsx(rn,{directory:a,hideFilesTab:t,headerActionsSlot:s,headerActionsPresentation:n}):e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:e.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse pull requests."})})},rn=({directory:t,hideFilesTab:s,headerActionsSlot:n=null,headerActionsPresentation:a="drawer"})=>{const d=Ee().github??null,[c,r]=o.useState(!1),[x,p]=o.useState(!1),k=o.useRef(null);return o.useEffect(()=>Gt(),[]),e.jsx(St,{directory:t,isRefreshing:c,onRefresh:()=>k.current?.(),children:({repo:m,directory:b})=>e.jsx(cn,{directory:b,repo:m,github:d,refreshing:c,setRefreshing:r,loadingMore:x,setLoadingMore:p,refreshRef:k,hideFilesTab:s,headerActionsSlot:n,headerActionsPresentation:a},m)})},cn=({directory:t,repo:s,github:n,refreshing:a,setRefreshing:l,loadingMore:d,setLoadingMore:c,refreshRef:r,hideFilesTab:x,headerActionsSlot:p=null,headerActionsPresentation:k="drawer"})=>{const m=O(v=>v.ensureCollectionsFresh),b=O(v=>v.searchRemote),h=O(v=>v.loadMoreRemote),A=O(v=>v.loadMoreCollection),F=O(v=>v.refreshAllForScope),T=O(v=>v.selectPullRequest),j=O(v=>v.setFilters),g=O(v=>v.resetFilters),i=Ht(t,s),C=qt(t),L=It(),f=C.repo===s?C.number:null,N=i.state==="open"?"open":i.state==="all"?"both":"closed";o.useEffect(()=>{if(!n)return;let v=!1;return l(!0),m(t,s,N,n).then(()=>{v||l(!1)}).catch(()=>{v||l(!1)}),()=>{v=!0}},[t,s,n,N]),o.useEffect(()=>{if(!n)return;const v=()=>{typeof document<"u"&&document.hidden||m(t,s,N,n).catch(()=>{})};return window.addEventListener("focus",v),document.addEventListener("visibilitychange",v),()=>{window.removeEventListener("focus",v),document.removeEventListener("visibilitychange",v)}},[t,s,n,N]);const E=De(s,"open"),M=De(s,"closed"),B=o.useMemo(()=>Ot(s),[s,E?.data,M?.data]),V=o.useMemo(()=>new Set(B.map(v=>v.number)),[B]),S=o.useMemo(()=>Bt(B,{state:i.state,involvement:i.involvement,search:i.search,sort:i.sort,viewerLogin:L}),[B,i.state,i.involvement,i.search,i.sort,L]),$=on(S),K=N==="both"?[E,M]:[N==="open"?E:M],_=K.some(v=>v?.data!=null),X=_&&K.every(v=>v?.data?.nextCursor==null),R=K.reduce((v,u)=>v+(u?.data?.items.length??0),0),I=K.find(v=>v?.error)?.error??null,y=K.some(v=>v?.isLoading),de=K.some(v=>v?.stale),Q=i.search.trim(),ee=i.involvement!=="all"&&!L,Z=Q.length>0||i.involvement!=="all",se=o.useMemo(()=>({state:i.state,involvement:i.involvement,q:Q}),[i.state,i.involvement,Q]),ne=`${se.state}|${se.involvement}|${se.q}`,oe=!X&&_&&S.length===0&&(Q.length>0||ee),ae=o.useCallback(v=>n?b(t,s,v,n):Promise.resolve(null),[t,s,n,b]),ue=o.useCallback(v=>n?h(t,s,v,n):Promise.resolve(null),[t,s,n,h]),{remoteView:w,numberJump:G,remotePending:q,handleSearchAll:ie}=Rt({repo:s,query:se,queryKey:ne,autoRemote:oe,indexNumbers:V,visibleItems:S,searchText:Q,useRemoteEntry:Wt,runSearch:ae,runLoadMore:ue}),D=o.useMemo(()=>{if(X||!_||!Z)return null;const v=S.length===1?"1 match":`${S.length} matches`,u=R===1?"1 most recent loaded pull request":`${R} most recent loaded pull requests`;return`Showing ${v} from the ${u}`},[X,_,Z,S.length,R]),U=o.useCallback(()=>{n&&(l(!0),F(t,s,n).then(()=>{l(!1)}).catch(()=>l(!1)))},[t,s,n,F,l]);o.useEffect(()=>(r.current=U,()=>{r.current===U&&(r.current=null)}),[r,U]);const W=o.useCallback(()=>{if(!n)return;c(!0);const v=N==="both"?["open","closed"]:[N];Promise.all(v.map(u=>A(t,s,u,n))).then(()=>c(!1)).catch(()=>c(!1))},[t,s,N,n,A,c]),J=o.useCallback(v=>{T(t,s,v)},[t,s,T]),me=o.useCallback(()=>{T(t,null,null)},[t,T]);return n?f!=null?e.jsx(dn,{directory:t,repo:s,number:f,github:n,onBack:me,hideFilesTab:x,seed:_t(s,f)}):e.jsx(ln,{items:S,headerActionsSlot:p,headerActionsPresentation:k,hasMore:K.some(v=>v?.data?.nextCursor!=null),isLoadingMore:d,isLoading:y,isRefreshing:a&&_,stale:de,error:I,filters:i,checksByUrl:$,countComplete:X,incompleteNotice:D?{summary:D,searching:q,onSearchAll:ie}:null,remote:w,numberJump:G,onFiltersChange:v=>j(t,s,v),onClearFilters:()=>g(t,s),onLoadMore:W,onRetry:U,onOpen:J}):e.jsx(tt,{info:{reason:"failed",message:"GitHub is not available in this runtime."}})},dn=({directory:t,repo:s,number:n,github:a,onBack:l,hideFilesTab:d,seed:c})=>{const r=O(S=>S.ensureDetail),x=O(S=>S.ensureComments),p=O(S=>S.ensureFiles),k=O(S=>S.ensureChecks),m=O(S=>S.loadMoreFiles),b=O(S=>S.loadMoreComments),h=O(S=>S.refreshComments),A=O(S=>S.refreshDetail),F=O(S=>S.refreshChecks);o.useEffect(()=>{r(t,s,n,a).catch(()=>{}),x(t,s,n,a).catch(()=>{}),d||p(t,s,n,a).catch(()=>{}),k(t,s,n,a).catch(()=>{})},[t,s,n,d]);const T=Ut(s,n),j=Vt(s,n),g=Kt(s,n),i=Jt(s,n),C=T?.data?.detail??null,L=o.useCallback((S,$)=>{const K=Ss(t);Ne(async()=>{const{useUIStore:_}=await import("./index-6IO1AcJI.js").then(X=>X.cy);return{useUIStore:_}},__vite__mapDeps([1,2,3,4,5,6,7])).then(({useUIStore:_})=>{_.getState().openContextFileAtLine(K,S,$)}).catch(()=>{})},[t]),f=o.useCallback(()=>{m(t,s,n,a).catch(()=>{})},[t,s,n,a,m]),N=o.useCallback(()=>{b(t,s,n,a).catch(()=>{})},[t,s,n,a,b]),E=o.useCallback(()=>{h(t,s,n,a).catch(()=>{})},[t,s,n,a,h]),M=o.useCallback(()=>{A(t,s,n,a).catch(()=>{})},[t,s,n,a,A]),B=o.useCallback(()=>{p(t,s,n,a).catch(()=>{})},[t,s,n,a,p]),V=o.useCallback(()=>{F(t,s,n,a).catch(()=>{})},[t,s,n,a,F]);return e.jsx(an,{hideFilesTab:d,seed:c,directory:t,repo:s,number:n,github:a,detail:C,detailError:T?.error??null,detailStale:T?.stale??!1,files:g?.data??null,filesError:g?.error??null,filesLoading:g?.isLoading??!1,filesHasMore:g?.data?.nextCursor!=null,onLoadMoreFiles:f,checks:i?.data??null,checksError:i?.error??null,checksLoading:i?.isLoading??!1,reviews:C?.reviews??[],threads:C?.threads??[],comments:j?.data?.comments??[],commentsError:j?.error??null,commentsLoading:j?.isLoading??!1,commentsHasMore:j?.data?.nextCursor!=null,onLoadMoreComments:N,onRetryComments:E,onBack:l,onRetryDetail:M,onRetryFiles:B,onRetryChecks:V,onOpenFilesAtLine:L})};export{ra as PullRequestsSurface};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as m,o as h}from"./index-6IO1AcJI.js";import{j as g}from"./vendor-boot-DyL2td56.js";import"./vendor-react-DASdDPIk.js";import{cN as y,cO as D,cP as w}from"./useAppFontEffects-CG3_yteE.js";const S="Awaiting first prompt";function I(e,t="Untitled Session"){const r=e?.title?.trim();return r||(e?.messageCount===0?S:t)}const R=(e,t,r)=>{const a=`${r}:`,o=new Set([...t].filter(s=>s.startsWith(a)));return e.size===o.size&&[...o].every(s=>e.has(s))?e:o},T=(e,t)=>{const r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r},b=e=>{const t=new Date(e),r=new Date,a=(n,i)=>n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate(),o=new Date(r);return o.setDate(r.getDate()-1),a(t,r)?"Today":a(t,o)?"Yesterday":t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}).replace(",","")},k=e=>{const t=new Date,r=new Date(e);if(((o,s)=>o.getFullYear()===s.getFullYear()&&o.getMonth()===s.getMonth()&&o.getDate()===s.getDate())(r,t)){const o=Date.now()-e;return o<6e4?"Just now":o<36e5?`${Math.floor(o/6e4)}min ago`:`${Math.floor(o/36e5)}h ago`}return b(e)},E=e=>{const t=Math.max(0,Date.now()-e),r=6e4,a=60*r,o=24*a,s=7*o,n=30*o,i=365*o;return t<a?`${Math.max(1,Math.floor(t/r))}m`:t<o?`${Math.floor(t/a)}h`:t<s?`${Math.floor(t/o)}d ago`:t<5*s?`${Math.floor(t/s)}w ago`:t<i?`${Math.floor(t/n)}mo`:`${Math.floor(t/i)}y ago`},d=e=>e.toLowerCase().replace(/[-_]/g,"").trim(),P=(e,t)=>e?d(e)!==d(t):!1,z=e=>{const t=new Map;return e.forEach(r=>{t.set(r.id,r)}),Array.from(t.values())},U=e=>`__archived__:${e}`,j=(e,t)=>{const r=m(e.directory??null),a=m(e.project?.worktree??null),o=r??a;if(!o)return"unassigned";if(t&&o===t)return"project root";const n=(t&&o.startsWith(`${t}/`)?o.slice(t.length+1):o).split("/").filter(Boolean);return n[n.length-1]??"unassigned"},B=e=>e.replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase()),Y="0.75rem",p="size-4 shrink-0",M="min-w-0 truncate typography-ui-label font-normal",x=p,v=M,$="group relative my-0.5 flex w-full cursor-pointer items-center gap-1.5 rounded-xl px-3 py-2 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",K=$,O=e=>e?x:p,W=e=>e?v:M,u=1e3,c=60*u,l=60*c,C=e=>{const t=Math.max(0,e);return t<c?`${Math.floor(t/u)}s`:t<l?`${Math.floor(t/c)}m ${Math.floor(t%c/u)}s`:`${Math.floor(t/l)}h ${Math.floor(t%l/c)}m`},N=1e3,G=({sessionId:e,running:t,className:r})=>{const a=y(e),o=D(e),s=w(t,N),n=t?Math.max(0,s-(a??s)):o;if(n===void 0)return null;const i=C(n),f=t?`Active for ${i}`:`Last turn took ${i}`;return g.jsx("span",{className:h("shrink-0 tabular-nums",t?"text-primary":"text-[var(--status-info)]",r),"aria-label":f,title:f,children:i})};function H({label:e,className:t}){return g.jsx("span",{className:h("size-1.5 shrink-0 rounded-full bg-foreground",t),"aria-label":e,title:e})}export{H as S,G as a,k as b,U as c,z as d,M as e,E as f,I as g,O as h,W as i,K as j,$ as k,P as l,Y as m,B as n,R as o,j as r,p as s,T as t};
|