@pi-chamber/web 1.0.6-rc.4 → 1.0.6-rc.6
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-BZ--w7Lh.js → DiagramView-BxBfOrN5.js} +1 -1
- package/dist/assets/{DiffView-Dtn6otnT.js → DiffView-CSC9GMrb.js} +3 -3
- package/dist/assets/{FileSaveConflictDialog-p1ik30al.js → FileSaveConflictDialog-C_MNWp6w.js} +1 -1
- package/dist/assets/{FilesView-D0Z0VmQm.js → FilesView-DeN6KmNt.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-a27RksFo.js → GitHubDetailScaffold-CrtJwlqV.js} +2 -2
- package/dist/assets/{GitHubLinkPicker-B0CfzNfk.js → GitHubLinkPicker-g6w8K95J.js} +1 -1
- package/dist/assets/GitHubListPrimitives-lAi2ywE3.js +1 -0
- package/dist/assets/{GitView-BNkoaVYl.js → GitView-D9_em8Vx.js} +5 -5
- package/dist/assets/IssuesSurface-DCiHe6TE.js +7 -0
- package/dist/assets/{JsonTreeView-CEiJsFnP.js → JsonTreeView-D64mTfTx.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-418ChlsN.js → MarkdownRendererImpl-DwE90rTA.js} +3 -3
- package/dist/assets/PatchDiff-CcIwURzW.js +1 -0
- package/dist/assets/{PierreDiffViewer-CkuyY9ne.js → PierreDiffViewer-tN7awL0-.js} +2 -2
- package/dist/assets/PullRequestsSurface-iX4r3QlS.js +2 -0
- package/dist/assets/{SessionSwitcherContent-DkfjRgwv.js → SessionSwitcherContent-DrrM0ObM.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CEw8BEs6.js → SessionSwitcherDropdown-B9_0JwY7.js} +2 -2
- package/dist/assets/SessionUnreadDot-Bpgp2gLO.js +1 -0
- package/dist/assets/SettingsView-C4hec1iy.js +6 -0
- package/dist/assets/{SettingsWindow-D03Z9QyW.js → SettingsWindow-Bepcpy0R.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-CONTbZgX.js → StickyHorizontalScrollbar-DNsbTLS7.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DibddNlz.js → ToolOutputDialog-Dl9-vpvL.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-Bx7T1M2f.js → ToolPartDiffPreview-CLlHEPYD.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BY-mDMT8.js → VirtualizedFileDiff-D9OpUpR3.js} +4 -4
- package/dist/assets/{Virtualizer-cIf8dSOQ.js → Virtualizer-okhy9Aq3.js} +1 -1
- package/dist/assets/{collapsible-BhQdnj8G.js → collapsible-ZT74WYMA.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CzkFqhaU.js → computeVirtualFileMetrics-CDv_UBXL.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-CjCOK8EB.js → contextFileOpenGuard-BJ2sAhZG.js} +1 -1
- package/dist/assets/{fileTreeStatus-CPTpyKOV.js → fileTreeStatus-B2PDFobt.js} +2 -2
- package/dist/assets/{gitStatusPredicates-_GNbGCCb.js → gitStatusPredicates-BDdOjxH_.js} +1 -1
- package/dist/assets/{githubLink-CwIFogWd.js → githubLink-wwC2_C_9.js} +2 -2
- package/dist/assets/index-BaLCg7tL.css +1 -0
- package/dist/assets/{index-DjOKW10B.js → index-MXKT8Ir9.js} +1 -1
- package/dist/assets/index-fmzQmSSv.js +11 -0
- package/dist/assets/{main-C51a3z3b.js → main-CnW7qm2b.js} +2 -2
- package/dist/assets/{main-1wmEZ4Is.js → main-DmHVgAh0.js} +4 -4
- package/dist/assets/{markdownCore-Dsr6dY5C.js → markdownCore-DOFhfL5i.js} +2 -2
- package/dist/assets/{miniChat-DCxCx1fF.js → miniChat-D_Wl2jlx.js} +2 -2
- package/dist/assets/{mobile-D6Ac2Mu3.js → mobile-Cl-KcfGW.js} +2 -2
- package/dist/assets/{nativeFileSave-P_Eg5Dgb.js → nativeFileSave-B4Rg6n8u.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-DjDyjZ1C.js → pi-session-focus-preference-BqEU9Iq6.js} +3 -3
- package/dist/assets/{renderDiffWithHighlighter-CK_inhQE.js → renderDiffWithHighlighter-U7WjeGm9.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-wBNgFl0U.js → renderElectronMiniChatApp-BJxNc9OP.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-B_PFeRW5.js → renderFileWithHighlighter-DiwpFgMp.js} +1 -1
- package/dist/assets/{renderMobileApp-B3mhxGnb.js → renderMobileApp-d5KpyvBc.js} +3 -3
- package/dist/assets/runtimeEndpointReset-Cd4yJDsk.js +62 -0
- package/dist/assets/{runtimeSurface-C3YPOBlg.js → runtimeSurface-X62LLBLv.js} +1 -1
- package/dist/assets/{useAppFontEffects-CoFst31H.js → useAppFontEffects-FKnY7Fe2.js} +92 -92
- package/dist/assets/useGitHubRemoteSearch-4QMXIODG.js +1 -0
- package/dist/assets/{useSwitcherItems-DHCCg4GF.js → useSwitcherItems-DtCNsq8u.js} +1 -1
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-B9_YeZyx.js → vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js} +1 -1
- package/dist/assets/{vendor-base-ui-CKSCJw-4.js → vendor-base-ui-BCqPBzDj.js} +1 -1
- package/dist/assets/{vendor-boot-Ciu-Edvy.js → vendor-boot-3SaHYVb1.js} +1 -1
- package/dist/assets/{vendor-capacitor-app-Bpy_aPMq.js → vendor-capacitor-app-NbQ-WiPS.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-DO8AIjrZ.js → vendor-capacitor-keyboard-CgrHt8iN.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-SQkytwUW.js → vendor-capacitor-status-bar-CWt0OF5t.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-CInQsE8a.js → vendor-codemirror-autocomplete-WThuuUAz.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-QbsN3LGE.js → vendor-codemirror-lang-angular-BbLGCxF6.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-BT5U7lxV.js → vendor-codemirror-lang-cpp-Cceks-9O.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-dF-Dxbty.js → vendor-codemirror-lang-css-D1wpUg3Z.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-e4dp1bar.js → vendor-codemirror-lang-go-Cv0zXHHM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DKcbBVQ4.js → vendor-codemirror-lang-html-DbL8oT9H.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CB2-FWv6.js → vendor-codemirror-lang-java-CNugenuC.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-B1zJk7xE.js → vendor-codemirror-lang-javascript-Bx_FIyZF.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BsERjdSd.js → vendor-codemirror-lang-jinja-DDGjB3Zq.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-C0pZ0NhY.js → vendor-codemirror-lang-json-DIvqf9Pb.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-_N9HmR4h.js → vendor-codemirror-lang-less-D8r9dGG1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-D02xJRCD.js → vendor-codemirror-lang-liquid-B24mguYi.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-_6ojeUuZ.js → vendor-codemirror-lang-markdown-v3yG2sbf.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DguCnbJA.js → vendor-codemirror-lang-php-BcZGalqy.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-Byr5gw5f.js → vendor-codemirror-lang-python-b-JqEwQy.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-DN6Wh0eK.js → vendor-codemirror-lang-rust-B1uZxDW-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DOlEW7q1.js → vendor-codemirror-lang-sass-DqPrngKp.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BJzE9Dby.js → vendor-codemirror-lang-sql-UyCnpt-k.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-DR8E-2nr.js → vendor-codemirror-lang-vue-xDwYkovV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-n6lcDH5S.js → vendor-codemirror-lang-wast-CF3169p_.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Cf2lmlmY.js → vendor-codemirror-lang-xml-FCtVhuOb.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-DSR_E0yh.js → vendor-codemirror-lang-yaml-g0sPmAnv.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CSid5JuX.js → vendor-codemirror-language-data-B03xgzP2.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-8lY3lt6q.js → vendor-codemirror-search-Dw3Wpu15.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-DZYTDKiD.js → vendor-lezer-cpp-Cu3E-KUI.js} +1 -1
- package/dist/assets/{vendor-lezer-css-6qV4fYNQ.js → vendor-lezer-css-Cb8vp67u.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BDi_Iblq.js → vendor-lezer-go-BTsIaOm7.js} +1 -1
- package/dist/assets/{vendor-lezer-html-BjqcY-oJ.js → vendor-lezer-html-UQMsUwj-.js} +1 -1
- package/dist/assets/{vendor-lezer-java-J2BXqz1h.js → vendor-lezer-java-BIWrFrAx.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-CiQ9F8yX.js → vendor-lezer-javascript-BH2Etgoy.js} +1 -1
- package/dist/assets/{vendor-lezer-json-BxN83KKR.js → vendor-lezer-json-CE-QUCwM.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-BVsDua_K.js → vendor-lezer-lr-HY6Yc0Vr.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-BkMtRQ3X.js → vendor-lezer-markdown-xFL3Evwf.js} +1 -1
- package/dist/assets/{vendor-lezer-php-B3XqnXdP.js → vendor-lezer-php-Cr_mQGrG.js} +1 -1
- package/dist/assets/{vendor-lezer-python-D342CidI.js → vendor-lezer-python-BNRFWCb0.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-Dbfg_4LA.js → vendor-lezer-rust-BvfOK5cU.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-ClxPaFt1.js → vendor-lezer-sass-qoxiLisk.js} +1 -1
- package/dist/assets/{vendor-lezer-xml-I_S6FQ1u.js → vendor-lezer-xml--x8SSpqU.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-COA6HWLP.js → vendor-lezer-yaml-BDo1JaEr.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-7IE2zVmx.js → vendor-replit-codemirror-vim-D1Fe7FiY.js} +1 -1
- package/dist/assets/{web-components-CzkvK_V5.js → web-components-D5QImbWv.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/pi/archive-store.js +38 -10
- package/server/lib/pi/archive-store.test.js +10 -0
- package/server/lib/pi/routes.js +65 -18
- package/server/lib/pi/routes.test.js +189 -8
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +5 -1
- package/server/lib/pi/session-daemon/session-daemon-engines.test.js +18 -0
- package/server/lib/pi/session-daemon/session-daemon.js +24 -1
- package/server/lib/pi/session-shelf-store.js +155 -84
- package/server/lib/pi/session-shelf-store.test.js +134 -33
- package/server/lib/pi/ui-settings-store.js +59 -0
- package/server/lib/pi/ui-settings-store.test.js +105 -6
- package/dist/assets/GitHubListPrimitives-LFdR70l6.js +0 -1
- package/dist/assets/IssuesSurface-D4kD7_VW.js +0 -7
- package/dist/assets/PatchDiff-BtOv_oLB.js +0 -1
- package/dist/assets/PullRequestsSurface-PML07zr-.js +0 -2
- package/dist/assets/SessionUnreadDot-DXUn8-ss.js +0 -1
- package/dist/assets/SettingsView-BvUeFUqw.js +0 -6
- package/dist/assets/index-Cfrwo5uQ.js +0 -11
- package/dist/assets/index-D7k62S9M.css +0 -1
- package/dist/assets/runtimeEndpointReset-D8lAOCUB.js +0 -62
- package/dist/assets/useGitHubRemoteSearch-C0-6hhMJ.js +0 -1
|
@@ -39,6 +39,7 @@ const PORTABLE_FIELDS = new Set([
|
|
|
39
39
|
'weekStartPreference',
|
|
40
40
|
'sidebarViewMode',
|
|
41
41
|
'sidebarAutoSettleAfterDays',
|
|
42
|
+
'sessionAutoArchiveAfterDays', 'sessionAutoDeleteAfterDays',
|
|
42
43
|
'expandedEditorToolbar',
|
|
43
44
|
'wrapLinesByDefault',
|
|
44
45
|
'fontSize', 'terminalFontSize', 'editorFontSize', 'uiFont', 'monoFont', 'padding',
|
|
@@ -71,6 +72,17 @@ const LOCAL_FIELDS = new Set([
|
|
|
71
72
|
'hasManagedRemoteTunnelToken', 'desktopUiPassword', 'desktopLocalClientToken',
|
|
72
73
|
]);
|
|
73
74
|
|
|
75
|
+
const RETENTION_FIELDS = ['sessionAutoArchiveAfterDays', 'sessionAutoDeleteAfterDays'];
|
|
76
|
+
const MAX_RETENTION_DAYS = 365;
|
|
77
|
+
const NEW_INSTALL_AUTO_ARCHIVE_DAYS = 7;
|
|
78
|
+
// Old "delete after N days" now archives at N and deletes this long after
|
|
79
|
+
// archiving, so nothing is deleted sooner than it used to be.
|
|
80
|
+
const MIGRATED_DELETE_AFTER_ARCHIVE_DAYS = 30;
|
|
81
|
+
// The old client's default when autoDeleteAfterDays was never saved.
|
|
82
|
+
const LEGACY_RETENTION_DAYS = 30;
|
|
83
|
+
|
|
84
|
+
const isRetentionDays = (value) => Number.isInteger(value) && value >= 0 && value <= MAX_RETENTION_DAYS;
|
|
85
|
+
|
|
74
86
|
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
75
87
|
|
|
76
88
|
const validateValue = (value, depth = 0) => {
|
|
@@ -108,6 +120,34 @@ const readRecord = async (file, fs) => {
|
|
|
108
120
|
}
|
|
109
121
|
};
|
|
110
122
|
|
|
123
|
+
const legacyRetentionDays = (value) => {
|
|
124
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return LEGACY_RETENTION_DAYS;
|
|
125
|
+
return Math.max(1, Math.min(MAX_RETENTION_DAYS, Math.round(value)));
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Starting values for the auto-archive and auto-delete settings. Runs once:
|
|
129
|
+
// after this the portable file holds both fields and they are never removed.
|
|
130
|
+
// A new install (nothing saved in either file) gets 7/0. An existing install
|
|
131
|
+
// keeps what the old retention fields did, except "delete after N days" now
|
|
132
|
+
// archives at N and deletes 30 days after that.
|
|
133
|
+
const decideRetention = ({ portable, runtime }) => {
|
|
134
|
+
const isNewInstall = Object.keys(selectFields(portable, PORTABLE_FIELDS)).length === 0
|
|
135
|
+
&& Object.keys(selectFields(portable, LOCAL_FIELDS)).length === 0
|
|
136
|
+
&& Object.keys(selectFields(runtime, LOCAL_FIELDS)).length === 0;
|
|
137
|
+
if (isNewInstall) {
|
|
138
|
+
return { sessionAutoArchiveAfterDays: NEW_INSTALL_AUTO_ARCHIVE_DAYS, sessionAutoDeleteAfterDays: 0 };
|
|
139
|
+
}
|
|
140
|
+
if (portable.autoDeleteEnabled !== true) {
|
|
141
|
+
return { sessionAutoArchiveAfterDays: 0, sessionAutoDeleteAfterDays: 0 };
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
sessionAutoArchiveAfterDays: legacyRetentionDays(portable.autoDeleteAfterDays),
|
|
145
|
+
sessionAutoDeleteAfterDays: portable.sessionRetentionAction === 'delete' ? MIGRATED_DELETE_AFTER_ARCHIVE_DAYS : 0,
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const hasRetentionDecision = (portable) => RETENTION_FIELDS.every((field) => isRetentionDays(portable[field]));
|
|
150
|
+
|
|
111
151
|
export const createDockerInitialLocalSettings = () => {
|
|
112
152
|
const projectId = `path_${Buffer.from(DOCKER_WORKSPACE).toString('base64url')}`;
|
|
113
153
|
return {
|
|
@@ -134,6 +174,9 @@ export const createPiUiSettingsStore = ({
|
|
|
134
174
|
const portableRoot = await readRecord(file, fs);
|
|
135
175
|
const runtimeRoot = await readRecord(runtimeFile, fs);
|
|
136
176
|
const migrated = portableRoot[PORTABLE_SETTINGS_MARKER] === PORTABLE_SETTINGS_VERSION;
|
|
177
|
+
const retention = hasRetentionDecision(portableRoot)
|
|
178
|
+
? null
|
|
179
|
+
: decideRetention({ portable: portableRoot, runtime: runtimeRoot });
|
|
137
180
|
|
|
138
181
|
if (!migrated) {
|
|
139
182
|
const isFreshStore = Object.keys(portableRoot).length === 0 && Object.keys(runtimeRoot).length === 0;
|
|
@@ -145,6 +188,7 @@ export const createPiUiSettingsStore = ({
|
|
|
145
188
|
const migratedPortable = {
|
|
146
189
|
[PORTABLE_SETTINGS_MARKER]: PORTABLE_SETTINGS_VERSION,
|
|
147
190
|
...selectFields(portableRoot, PORTABLE_FIELDS),
|
|
191
|
+
...retention,
|
|
148
192
|
};
|
|
149
193
|
// Local state goes first. A failure cannot strand host state only in a
|
|
150
194
|
// portable file that a later successful write might replace.
|
|
@@ -153,6 +197,16 @@ export const createPiUiSettingsStore = ({
|
|
|
153
197
|
return { ...selectFields(migratedPortable, PORTABLE_FIELDS), ...selectFields(migratedRuntime, LOCAL_FIELDS) };
|
|
154
198
|
}
|
|
155
199
|
|
|
200
|
+
if (retention) {
|
|
201
|
+
// Rewrite only the portable file; local state is already in its own file.
|
|
202
|
+
const decidedPortable = { ...portableRoot, ...retention };
|
|
203
|
+
await writeRecord(file, decidedPortable, fs);
|
|
204
|
+
return {
|
|
205
|
+
...selectFields(decidedPortable, PORTABLE_FIELDS),
|
|
206
|
+
...selectFields(runtimeRoot, LOCAL_FIELDS),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
156
210
|
return {
|
|
157
211
|
...selectFields(portableRoot, PORTABLE_FIELDS),
|
|
158
212
|
...selectFields(runtimeRoot, LOCAL_FIELDS),
|
|
@@ -176,6 +230,11 @@ export const createPiUiSettingsStore = ({
|
|
|
176
230
|
throw new Error('UI_SETTINGS_INVALID');
|
|
177
231
|
}
|
|
178
232
|
}
|
|
233
|
+
for (const field of RETENTION_FIELDS) {
|
|
234
|
+
if (Object.hasOwn(changes, field) && !isRetentionDays(changes[field])) {
|
|
235
|
+
throw new Error('UI_SETTINGS_INVALID');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
179
238
|
return runMutation(async () => {
|
|
180
239
|
const current = await readLocked();
|
|
181
240
|
const portableChanges = selectFields(changes, PORTABLE_FIELDS);
|
|
@@ -12,12 +12,17 @@ const makeStore = async () => {
|
|
|
12
12
|
return { file, runtimeFile, store: createPiUiSettingsStore({ file, runtimeFile }) };
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// What a fresh store decides for the auto-archive and auto-delete settings,
|
|
16
|
+
// and what an existing install with retention off maps to.
|
|
17
|
+
const NEW_INSTALL_RETENTION = { sessionAutoArchiveAfterDays: 7, sessionAutoDeleteAfterDays: 0 };
|
|
18
|
+
const RETENTION_OFF = { sessionAutoArchiveAfterDays: 0, sessionAutoDeleteAfterDays: 0 };
|
|
19
|
+
|
|
15
20
|
const readJson = async (file) => JSON.parse(await readFile(file, 'utf8'));
|
|
16
21
|
|
|
17
22
|
describe('Pi UI settings store', () => {
|
|
18
23
|
it('distinguishes malformed persisted settings from a fresh store', async () => {
|
|
19
24
|
const { file, store } = await makeStore();
|
|
20
|
-
await expect(store.read()).resolves.toEqual(
|
|
25
|
+
await expect(store.read()).resolves.toEqual(NEW_INSTALL_RETENTION);
|
|
21
26
|
await writeFile(file, '{broken');
|
|
22
27
|
await expect(store.read()).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
23
28
|
});
|
|
@@ -65,7 +70,7 @@ describe('Pi UI settings store', () => {
|
|
|
65
70
|
runtimeFile: existingRuntimeFile,
|
|
66
71
|
initialLocalSettings,
|
|
67
72
|
});
|
|
68
|
-
await expect(existingStore.read()).resolves.toEqual({ themeId: 'nord' });
|
|
73
|
+
await expect(existingStore.read()).resolves.toEqual({ themeId: 'nord', ...RETENTION_OFF });
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
it('migrates a flat settings file into portable and local allowlists', async () => {
|
|
@@ -87,6 +92,7 @@ describe('Pi UI settings store', () => {
|
|
|
87
92
|
await expect(readJson(file)).resolves.toEqual({
|
|
88
93
|
__pichamberSettingsScope: 'portable-v1',
|
|
89
94
|
themeId: 'nord',
|
|
95
|
+
...RETENTION_OFF,
|
|
90
96
|
});
|
|
91
97
|
await expect(readJson(runtimeFile)).resolves.toEqual({
|
|
92
98
|
homeDirectory: '/old-home',
|
|
@@ -105,6 +111,7 @@ describe('Pi UI settings store', () => {
|
|
|
105
111
|
|
|
106
112
|
await expect(target.store.read()).resolves.toEqual({
|
|
107
113
|
themeId: 'nord',
|
|
114
|
+
...NEW_INSTALL_RETENTION,
|
|
108
115
|
homeDirectory: '/root',
|
|
109
116
|
projects: [{ id: 'two', path: '/root/project' }],
|
|
110
117
|
});
|
|
@@ -118,12 +125,14 @@ describe('Pi UI settings store', () => {
|
|
|
118
125
|
]);
|
|
119
126
|
await expect(store.read()).resolves.toEqual({
|
|
120
127
|
themeId: 'dark',
|
|
128
|
+
...NEW_INSTALL_RETENTION,
|
|
121
129
|
projects: [{ id: 'one', path: '/one' }],
|
|
122
130
|
desktopCloseToTrayEnabled: false,
|
|
123
131
|
});
|
|
124
132
|
await expect(readJson(file)).resolves.toEqual({
|
|
125
133
|
__pichamberSettingsScope: 'portable-v1',
|
|
126
134
|
themeId: 'dark',
|
|
135
|
+
...NEW_INSTALL_RETENTION,
|
|
127
136
|
});
|
|
128
137
|
await expect(readJson(runtimeFile)).resolves.toEqual({
|
|
129
138
|
projects: [{ id: 'one', path: '/one' }],
|
|
@@ -142,6 +151,7 @@ describe('Pi UI settings store', () => {
|
|
|
142
151
|
await expect(readJson(file)).resolves.toEqual({
|
|
143
152
|
__pichamberSettingsScope: 'portable-v1',
|
|
144
153
|
themeId: 'dark',
|
|
154
|
+
...NEW_INSTALL_RETENTION,
|
|
145
155
|
});
|
|
146
156
|
await expect(readJson(runtimeFile)).resolves.toEqual({ desktopUpdateChannel: 'rc', serverUpdateChannel: 'stable' });
|
|
147
157
|
await expect(store.write({ desktopUpdateChannel: 'beta' })).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
@@ -242,26 +252,28 @@ describe('Pi UI settings store', () => {
|
|
|
242
252
|
const { file, runtimeFile, store } = await makeStore();
|
|
243
253
|
|
|
244
254
|
const writeResult = await store.write({ sidebarViewMode: 'folder', unknownField: 'drop-me' });
|
|
245
|
-
expect(writeResult).toEqual({ sidebarViewMode: 'folder' });
|
|
255
|
+
expect(writeResult).toEqual({ sidebarViewMode: 'folder', ...NEW_INSTALL_RETENTION });
|
|
246
256
|
|
|
247
257
|
const readResult = await store.read();
|
|
248
|
-
expect(readResult).toEqual({ sidebarViewMode: 'folder' });
|
|
258
|
+
expect(readResult).toEqual({ sidebarViewMode: 'folder', ...NEW_INSTALL_RETENTION });
|
|
249
259
|
|
|
250
260
|
const portable = await readJson(file);
|
|
251
261
|
expect(portable).toEqual({
|
|
252
262
|
__pichamberSettingsScope: 'portable-v1',
|
|
253
263
|
sidebarViewMode: 'folder',
|
|
264
|
+
...NEW_INSTALL_RETENTION,
|
|
254
265
|
});
|
|
255
266
|
|
|
256
267
|
const runtime = await readJson(runtimeFile);
|
|
257
268
|
expect(runtime).toEqual({});
|
|
258
269
|
|
|
259
270
|
const updatedResult = await store.write({ sidebarViewMode: 'timeline' });
|
|
260
|
-
expect(updatedResult).toEqual({ sidebarViewMode: 'timeline' });
|
|
261
|
-
expect(await store.read()).toEqual({ sidebarViewMode: 'timeline' });
|
|
271
|
+
expect(updatedResult).toEqual({ sidebarViewMode: 'timeline', ...NEW_INSTALL_RETENTION });
|
|
272
|
+
expect(await store.read()).toEqual({ sidebarViewMode: 'timeline', ...NEW_INSTALL_RETENTION });
|
|
262
273
|
expect(await readJson(file)).toEqual({
|
|
263
274
|
__pichamberSettingsScope: 'portable-v1',
|
|
264
275
|
sidebarViewMode: 'timeline',
|
|
276
|
+
...NEW_INSTALL_RETENTION,
|
|
265
277
|
});
|
|
266
278
|
});
|
|
267
279
|
|
|
@@ -274,6 +286,7 @@ describe('Pi UI settings store', () => {
|
|
|
274
286
|
expect(await readJson(file)).toEqual({
|
|
275
287
|
__pichamberSettingsScope: 'portable-v1',
|
|
276
288
|
notifyOnInputNeeded: false,
|
|
289
|
+
...NEW_INSTALL_RETENTION,
|
|
277
290
|
});
|
|
278
291
|
|
|
279
292
|
await expect(store.write({ notifyOnInputNeeded: true })).resolves.toMatchObject({
|
|
@@ -290,6 +303,92 @@ describe('Pi UI settings store', () => {
|
|
|
290
303
|
await expect(store.write(changes)).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
291
304
|
});
|
|
292
305
|
|
|
306
|
+
describe('session retention starting values', () => {
|
|
307
|
+
const seed = async (portable, runtime) => {
|
|
308
|
+
const target = await makeStore();
|
|
309
|
+
if (portable !== undefined) await writeFile(target.file, JSON.stringify(portable));
|
|
310
|
+
if (runtime !== undefined) await writeFile(target.runtimeFile, JSON.stringify(runtime));
|
|
311
|
+
return target;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
it('starts a new install at auto-archive 7 and auto-delete 0, and writes it', async () => {
|
|
315
|
+
for (const portable of [undefined, {}, { __pichamberSettingsScope: 'portable-v1' }]) {
|
|
316
|
+
const { file, store } = await seed(portable);
|
|
317
|
+
await expect(store.read()).resolves.toEqual({
|
|
318
|
+
sessionAutoArchiveAfterDays: 7,
|
|
319
|
+
sessionAutoDeleteAfterDays: 0,
|
|
320
|
+
});
|
|
321
|
+
expect(await readJson(file)).toEqual({
|
|
322
|
+
__pichamberSettingsScope: 'portable-v1',
|
|
323
|
+
sessionAutoArchiveAfterDays: 7,
|
|
324
|
+
sessionAutoDeleteAfterDays: 0,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('maps each old retention combination on an existing install', async () => {
|
|
330
|
+
const cases = [
|
|
331
|
+
[{ themeId: 'nord' }, 0, 0],
|
|
332
|
+
[{ autoDeleteEnabled: false, sessionRetentionAction: 'delete', autoDeleteAfterDays: 10 }, 0, 0],
|
|
333
|
+
[{ autoDeleteEnabled: true, sessionRetentionAction: 'archive', autoDeleteAfterDays: 14 }, 14, 0],
|
|
334
|
+
[{ autoDeleteEnabled: true, sessionRetentionAction: 'delete', autoDeleteAfterDays: 21 }, 21, 30],
|
|
335
|
+
[{ autoDeleteEnabled: true }, 30, 0],
|
|
336
|
+
[{ autoDeleteEnabled: true, sessionRetentionAction: 'delete', autoDeleteAfterDays: 900 }, 365, 30],
|
|
337
|
+
];
|
|
338
|
+
for (const [old, archive, del] of cases) {
|
|
339
|
+
for (const marked of [false, true]) {
|
|
340
|
+
const portable = marked ? { __pichamberSettingsScope: 'portable-v1', ...old } : old;
|
|
341
|
+
const { file, store } = await seed(portable);
|
|
342
|
+
const settings = await store.read();
|
|
343
|
+
expect([settings.sessionAutoArchiveAfterDays, settings.sessionAutoDeleteAfterDays]).toEqual([archive, del]);
|
|
344
|
+
const saved = await readJson(file);
|
|
345
|
+
expect([saved.sessionAutoArchiveAfterDays, saved.sessionAutoDeleteAfterDays]).toEqual([archive, del]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('treats saved local state as an existing install', async () => {
|
|
351
|
+
const { store } = await seed({ __pichamberSettingsScope: 'portable-v1' }, { projects: [{ id: 'one', path: '/one' }] });
|
|
352
|
+
await expect(store.read()).resolves.toMatchObject({
|
|
353
|
+
sessionAutoArchiveAfterDays: 0,
|
|
354
|
+
sessionAutoDeleteAfterDays: 0,
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('decides once and keeps later choices', async () => {
|
|
359
|
+
const { store } = await seed({ autoDeleteEnabled: true, sessionRetentionAction: 'delete', autoDeleteAfterDays: 5 });
|
|
360
|
+
await expect(store.read()).resolves.toMatchObject({ sessionAutoArchiveAfterDays: 5, sessionAutoDeleteAfterDays: 30 });
|
|
361
|
+
await store.write({ sessionAutoArchiveAfterDays: 0, sessionAutoDeleteAfterDays: 0, autoDeleteAfterDays: 60 });
|
|
362
|
+
await expect(store.read()).resolves.toMatchObject({
|
|
363
|
+
sessionAutoArchiveAfterDays: 0,
|
|
364
|
+
sessionAutoDeleteAfterDays: 0,
|
|
365
|
+
autoDeleteEnabled: true,
|
|
366
|
+
autoDeleteAfterDays: 60,
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('decides before the first write', async () => {
|
|
371
|
+
const { store } = await seed({ autoDeleteEnabled: true, sessionRetentionAction: 'archive', autoDeleteAfterDays: 9 });
|
|
372
|
+
await expect(store.write({ themeId: 'dark' })).resolves.toMatchObject({
|
|
373
|
+
themeId: 'dark',
|
|
374
|
+
sessionAutoArchiveAfterDays: 9,
|
|
375
|
+
sessionAutoDeleteAfterDays: 0,
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('rejects values outside off or 1 to 365 days', async () => {
|
|
380
|
+
const { store } = await makeStore();
|
|
381
|
+
for (const value of [-1, 366, 1.5, '7', null]) {
|
|
382
|
+
await expect(store.write({ sessionAutoArchiveAfterDays: value })).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
383
|
+
await expect(store.write({ sessionAutoDeleteAfterDays: value })).rejects.toThrow('UI_SETTINGS_INVALID');
|
|
384
|
+
}
|
|
385
|
+
await expect(store.write({ sessionAutoArchiveAfterDays: 365, sessionAutoDeleteAfterDays: 1 })).resolves.toMatchObject({
|
|
386
|
+
sessionAutoArchiveAfterDays: 365,
|
|
387
|
+
sessionAutoDeleteAfterDays: 1,
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
293
392
|
it('keeps a symlinked settings.json and writes through to its target', async () => {
|
|
294
393
|
const root = await mkdtemp(join(tmpdir(), 'pichamber-ui-settings-'));
|
|
295
394
|
const dotfiles = join(root, 'dotfiles');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-boot-Ciu-Edvy.js";import{R as u}from"./vendor-react-Bz1tRBxM.js";import{I as o,B as l,b2 as f}from"./useAppFontEffects-CoFst31H.js";import{f as m}from"./index-Cfrwo5uQ.js";import{R as b,S as g}from"./GitHubDetailScaffold-a27RksFo.js";const G=({options:r,value:s,onChange:t,ariaLabel:a})=>e.jsx("div",{role:"tablist","aria-label":a,className:"flex flex-wrap gap-1",children:r.map(i=>{const n=i.id===s;return e.jsx(l,{type:"button",variant:"chip",size:"xs",role:"tab","aria-selected":n,"aria-pressed":n,onClick:()=>t(i.id),className:m(n&&"bg-interactive-selection text-interactive-selection-foreground"),children:i.label},i.id)})}),S=({value:r,onChange:s,placeholder:t,ariaLabel:a})=>{const[i,n]=u.useState(r);u.useEffect(()=>n(r),[r]);const c=u.useRef(s);return c.current=s,u.useEffect(()=>{if(i===r)return;const d=setTimeout(()=>c.current(i),80);return()=>clearTimeout(d)},[i,r]),e.jsxs("span",{className:"relative block min-w-0 flex-1",children:[e.jsx(o,{name:"search","aria-hidden":"true",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(f,{value:i,onChange:d=>n(d.target.value),placeholder:t??"Search","aria-label":a??"Search",className:"h-8 pl-7"})]})},H=({rows:r=7,label:s})=>{const t=["w-3/5","w-2/5","w-1/2","w-2/3","w-2/5","w-3/5","w-1/2"],a=["w-2/5","w-1/3","w-2/5","w-1/4","w-1/3","w-2/5","w-1/3"];return e.jsx("div",{role:"status","aria-label":s,className:"flex animate-pulse flex-col p-1",children:Array.from({length:r},(i,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-2",children:[e.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0 rounded-full bg-muted-foreground/15"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:m("block h-3.5 rounded bg-muted-foreground/15",t[n%t.length])}),e.jsx("span",{"aria-hidden":"true",className:m("block h-3 rounded bg-muted-foreground/15",a[n%a.length])})]}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-12 rounded bg-muted-foreground/15"}),e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-10 rounded bg-muted-foreground/15"})]})]},n))})},p=({icon:r,title:s,description:t,action:a})=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[e.jsx(o,{name:r,"aria-hidden":"true",className:"size-6 text-subtle-foreground"}),e.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:s}),t?e.jsx("p",{className:"max-w-60 typography-micro text-muted-foreground",children:t}):null,a]}),j=({hasMore:r,isLoading:s,onLoadMore:t,label:a})=>r?e.jsx("div",{className:"flex justify-center px-2 py-2",children:e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:s,children:s?"Loading…":a??"Load more"})}):null,z=({summary:r,summaryTitle:s})=>e.jsx("footer",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:e.jsx("span",{className:"min-w-0 truncate",title:s??r,children:r})}),C=({matchSummary:r,searching:s,onSearchAll:t})=>e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:r,children:r}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:t,disabled:s,children:s?"Searching…":"Search all on GitHub"})]}),R=({title:r,isSearching:s,error:t,hasResults:a,hasMore:i,isLoadingMore:n,onRetry:c,onLoadMore:d,children:h})=>{const x=t?.kind==="rate-limited"?"GitHub rate limit reached — try again in a little while.":"Couldn't search GitHub.";return e.jsxs("section",{"aria-label":r,className:"border-t border-border/60",children:[e.jsx("p",{className:"px-3 pb-0.5 pt-1.5 typography-micro font-medium text-muted-foreground",children:r}),t&&!a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 typography-micro text-muted-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:c,children:"Retry"})]}):null,t&&a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:c,children:"Retry"})]}):null,!t&&s&&!a?e.jsx("p",{className:"px-3 py-2 typography-micro text-muted-foreground",role:"status",children:"Searching GitHub…"}):null,a?e.jsx("div",{className:"flex flex-col p-1 pt-0.5",children:h}):null,!t&&a?e.jsx(j,{hasMore:i,isLoading:n,onLoadMore:d,label:"Load more results"}):null]})},E=({error:r,onRetry:s,label:t})=>{if(!b(r))return null;const a=g(r);return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert","aria-label":`${t} failed to load`,children:[e.jsx(o,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[t," failed to load",r?` — ${a}`:""]}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:s,children:"Retry"})]})},L=({number:r,kindLabel:s,onOpen:t})=>e.jsx("div",{className:"flex flex-col p-1",children:e.jsxs("button",{type:"button",onClick:t,"aria-label":`Open ${s} #${r}`,className:"group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-interactive-hover",children:[e.jsx("span",{className:"inline-flex w-4 shrink-0 items-center justify-center",children:e.jsx(o,{name:"external-link",className:"size-3.5 text-muted-foreground","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:["Open #",r]}),e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"Not in the loaded list"})]})}),I=({onRetry:r})=>e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-3 py-1.5 typography-micro text-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Showing saved results — last refresh failed"}),e.jsx("button",{type:"button",onClick:r,className:"shrink-0 underline","aria-label":"Retry GitHub refresh",children:"Retry"})]}),T=({kind:r,noItemsTitle:s,noItemsBody:t,noItemsIcon:a,noItemsAction:i,onClearFilters:n})=>r==="no-match"?e.jsx(p,{icon:"search",title:"Nothing matches these filters",description:"Try fewer words, or search by number, author, or label.",action:n?e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Clear filters"}):void 0}):e.jsx(p,{icon:a??"git-pull-request",title:s,description:t,action:i});export{H as G,E as S,p as a,I as b,S as c,T as d,L as e,j as f,R as g,C as h,z as i,G as j};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Cfrwo5uQ.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-D7k62S9M.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as t}from"./vendor-boot-Ciu-Edvy.js";import{R as u}from"./vendor-react-Bz1tRBxM.js";import{i as Pe,j as ot,p as lt,l as it,m as ct,r as ut,b as dt,c as mt,G as ht,h as Ne,u as ft,n as bt,o as gt}from"./useGitHubRemoteSearch-C0-6hhMJ.js";import{as as xt,B as j,I as R,av as pt,aw as yt,aB as vt,ax as Ct,ay as jt,aC as wt,z as $e,h as kt,t as P,d$ as St,o as ye,b2 as Oe,a$ as Re,b0 as Le,b1 as Ee,dT as Nt,dU as Rt,bu as xe,bM as Lt,y as Et}from"./useAppFontEffects-CoFst31H.js";import{be as It,bf as Ie,bg as pe,bh as Ae,bi as ce,bj as At,bk as ue,aT as Dt,L as _e,b2 as Tt,a$ as Gt,bl as Ht}from"./runtimeEndpointReset-D8lAOCUB.js";import{_ as Bt}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as Mt,d as Ft}from"./vendor-zustand-CXhN0IMY.js";import{n as Ue,o as zt}from"./index-Cfrwo5uQ.js";import{a as Ke,u as Pt,p as $t,r as Ot,t as De,x as _t,z as Ut,A as Kt,w as ie,y as Wt,B as oe,C as We,D as qt,T as Vt,E as Te,G as Qt,H as Jt,I as Yt,J as Zt,K as Ge}from"./GitHubDetailScaffold-a27RksFo.js";import{I as He,a as Xt,b as es,i as qe,c as ts,d as ss,s as as,g as le,e as ns,f as rs,h as Be,j as Me,C as os,k as ls,v as is}from"./githubLink-CwIFogWd.js";import{a as cs,f as us}from"./GitHubListPrimitives-LFdR70l6.js";import"./vendor-clsx-B-dksMZM.js";import"./runtimeSurface-C3YPOBlg.js";import"./nativeFileSave-P_Eg5Dgb.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./SessionUnreadDot-DXUn8-ss.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./vendor-dompurify-BGCr_sdL.js";const ve={state:"open",involvement:"all",labels:"",search:"",sort:"updated"},ds=3e4,ms=100,hs=50,Ve=(e,s)=>ue([e,"issues-collection",s]),Qe=(e,s)=>ue([e,"issues-remote",s.state,s.involvement,s.labels.trim(),s.q.trim()]),Ce=(e,s)=>ue([e,"issue-detail",s]),je=(e,s)=>ue([e,"issue-comments",s]),fs=e=>({state:e,perPage:ms}),bs=(e,s)=>({state:e.state,filter:e.involvement,q:e.q.trim()?e.q.trim():void 0,labels:e.labels.trim()?e.labels.trim():void 0,perPage:hs,...s?{cursor:s}:{}}),gs={set:e=>{typeof e=="function"?C.setState(s=>{const n={filtersByScope:s.filtersByScope,selectionByDirectory:s.selectionByDirectory};return e(n)}):C.setState(e)},get:()=>{const e=C.getState();return{filtersByScope:e.filtersByScope,selectionByDirectory:e.selectionByDirectory}}},g=At({openCollection:"open",closedCollection:"closed",defaultFilters:ve,freshWindowMs:ds,serverKind:"issues",errorFallback:"Issue request failed",collectionKeyFor:Ve,remoteKeyFor:Qe,detailKeyFor:Ce,commentsKeyFor:je,buildCollectionQuery:e=>({...fs(e)}),buildRemoteQuery:(e,s)=>({...bs(e,s)}),fetchList:async(e,s,n,r)=>{const l=await e.issuesList(s,n,r);return{items:l.items,nextCursor:l.nextCursor,fetchedAt:l.fetchedAt}},fetchDetail:async(e,s,n,r)=>e.issueGet(s,n,r),fetchComments:async(e,s,n,r,l)=>{const a=await e.issueComments(s,n,r,l);return{comments:a.comments,nextCursor:a.nextCursor,fetchedAt:a.fetchedAt}}},gs),C=Mt()(Ft((e,s)=>({...g.initialState,actionErrorByDetail:{},actingActions:{},setFilters:g.setFilters,resetFilters:g.resetFilters,selectIssue:g.select,ensureCollection:g.ensureCollection,ensureCollectionsFresh:g.ensureCollectionsFresh,prefetchClosedCollection:g.prefetchClosedCollection,loadMoreCollection:g.loadMoreCollection,refreshCollections:g.refreshCollections,searchRemote:g.searchRemote,loadMoreRemote:g.loadMoreRemote,dropRemoteForRepo:g.dropRemoteForRepo,refreshAllForScope:g.refreshAllForScope,ensureDetail:g.ensureDetail,refreshDetail:g.refreshDetail,ensureComments:g.ensureComments,loadMoreComments:g.loadMoreComments,refreshComments:g.refreshComments,updateIssue:async(n,r,l,a,d)=>{const b=Ae(r,l),o=Ce(r,l);if(s().actingActions[b])return{ok:!1,error:{kind:"failed",message:"An update is already in progress"}};e(x=>({actingActions:{...x.actingActions,[b]:!0},actionErrorByDetail:{...x.actionErrorByDetail,[b]:null}}));const c=g.resources.details.getEntry(o)?.data?.detail??null,y=c?.issue??null,w=y?{...y,title:a.title??y.title,body:a.body??y.body,state:a.state??y.state,stateReason:a.state!==void 0?a.stateReason??null:y.stateReason,labels:a.labels!==void 0?a.labels.map(x=>({name:x})):y.labels,assignees:a.assignees!==void 0?a.assignees.map(x=>({login:x})):y.assignees}:null;w&&c&&await g.resources.details.refresh(o,async()=>({detail:{...c,issue:w}})).catch(()=>null);try{return await d.issueUpdate(n,r,l,a),await pe(d,{directory:n,repo:r,kind:"issues",number:l}),s().dropRemoteForRepo(r),await s().refreshCollections(n,r,"both",d).catch(()=>null),await s().refreshDetail(n,r,l,d).catch(()=>null),e(x=>({actingActions:{...x.actingActions,[b]:!1}})),{ok:!0}}catch(x){const S=g.toStoreError(x);return c&&await g.resources.details.refresh(o,async()=>({detail:c})).catch(()=>null),e(f=>({actingActions:{...f.actingActions,[b]:!1},actionErrorByDetail:{...f.actionErrorByDetail,[b]:S}})),{ok:!1,error:S}}},addComment:async(n,r,l,a,d)=>{const b=Ae(r,l),o=je(r,l),c=a.trim(),y={id:-Date.now(),url:"",body:c,author:null,createdAt:new Date().toISOString(),updatedAt:null},w=g.resources.comments.getEntry(o)?.data??null;if(w){const x={comments:[...w.comments,y],nextCursor:w.nextCursor,fetchedAt:w.fetchedAt};await g.resources.comments.refresh(o,async()=>x).catch(()=>null)}try{return await d.issueComment(n,r,l,c),await pe(d,{directory:n,repo:r,kind:"issues",number:l}),await s().refreshComments(n,r,l,d).catch(()=>null),await s().refreshDetail(n,r,l,d).catch(()=>null),{ok:!0}}catch(x){const S=g.toStoreError(x);return w?await g.resources.comments.refresh(o,async()=>w).catch(()=>null):g.resources.comments.remove(o),e(f=>({actionErrorByDetail:{...f.actionErrorByDetail,[b]:S}})),{ok:!1,error:S}}},createIssue:async(n,r)=>{try{const l=await r.issueCreate(n.directory,n.repo,{title:n.title,body:n.body,labels:n.labels,assignees:n.assignees});return await pe(r,{directory:n.directory,repo:n.repo,kind:"issues"}),s().dropRemoteForRepo(n.repo),await s().refreshCollections(n.directory,n.repo,"both",r).catch(()=>null),{ok:!0,number:l.issue.number}}catch(l){return{ok:!1,error:g.toStoreError(l)}}},notifyAgentTurnComplete:n=>{const r=Ue((n||"").trim());if(!r)return;const l=s().selectionByDirectory[r];!l?.repo||typeof l.number!="number"||(g.markCollectionsStale(l.repo),Bt(async()=>{const{getRegisteredRuntimeAPIs:a}=await import("./index-Cfrwo5uQ.js").then(d=>d.cU);return{getRegisteredRuntimeAPIs:a}},__vite__mapDeps([0,1,2,3,4,5,6,7])).then(({getRegisteredRuntimeAPIs:a})=>{const d=a()?.github??null;if(d)return s().refreshDetail(r,l.repo,l.number,d)}).catch(()=>{}))},resetForRuntimeSwitch:()=>{g.resetCore(),e({actionErrorByDetail:{},actingActions:{}})}}),{name:"github-issues-store"}));typeof window<"u"&&zt(()=>{C.getState().resetForRuntimeSwitch()});const xs=e=>g.getLocalIndex(e),ps=(e,s)=>g.getLocalIndex(e).find(n=>n.number===s)??null,Fe=(e,s)=>ce(g.resources.collections,e?Ve(e,s):null),ys=(e,s)=>ce(g.resources.remote,e?Qe(e,s):null),vs=(e,s)=>ce(g.resources.details,e!=null&&s!=null?Ce(e,s):null),Cs=(e,s)=>ce(g.resources.comments,e!=null&&s!=null?je(e,s):null),js=(e,s)=>C(n=>!e||!s?ve:n.filtersByScope[It(e,s)]??ve),ws=e=>C(s=>e?s.selectionByDirectory[Ue(e)]??Ie:Ie),ks=e=>typeof e!="number"||e===0?null:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 typography-micro tabular-nums text-muted-foreground",title:`${e} comments`,"aria-label":`${e} comments`,children:[t.jsx(R,{name:"chat-1",className:"size-3.5"}),e]}),Ss=({items:e,hasMore:s,isLoadingMore:n,isLoading:r,isRefreshing:l,stale:a,error:d,filters:b,countComplete:o=!0,incompleteNotice:c=null,remote:y=null,numberJump:w=null,onFiltersChange:x,onClearFilters:S,onLoadMore:f,onRetry:p,onOpen:N,onNewIssue:k,headerActionsSlot:G=null,headerActionsPresentation:H="drawer"})=>{const z=b.state==="open"&&b.involvement==="all"&&!b.search.trim()&&!b.labels.trim(),{isMobile:D,isTablet:I}=xt(),B=D||I,T=G!=null,A=H??"drawer",$=T?A==="desktop"?t.jsxs(j,{type:"button",variant:"ghost",size:"sm",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-4"}),"New issue"]}):t.jsxs(j,{type:"button",variant:"ghost",size:"default",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-4"}),"New issue"]}):t.jsxs(j,{type:"button",variant:"ghost",size:B?"sm":"xs",onClick:k,"aria-label":"New issue",title:"New issue",children:[t.jsx(R,{name:"add",className:"size-3.5"}),"New issue"]}),O=u.useCallback(h=>t.jsx("li",{role:"listitem",children:t.jsx(Pe,{glyph:t.jsx(Ke,{kind:"issue",state:h.state}),number:`#${h.number}`,title:h.title,signals:ks(h.comments),meta:t.jsxs(t.Fragment,{children:[t.jsx(ot,{login:h.author?.login,avatarUrl:h.author?.avatarUrl}),t.jsx(lt,{labels:h.labels??[]})]}),updatedAt:h.updatedAt,onOpen:()=>N(h.number),ariaLabel:`Open issue #${h.number} ${h.title}`})},h.number),[N]);return t.jsx(it,{items:e,renderRow:O,hasMore:s,isLoadingMore:n,isLoading:r,isRefreshing:l,stale:a,error:d,searchValue:b.search,onSearchChange:h=>x({search:h}),searchPlaceholder:"Search issues, or label:bug",searchAriaLabel:"Search issues",toolbarControls:t.jsx(ct,{stateValue:b.state,stateOptions:He.map(h=>({id:h.id,label:h.label})),onStateChange:h=>x({state:h}),involvementValue:b.involvement,involvementOptions:es.map(h=>({id:h.id,label:h.label})),onInvolvementChange:h=>x({involvement:h}),labelsValue:b.labels,onLabelsChange:h=>x({labels:h}),sortValue:b.sort,sortOptions:Xt.map(h=>({id:h.id,label:h.label})),onSortChange:h=>x({sort:h}),sortAriaLabel:"Sort issues"}),primaryAction:$,headerActionsSlot:G,headerActionsPresentation:A,isDefaultFilters:z,stateLabel:He.find(h=>h.id===b.state)?.label??b.state,kindSingular:"issue",kindPlural:"issues",noItemsTitle:b.state==="open"?"No open issues":"No issues yet",noItemsBody:"Issues for this repository appear here.",noItemsIcon:"inbox-archive",noItemsAction:t.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:k,children:[t.jsx(R,{name:"add",className:"size-3.5"}),"New issue"]}),listAriaLabel:"Issues",skeletonLabel:"Loading issues",updatedAtOf:h=>h.updatedAt,countComplete:o,incompleteNotice:c,remote:y,numberJump:w,numberJumpKind:"issue",onClearFilters:S,onLoadMore:f,onRetry:p,onOpen:N})},Je=(e,s,n)=>{const[r,l]=u.useState([]),[a,d]=u.useState([]),[b,o]=u.useState(!1);return u.useEffect(()=>{if(!n)return;let c=!1;return o(!0),n.repoMeta(e,s).then(y=>{c||(l(y.labels??[]),d(y.assignees??[]))}).catch(()=>{c||(l([]),d([]))}).finally(()=>{c||o(!1)}),()=>{c=!0}},[n,e,s]),{labels:r,assignees:a,loading:b}},Ye=(e,s)=>e.includes(s)?e.filter(n=>n!==s):[...e,s],Ze=({candidates:e,loading:s,selected:n,onChange:r})=>s?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading labels…"}):e.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No labels in this repository."}):t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(l=>{const a=n.includes(l.name);return t.jsx(j,{type:"button",variant:"chip",size:"xs","aria-pressed":a,onClick:()=>r(Ye(n,l.name)),children:l.name},l.name)})}),Xe=({candidates:e,loading:s,selected:n,onChange:r})=>s?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading assignees…"}):e.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No assignable users found."}):t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(l=>{const a=l.login,d=a?n.includes(a):!1;return t.jsx(j,{type:"button",variant:"chip",size:"xs","aria-pressed":d,onClick:()=>{a&&r(Ye(n,a))},children:a},a)})}),Ns=({open:e,onOpenChange:s,issueNumber:n,issueTitle:r,busy:l,onChoose:a})=>{const[d,b]=u.useState("worktree"),o=qe(n,r);return t.jsx(pt,{open:e,onOpenChange:s,children:t.jsxs(yt,{className:"max-w-md w-[calc(100vw-2rem)]",children:[t.jsxs(vt,{children:[t.jsxs(Ct,{children:["Start session from issue #",n]}),t.jsx(jt,{children:"Choose where the new session works. The composer is pre-filled — nothing is sent automatically."})]}),t.jsxs("div",{className:"flex flex-col gap-1",role:"radiogroup","aria-label":"Session location",children:[t.jsxs("button",{type:"button",role:"radio","aria-checked":d==="current",onClick:()=>b("current"),className:"flex items-start gap-2 rounded-md border border-border px-3 py-2 text-left hover:bg-interactive-hover",children:[t.jsx(R,{name:d==="current"?"record-circle":"checkbox-blank-circle-fill",className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block typography-ui-label text-foreground",children:"Current checkout"}),t.jsx("span",{className:"block typography-micro text-muted-foreground",children:"Work directly where you are now."})]})]}),t.jsxs("button",{type:"button",role:"radio","aria-checked":d==="worktree",onClick:()=>b("worktree"),className:"flex items-start gap-2 rounded-md border border-border px-3 py-2 text-left hover:bg-interactive-hover",children:[t.jsx(R,{name:d==="worktree"?"record-circle":"checkbox-blank-circle-fill",className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block typography-ui-label text-foreground",children:"New worktree"}),t.jsxs("span",{className:"block truncate font-mono typography-micro text-muted-foreground",title:o,children:["Branch ",o]})]})]})]}),t.jsxs(wt,{children:[t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>s(!1),disabled:l,children:"Cancel"}),t.jsx(j,{type:"button",variant:"default",size:"sm",onClick:()=>a(d),disabled:l,"aria-label":d==="worktree"?"Create worktree and open session draft":"Open session draft in current checkout",children:l?"Working…":d==="worktree"?"Create worktree":"Open draft"})]})]})})},ze=e=>{const s=as(e.title);return e.kind==="pr"?`pr-${e.number}-${s}`:qe(e.number,e.title)},Rs=async(e,s)=>{const{github:n,git:r,openDraft:l,refreshWorktrees:a}=s;if(!l)return{ok:!1,error:"Sessions are not available in this runtime"};let d;try{d=(await n.agentContext(e.directory,e.repo,e.kind==="pr"?"pr":"issue",e.number)).text}catch(p){return{ok:!1,error:p instanceof Error?p.message:"Failed to load issue context"}}const o=`${e.kind==="pr"?"PR":"Issue"} #${e.number}: ${e.title.trim()||"(untitled)"}`,c=e.kind==="pr"?`Work on this GitHub pull request. Read the quoted context below, then propose a plan and wait for confirmation before changing code.
|
|
3
|
-
|
|
4
|
-
PR #${e.number}: ${e.title}
|
|
5
|
-
${e.url}
|
|
6
|
-
|
|
7
|
-
${d}`:ts({repo:e.repo,number:e.number,title:e.title,url:e.url,contextText:d}),y=[{text:ss({kind:e.kind,number:e.number,title:e.title,url:e.url}),synthetic:!0},{text:d,synthetic:!0}];if(e.target==="current")return l({directoryOverride:e.directory,title:o,initialPrompt:c,syntheticParts:y}),{ok:!0,directory:e.directory};if(!r?.getGitBranches||!r?.createGitWorktree)return{ok:!1,error:"Worktree creation is not available in this runtime"};let w,x=!1;try{const p=await r.getGitBranches(e.directory);if(w=p.current?.trim()??"",!w)throw new Error("no current branch");x=Array.isArray(p.all)&&p.all.includes(ze(e))}catch{return{ok:!1,error:"Could not determine the current branch to start the worktree from"}}const S=ze(e);let f;try{if(x){let p=null;if(r.listGitWorktrees)try{const N=await r.listGitWorktrees(e.directory);p=Array.isArray(N)?N.find(k=>!k?.prunable&&k?.branch===S)?.path??null:null}catch{p=null}if(p)f=p;else if(f=(await r.createGitWorktree(e.directory,{mode:"existing",existingBranch:S})).path,!f)throw new Error("worktree path missing")}else if(f=(await r.createGitWorktree(e.directory,{mode:"new",startRef:w,branchName:S})).path,!f)throw new Error("worktree path missing")}catch(p){return{ok:!1,error:p instanceof Error?p.message:"Worktree creation failed"}}return await a?.(e.directory),l({directoryOverride:f,title:o,initialPrompt:c,syntheticParts:y}),{ok:!0,directory:f}},Ls=()=>{const e=$e(),s=kt(a=>a.openNewSessionDraft),[n,r]=u.useState(null);return{start:u.useCallback(async a=>{const d=e.github;if(!d)return P.error("GitHub is not available in this runtime"),!1;const b=`${a.repo}#${a.number}:${a.target}`;r(b);try{const o=await Rs(a,{github:d,git:e.git??null,refreshWorktrees:c=>ut(c,e.git),openDraft:c=>s(c)});return o.ok?(P.success(a.target==="worktree"?"Worktree ready — session draft opened":"Session draft opened"),!0):(P.error(o.error),!1)}finally{r(null)}},[e.github,e.git,s]),startingKey:n}},Es=({issue:e})=>t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(We,{login:e.author?.login,avatarUrl:e.author?.avatarUrl,size:"xs"}),e.author?.login??"ghost"]}),e.createdAt?` · opened ${Ge(e.createdAt)}`:"",e.updatedAt&&e.updatedAt!==e.createdAt?` · updated ${Ge(e.updatedAt)}`:""]}),Is=({number:e,closed:s,closeReason:n,onCloseReasonChange:r,closeAllowed:l,closeReasonText:a,reopenAllowed:d,reopenReasonText:b,acting:o,onStateAction:c,askSending:y,onAskAgent:w,onEditTitle:x,editAllowed:S,editReasonText:f,onCopyLink:p,url:N})=>t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pt-1 pb-2","aria-label":"Issue actions",children:[s?t.jsx(Ne,{copy:Me("reopen",e),busy:o,variant:"outline",disabled:!d,disabledReason:b??"Reopen issue",label:"Reopen issue",icon:t.jsx(R,{name:"history",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>{c("reopen")}}):t.jsxs("span",{role:"group","aria-label":"Close issue",className:"inline-flex shrink-0 items-center gap-1",children:[t.jsx(Ne,{copy:Me(n==="not_planned"?"close-not-planned":"close-completed",e),busy:o,destructive:!0,variant:"outline",disabled:!l,disabledReason:a??"Close issue",label:"Close issue",icon:t.jsx(R,{name:"close",className:"size-3.5","aria-hidden":"true"}),onConfirm:()=>{c(n==="not_planned"?"close-not-planned":"close-completed")}}),t.jsxs(Re,{modal:!1,children:[t.jsx(Le,{asChild:!0,children:t.jsx(j,{type:"button",variant:"outline",size:"xs",className:"shrink-0 px-1.5",title:"Close options","aria-label":"Close options",disabled:!l||o,children:t.jsx(R,{name:"arrow-down-s",className:"size-3.5"})})}),t.jsx(Ee,{align:"start",className:"w-60",children:t.jsx(Nt,{value:n,onValueChange:k=>r(k),children:os.map(k=>t.jsx(Rt,{value:k.id,children:k.id==="completed"?"Close as completed":"Close as not planned"},k.id))})})]})]}),t.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"shrink-0",onClick:w,disabled:y,title:"Send issue context to the agent composer","aria-label":"Ask agent about this issue",children:[t.jsx(R,{name:"send-plane-2",className:"size-3.5","aria-hidden":"true"}),y?"Asking…":"Ask agent"]}),t.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"shrink-0",onClick:()=>{ye(N)},title:"Open on GitHub","aria-label":"Open on GitHub",children:[t.jsx(R,{name:"external-link",className:"size-3.5","aria-hidden":"true"}),"Open on GitHub"]}),t.jsxs(Re,{modal:!1,children:[t.jsx(Le,{asChild:!0,children:t.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"shrink-0 px-1.5","aria-label":"More issue actions",title:"More issue actions",children:t.jsx(R,{name:"more-2",className:"size-4"})})}),t.jsxs(Ee,{align:"end",className:"w-60",children:[t.jsxs(xe,{onClick:x,disabled:!S,title:f??"Edit title",children:[t.jsx(R,{name:"pencil",className:"size-3.5"}),"Edit title"]}),t.jsx(Lt,{}),t.jsxs(xe,{onClick:()=>{ye(N)},children:[t.jsx(R,{name:"external-link",className:"size-3.5"}),"Open on GitHub"]}),t.jsxs(xe,{onClick:p,children:[t.jsx(R,{name:"file-copy",className:"size-3.5"}),"Copy link"]})]})]})]}),As=e=>{const{directory:s,repo:n,number:r,github:l,issue:a}=e,d=C(i=>i.updateIssue),b=C(i=>i.addComment),o=C(i=>i.actionErrorByDetail[`${n}#${r}`]??null),c=C(i=>i.actingActions[`${n}#${r}`]??!1),{start:y,startingKey:w}=Ls(),x=Pt(s,n),[S,f]=u.useState("completed"),[p,N]=u.useState(!1),[k,G]=u.useState(""),[H,z]=u.useState(!1),[D,I]=u.useState(""),[B,T]=u.useState(!1),[A,$]=u.useState([]),[O,h]=u.useState([]),{draft:v,onDraftChange:L,flushDraft:_}=dt(n,r),{busy:W,error:de,submit:X}=mt({postComment:i=>b(s,n,r,i,l),runFollowUp:i=>d(s,n,r,Be(i==="reopen"?"reopen":S==="not_planned"?"close-not-planned":"close-completed"),l),verbs:{close:"close",reopen:"reopen"},doneLabels:{close:"Closed with comment",reopen:"Reopened with comment"},afterPost:()=>{L(""),ft.getState().clearCommentDraft(n,r)}}),[Q,me]=u.useState("newest"),[he,J]=u.useState(!1),[Y,ee]=u.useState(!1),U=u.useMemo(()=>({capabilities:e.capabilities??null,isAuthor:$t(a?.author?.login,e.viewerLogin),permissionFallback:e.viewerPermission?.fallback===!0}),[e.capabilities,e.viewerLogin,e.viewerPermission?.fallback,a?.author?.login]),M=le(a?.state==="closed"?"reopen":"close",a,U),F=le("edit",a,U),te=le("labels",a,U),se=le("comment",a,U),ae=St(s),Z=u.useMemo(()=>{const i=new Set;for(const E of ae.scope?.repositories??[])E.host&&E.owner&&E.repo&&i.add(`${E.host}/${E.owner}/${E.repo}`.toLowerCase());return i.add(n.toLowerCase()),i},[ae.scope,n]),m=u.useCallback(i=>{Z.has(i.repoRef.toLowerCase())?Dt(s,i.repoRef,i.number):ye(i.url)},[s,Z]),{labels:q,assignees:et,loading:we}=Je(s,n,l),ne=i=>{a&&(i==="title"?(G(a.title),N(!0)):i==="body"?(I(a.body??""),z(!0)):($((a.labels??[]).map(E=>E.name)),h((a.assignees??[]).map(E=>E.login).filter(Boolean)),T(!0)))},fe=u.useCallback(async i=>{const E=await d(s,n,r,i,l);return E.ok?(N(!1),z(!1),T(!1),!0):(P.error(E.error?.kind==="failed"?E.error.message:"Update failed"),!1)},[d,s,n,r,l]),tt=u.useCallback(async i=>{const E=Be(i),ge=await d(s,n,r,E,l);return ge.ok?!0:(P.error(ge.error?.kind==="failed"?ge.error.message:"State change failed"),!1)},[d,s,n,r,l]),st=Ot(a?.url),at=u.useCallback(async()=>{if(!(!a||Y)){ee(!0);try{const i=await l.agentContext(s,n,"issue",r);ns({kind:"issue",number:r,title:a.title,url:a.url,contextText:i.text},rs()),P.success("Added to composer")}catch(i){P.error(i instanceof Error?i.message:"Failed to fetch GitHub context")}finally{ee(!1)}}},[a,Y,l,s,n,r]),K=u.useMemo(()=>{const i=[...e.comments];return Q==="newest"&&i.reverse(),i},[e.comments,Q]),nt=u.useMemo(()=>K.filter(i=>!De(i.author?.login)),[K]),rt=u.useMemo(()=>K.filter(i=>De(i.author?.login)),[K]),ke=a?.state==="closed",Se=w!==null,V=a??(e.seed&&e.seed.number===r?e.seed:null),be=t.jsxs(t.Fragment,{children:[t.jsx(_t,{onBack:e.onBack,backLabel:"Back to issues",repoName:x,number:r,url:V?.url,numberTintClass:Kt("issue",V?.state??"open",!1,a?.stateReason),statePill:V?t.jsx(Ut,{kind:"issue",state:V.state,stateReason:a?.stateReason}):void 0,openLabel:`Open issue #${r} on GitHub`,title:V?.title??null,onEditTitle:a?()=>ne("title"):void 0,editTitleLabel:"Edit issue title",editTitleDisabledReason:F.allowed?null:F.reason,meta:V?t.jsx(Es,{issue:V}):void 0,primary:a?t.jsxs(j,{type:"button",variant:"default",size:"xs",onClick:()=>J(!0),disabled:Se,"aria-label":"Start session from issue",children:[t.jsx(R,{name:"add-circle",className:"size-3.5"}),"Start session"]}):void 0}),a?t.jsx(Is,{number:r,closed:ke,closeReason:S,onCloseReasonChange:f,closeAllowed:a.state!=="closed"?M.allowed:!1,closeReasonText:a.state!=="closed"?M.reason:"Already closed",reopenAllowed:a.state==="closed"?M.allowed:!1,reopenReasonText:a.state==="closed"?M.reason:"Already open",acting:c,onStateAction:i=>tt(i),askSending:Y,onAskAgent:()=>{at()},onEditTitle:()=>ne("title"),editAllowed:F.allowed,editReasonText:F.reason,onCopyLink:st,url:a.url}):null]});if(!a&&e.detailError)return t.jsx(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsx(cs,{icon:"error-warning",title:"Could not load this issue",action:t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:e.onRetryDetail,disabled:e.detailLoading,children:"Retry"})})});if(!a)return t.jsx(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsx(Wt,{label:"Loading issue"})});const re=ke?"reopen":"close";return t.jsxs(ie,{header:be,tabs:[],activeTab:"",onTabChange:()=>{},children:[t.jsxs("div",{className:"flex flex-col gap-1 px-3 py-2",children:[e.detailStale?t.jsxs("p",{className:"typography-micro text-muted-foreground",role:"note",children:["Showing saved issue — last refresh failed."," ",t.jsx("button",{type:"button",className:"underline",onClick:e.onRetryDetail,children:"Retry"})]}):null,o?t.jsxs("p",{className:"flex items-start gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert",children:[t.jsx(R,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0",children:o.kind==="failed"?o.message:"Action failed"})]}):null,U.permissionFallback?t.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,p?t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 py-1",children:[t.jsx(Oe,{value:k,onChange:i=>G(i.target.value),"aria-label":"Issue title",className:"h-7"}),t.jsx(j,{type:"button",variant:"default",size:"xs",onClick:()=>{fe({title:k})},disabled:c||!k.trim(),children:"Save"}),t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>N(!1),disabled:c,children:"Cancel"})]}):null,t.jsxs("div",{className:"flex flex-col gap-1.5 py-1",children:[t.jsx(oe,{icon:"user",label:"Assignees",children:t.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:(a.assignees??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"Unassigned"}):(a.assignees??[]).map(i=>t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 typography-micro text-muted-foreground",children:[t.jsx(We,{login:i.login,avatarUrl:i.avatarUrl,size:"xs"}),t.jsx("span",{className:"truncate",children:i.login})]},i.login))})}),t.jsx(oe,{icon:"list-unordered",label:"Labels",children:t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[(a.labels??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):(a.labels??[]).map(i=>t.jsx(qt,{name:i.name,color:i.color},i.name)),t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>ne("meta"),"aria-label":"Edit labels and assignees",title:te.reason??"Edit labels and assignees",disabled:!te.allowed,children:"Edit"})]})}),a.milestone?t.jsx(oe,{icon:"time",label:"Milestone",children:t.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:a.milestone.title})}):null,t.jsx(oe,{icon:"git-pull-request",label:"Linked PRs",children:t.jsx("span",{className:"min-w-0 flex-1",children:e.linkedPullRequestsError?t.jsxs("span",{className:"flex items-center gap-2 typography-micro text-[var(--status-error)]",role:"alert",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Linked pull requests failed to load"}),t.jsx(j,{type:"button",variant:"outline",size:"xs",onClick:e.onRetryDetail,children:"Retry"})]}):(e.linkedPullRequests??[]).length===0?t.jsx("span",{className:"typography-micro text-muted-foreground",children:"None"}):t.jsx("ul",{className:"flex min-w-0 flex-col",children:(e.linkedPullRequests??[]).map(i=>{const E=Z.has(i.repoRef.toLowerCase());return t.jsx("li",{children:t.jsx(Pe,{glyph:t.jsx(Ke,{kind:"pr",state:i.state,draft:i.draft}),number:`#${i.number}`,title:i.title||"(no title)",meta:t.jsxs("span",{className:"truncate",children:[Vt(i.repoRef),E?"":" · GitHub"]}),onOpen:()=>m(i),ariaLabel:`Open linked pull request #${i.number}: ${i.title}`})},`${i.repoRef}#${i.number}`)})})})}),B?t.jsxs("div",{className:"flex flex-col gap-2 py-1",children:[t.jsx("p",{className:"typography-micro font-medium text-muted-foreground",children:"Labels"}),t.jsx(Ze,{candidates:q,loading:we,selected:A,onChange:$}),t.jsx("p",{className:"typography-micro font-medium text-muted-foreground",children:"Assignees"}),t.jsx(Xe,{candidates:et,loading:we,selected:O,onChange:h}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:()=>{fe({labels:A,assignees:O})},disabled:c,children:"Save"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>T(!1),disabled:c,children:"Cancel"})]})]}):null]}),t.jsx(Te,{id:`issue-${r}-description`,title:"Description",action:H?void 0:t.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>ne("body"),"aria-label":"Edit issue body",title:F.reason??"Edit issue body",disabled:!F.allowed,children:"Edit"}),children:H?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(_e,{value:D,onChange:i=>I(i.target.value),"aria-label":"Issue body",rows:6}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:()=>{fe({body:D})},disabled:c,children:"Save"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>z(!1),disabled:c,children:"Cancel"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(Qt,{markdown:a.body??"",html:a.bodyHtml??null,fallbackUrl:a.url}),a.body?.trim()?null:t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No description."})]})}),t.jsx(Te,{id:`issue-${r}-comments`,title:`Comments${K.length?` (${K.length})`:""}`,action:t.jsx(Zt,{order:Q,onToggle:()=>me(i=>i==="newest"?"oldest":"newest")}),children:t.jsxs("div",{className:"flex flex-col gap-2",children:[K.length===0&&!e.commentsLoading?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"No comments yet."}):nt.map(i=>t.jsx(Jt,{comment:i},i.id)),t.jsx(Yt,{comments:rt}),e.commentsLoading&&K.length===0?t.jsx("p",{className:"typography-micro text-muted-foreground",children:"Loading comments…"}):null,t.jsx(us,{hasMore:e.commentsHasMore,isLoading:e.commentsLoading,onLoadMore:e.onLoadMoreComments,label:"Load older comments"}),se.allowed?t.jsx(ht,{draft:v,onDraftChange:L,onDraftBlur:_,ariaLabel:`Leave a comment on issue #${r}`,busy:W,error:de,disabledReason:se.reason,followUp:{id:re,label:re==="close"?"Close with comment":"Reopen with comment",busyLabel:re==="close"?"Closing…":"Reopening…",onRun:()=>{X(re,v)},allowed:M.allowed,reason:M.reason},onSubmitComment:()=>{X("comment",v)}}):null]})})]}),a?t.jsx(Ns,{open:he,onOpenChange:J,issueNumber:r,issueTitle:a.title,busy:Se,onChoose:i=>{J(!1),y({directory:s,repo:n,number:r,kind:"issue",title:a.title,url:a.url,target:i})}}):null]})},Ds=({directory:e,repo:s,github:n,onCreated:r,onCancel:l})=>{const a=C(v=>v.createIssue),[d,b]=u.useState(""),[o,c]=u.useState(""),[y,w]=u.useState([]),[x,S]=u.useState([]),[f,p]=u.useState(""),[N,k]=u.useState([]),[G,H]=u.useState(null),{labels:z,assignees:D,loading:I}=Je(e,s,n),[B,T]=u.useState(!1),[A,$]=u.useState({});u.useEffect(()=>{let v=!1;return n.issueTemplates(e,s).then(L=>{v||(k(L.templates),H(L.templates.length===0?"No markdown templates in this repository. YAML issue forms are not supported.":null))}).catch(()=>{v||H("Issue templates are unavailable.")}),()=>{v=!0}},[n,e,s]);const O=v=>{if(p(v),!v)return;const L=N.find(_=>_.filename===v);L&&c(_=>ls(_,L.body))},h=async()=>{const v=is({title:d,body:o});if($(v.errors),!!v.ok){T(!0);try{const L=await a({directory:e,repo:s,title:d.trim(),body:o.trim()?o:void 0,labels:y.length>0?y:void 0,assignees:x.length>0?x:void 0},n);if(!L.ok||typeof L.number!="number"){P.error(L.error?.kind==="failed"?L.error.message:"Could not create the issue");return}P.success(`Issue #${L.number} created`),r(L.number)}finally{T(!1)}}};return t.jsx(ie,{header:t.jsxs("div",{className:"flex h-7 min-w-0 items-center gap-1 px-2 pt-1",children:[t.jsx(j,{type:"button",variant:"ghost",size:"icon",onClick:l,title:"Back to issues","aria-label":"Back to issues",className:"size-6 shrink-0",children:t.jsx(R,{name:"arrow-left",className:"size-4"})}),t.jsx("h1",{className:"min-w-0 flex-1 truncate text-base font-semibold text-foreground",children:"New issue"})]}),tabs:[],activeTab:"",onTabChange:()=>{},children:t.jsxs("div",{className:"flex flex-col gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-title",className:"typography-micro font-medium text-muted-foreground",children:"Title"}),t.jsx(Oe,{id:"new-issue-title",value:d,onChange:v=>b(v.target.value),placeholder:"Short summary","aria-label":"Issue title",className:"h-8",maxLength:300}),A.title?t.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.title}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-template",className:"typography-micro font-medium text-muted-foreground",children:"Template"}),t.jsxs("select",{id:"new-issue-template","aria-label":"Issue template",value:f,onChange:v=>O(v.target.value),className:"h-8 rounded-md border border-border bg-[var(--surface-elevated)] px-2 typography-micro text-foreground",children:[t.jsx("option",{value:"",children:"No template"}),N.map(v=>t.jsx("option",{value:v.filename,children:v.name},v.filename))]}),G?t.jsx("p",{className:"typography-micro text-muted-foreground",children:G}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("label",{htmlFor:"new-issue-body",className:"typography-micro font-medium text-muted-foreground",children:"Body"}),t.jsx(_e,{id:"new-issue-body",value:o,onChange:v=>c(v.target.value),placeholder:"Describe the issue","aria-label":"Issue body",rows:8}),A.body?t.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:A.body}):null]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:"Labels"}),t.jsx(Ze,{candidates:z,loading:I,selected:y,onChange:w})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"typography-micro font-medium text-muted-foreground",children:"Assignees"}),t.jsx(Xe,{candidates:D,loading:I,selected:x,onChange:S})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(j,{type:"button",size:"sm",onClick:h,disabled:B||!d.trim(),"aria-label":"Create issue",children:B?"Creating…":"Create issue"}),t.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:l,disabled:B,children:"Cancel"})]})]})})},Ts=({directory:e,repo:s,isRefreshing:n,registerRefresh:r,onRefreshChange:l,headerActionsSlot:a=null,headerActionsPresentation:d="drawer"})=>{const o=$e().github??null,c=js(e,s),y=ws(e),w=Tt(),[x,S]=u.useState(!1),f=y.repo===s&&typeof y.number=="number"?y.number:null,p=c.state==="open"?"open":c.state==="all"?"both":"closed",N=u.useCallback(()=>{o&&(l(!0),C.getState().refreshAllForScope(e,s,o).catch(()=>null).finally(()=>l(!1)))},[o,e,s,l]);u.useEffect(()=>(r(N),()=>r(null)),[r,N]),u.useEffect(()=>{o&&(l(!0),C.getState().ensureCollectionsFresh(e,s,p,o).catch(()=>null).finally(()=>l(!1)))},[o,e,s,p]),u.useEffect(()=>{if(!o||f===null)return;const m=C.getState();m.ensureDetail(e,s,f,o),m.ensureComments(e,s,f,o)},[o,e,s,f]),u.useEffect(()=>{if(!o)return;const m=()=>{typeof document<"u"&&document.hidden||C.getState().ensureCollectionsFresh(e,s,p,o).catch(()=>{})};return window.addEventListener("focus",m),document.addEventListener("visibilitychange",m),()=>{window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",m)}},[o,e,s,p]),u.useEffect(()=>Gt(m=>{C.getState().notifyAgentTurnComplete(m)}),[]);const k=Fe(s,"open"),G=Fe(s,"closed"),H=u.useMemo(()=>xs(s),[s,k?.data,G?.data]),z=u.useMemo(()=>new Set(H.map(m=>m.number)),[H]),D=u.useMemo(()=>Ht(H,{state:c.state,involvement:c.involvement,labels:c.labels,search:c.search,sort:c.sort,viewerLogin:w}),[H,c.state,c.involvement,c.labels,c.search,c.sort,w]),I=p==="both"?[k,G]:[p==="open"?k:G],B=I.some(m=>m?.data!=null),T=B&&I.every(m=>m?.data?.nextCursor==null),A=I.reduce((m,q)=>m+(q?.data?.items.length??0),0),$=I.find(m=>m?.error)?.error??null,O=I.some(m=>m?.stale),h=c.search.trim(),v=c.labels.trim(),L=c.involvement!=="all"&&!w||c.involvement==="mentioned",_=h.length>0||v.length>0||c.involvement!=="all",W=u.useMemo(()=>({state:c.state,involvement:c.involvement,labels:v,q:h}),[c.state,c.involvement,v,h]),de=`${W.state}|${W.involvement}|${W.labels}|${W.q}`,X=!T&&B&&(D.length===0||L)&&(h.length>0||v.length>0||L),Q=u.useCallback(m=>o?C.getState().searchRemote(e,s,m,o):Promise.resolve(null),[e,s,o]),me=u.useCallback(m=>o?C.getState().loadMoreRemote(e,s,m,o):Promise.resolve(null),[e,s,o]),{remoteView:he,numberJump:J,remotePending:Y,handleSearchAll:ee}=gt({repo:s,query:W,queryKey:de,autoRemote:X,indexNumbers:z,visibleItems:D,searchText:h,useRemoteEntry:ys,runSearch:Q,runLoadMore:me}),U=u.useMemo(()=>{if(T||!B||!_)return null;const m=D.length===1?"1 match":`${D.length} matches`,q=A===1?"1 most recent loaded issue":`${A} most recent loaded issues`;return`Showing ${m} from the ${q}`},[T,B,_,D.length,A]),M=vs(s,f),F=Cs(s,f),te=u.useCallback(()=>{!o||f===null||C.getState().loadMoreComments(e,s,f,o)},[o,e,s,f]),se=u.useCallback(()=>{C.getState().selectIssue(e,null,null)},[e]),ae=u.useCallback(()=>{!o||f===null||C.getState().refreshDetail(e,s,f,o)},[o,e,s,f]),Z=u.useCallback(()=>{!o||f===null||C.getState().refreshComments(e,s,f,o)},[o,e,s,f]);if(!o)return null;if(x)return t.jsx(Ds,{directory:e,repo:s,github:o,onCancel:()=>S(!1),onCreated:m=>{S(!1),C.getState().selectIssue(e,s,m)}});if(f!==null){const m=M?.data?.detail??null;return t.jsx(As,{directory:e,repo:s,number:f,github:o,seed:ps(s,f),issue:m?.issue??null,linkedPullRequests:m?.linkedPullRequests??[],linkedPullRequestsError:m?.sectionErrors?.linkedPullRequests??null,capabilities:m?.capabilities??null,viewerLogin:m?.viewerLogin??null,viewerPermission:m?.viewerPermission??null,detailError:M?.error??null,detailStale:M?.stale??!1,detailLoading:M?.isLoading??!1,comments:F?.data?.comments??[],commentsHasMore:!!F?.data?.nextCursor,commentsLoading:F?.isLoading??!1,onLoadMoreComments:te,onBack:se,onRetryDetail:ae,onRetryComments:Z})}return t.jsx(Ss,{items:D,headerActionsSlot:a,headerActionsPresentation:d,hasMore:I.some(m=>m?.data?.nextCursor!=null),isLoadingMore:I.some(m=>m?.isLoading),isLoading:I.some(m=>m?.isLoading),isRefreshing:n,stale:O,error:$,filters:c,countComplete:T,incompleteNotice:U?{summary:U,searching:Y,onSearchAll:ee}:null,remote:he,numberJump:J,onFiltersChange:m=>C.getState().setFilters(e,s,m),onClearFilters:()=>C.getState().resetFilters(e,s),onLoadMore:()=>{const m=p==="both"?["open","closed"]:[p];Promise.all(m.map(q=>C.getState().loadMoreCollection(e,s,q,o)))},onRetry:()=>N(),onOpen:m=>C.getState().selectIssue(e,s,m),onNewIssue:()=>S(!0)})},ea=({headerActionsSlot:e=null,headerActionsPresentation:s="drawer"})=>{const n=Et()??"",[r,l]=u.useState(!1),a=u.useRef(null),d=u.useCallback(o=>{a.current=o},[]),b=u.useCallback(o=>l(o),[]);return n?t.jsx(bt,{directory:n,isRefreshing:r,onRefresh:()=>a.current?.(),children:({repo:o,directory:c})=>t.jsx(Ts,{directory:c,repo:o,isRefreshing:r,registerRefresh:d,onRefreshChange:b,headerActionsSlot:e,headerActionsPresentation:s})}):t.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center",children:t.jsx("p",{className:"typography-ui text-muted-foreground",children:"Open a project to browse issues."})})};export{ea as IssuesSurface};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ei as j,dH as y,dL as D}from"./useAppFontEffects-CoFst31H.js";import{f as k,B as C}from"./web-components-CzkvK_V5.js";import{M as P,G as L,u as O,W as A,a as H,b as M,n as F,t as R}from"./Virtualizer-cIf8dSOQ.js";import{j as d}from"./vendor-boot-Ciu-Edvy.js";import{V as _,F as N}from"./VirtualizedFileDiff-BY-mDMT8.js";import{a as w}from"./vendor-react-Bz1tRBxM.js";function T({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function V(e,t){const n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:z(n,e.startContentIndex)}}function z(e,t){let n=e.unifiedLineStart;for(let l=0;l<t;l++){const s=e.hunkContent[l];n+=s.type==="context"?s.lines:s.deletions+s.additions}return n}function U(e){const t=j(e);if(t.length!==1)throw console.error(t),new Error("PatchDiff: Provided patch must include only 1 patch, with 1 diff");const{files:n}=t[0];if(n.length!==1)throw console.error(n),new Error("FileDiff: Provided patch must contain exactly 1 file diff");return n[0]}function $({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:l,renderHeaderFilenameSuffix:s,renderHeaderMetadata:x,renderAnnotation:f,renderGutterUtility:u,renderMergeConflictUtility:o,lineAnnotations:a,getHoveredLine:g,getInstance:m}){const p=n?.(e),c=l?.(e),i=s?.(e),v=x?.(e);return d.jsxs(d.Fragment,{children:[p!=null?d.jsx("div",{slot:y,children:p}):d.jsxs(d.Fragment,{children:[c!=null&&d.jsx("div",{slot:"header-prefix",children:c}),i!=null&&d.jsx("div",{slot:"header-filename-suffix",children:i}),v!=null&&d.jsx("div",{slot:"header-metadata",children:v})]}),f!=null&&a?.map((r,h)=>d.jsx("div",{slot:k(r),children:f(r)},h)),t!=null&&o!=null&&m!=null&&t.map(r=>{if(r==null)return;const h=b(r,e);return d.jsx("div",{slot:h,style:P,children:o(r,m)},h)}),u!=null&&d.jsx("div",{slot:"gutter-utility-slot",style:L,children:u(g)})]})}function b(e,t){const n=V(e,t);return n!=null?T({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex}):void 0}const S=typeof window>"u"?w.useEffect:w.useLayoutEffect;function G({fileDiff:e,options:t,lineAnnotations:n,selectedLines:l,prerenderedHTML:s,metrics:x,hasGutterRenderUtility:f,hasCustomHeader:u,disableWorkerPool:o,contentEditable:a}){const g=O(),m=l!==void 0,p=w.useContext(A),c=H(),i=w.useRef(null),v=M(r=>{if(r!=null){if(i.current!=null)throw new Error("useFileDiffInstance: An instance should not already exist when a node is created");g!=null?i.current=new _(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),g,x,o?void 0:p,!0):i.current=new N(E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),o?void 0:p,!0),i.current.hydrate({fileDiff:e,fileContainer:r,lineAnnotations:n,prerenderedHTML:s})}else{if(i.current==null)throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");i.current.cleanUp(),i.current=null}});return S(()=>{const{current:r}=i;if(r==null)return;const h=E({controlledSelection:m,contentEditable:a,hasCustomHeader:u,hasEditor:c!==void 0,hasGutterRenderUtility:f,options:t}),I=!C(r.options,h);r.setOptions(h),r.render({forceRender:I,fileDiff:e,lineAnnotations:n}),l!==void 0&&r.setSelectedLines(l)}),S(()=>{if(a&&i.current!=null){if(c===void 0)throw new Error("FileDiff: Editor is not attached");return c.edit(i.current)}},[a,c]),{ref:v,getHoveredLine:w.useCallback(()=>i.current?.getHoveredLine(),[])}}function E({options:e,controlledSelection:t,contentEditable:n,hasCustomHeader:l,hasEditor:s,hasGutterRenderUtility:x}){const f=n&&s,u=t||x||l;if(!u&&!f)return e;let o={...e};return u&&(o={...o,controlledSelection:t,renderCustomHeader:l?F:e?.renderCustomHeader,renderGutterUtility:x?F:e?.renderGutterUtility}),f&&(o={...o,useTokenTransformer:!0,enableGutterUtility:!1,enableLineSelection:!1,expandUnchanged:!0,lineHoverHighlight:"disabled"}),o}function Y({patch:e,options:t,metrics:n,lineAnnotations:l,selectedLines:s,className:x,style:f,prerenderedHTML:u,renderAnnotation:o,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderGutterUtility:c,disableWorkerPool:i=!1,contentEditable:v=!1}){const r=q(e),{ref:h,getHoveredLine:I}=G({fileDiff:r,options:t,metrics:n,lineAnnotations:l,selectedLines:s,prerenderedHTML:u,hasGutterRenderUtility:c!=null,hasCustomHeader:a!=null,disableWorkerPool:i,contentEditable:v});return d.jsx(D,{ref:h,className:x,style:f,children:R($({fileDiff:r,renderCustomHeader:a,renderHeaderPrefix:g,renderHeaderFilenameSuffix:m,renderHeaderMetadata:p,renderAnnotation:o,lineAnnotations:l,renderGutterUtility:c,getHoveredLine:I}),u)})}function q(e){return w.useMemo(()=>U(e),[e])}export{Y as P};
|