@openchamber/web 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
- package/dist/assets/{CommitSection-D9cV-qR9.js → CommitSection-C-F3AX6D.js} +1 -1
- package/dist/assets/{DiagramEditor-B9NCadU7.js → DiagramEditor-BPECg1jS.js} +1 -1
- package/dist/assets/DiagramView-D0YNMix8.js +1 -0
- package/dist/assets/DiffView-BHWaMYCC.js +4 -0
- package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
- package/dist/assets/{GitView-DsWXqWx3.js → GitView-Rp8P1KEI.js} +4 -4
- package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-KnXFN2A-.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-n0ikH-xm.js → MarkdownImageGallery-BMn3mtor.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
- package/dist/assets/{OnboardingScreen-CDjgzxEe.js → OnboardingScreen-CenIeD4v.js} +1 -1
- package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-BzVOVog8.js} +1 -1
- package/dist/assets/{PierreDiffViewer-D_Gt4A_6.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
- package/dist/assets/PlanView-Czu1KMJa.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
- package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
- package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
- package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
- package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
- package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-CaSYE0lw.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-BO1wRpaN.js → contextPanelEmbeddedChat-BEARQjgn.js} +1 -1
- package/dist/assets/de-DFdX3ABv.js +9 -0
- package/dist/assets/es-iC-FKvV9.js +15 -0
- package/dist/assets/fr-BBbi_1AL.js +13 -0
- package/dist/assets/{index-BSvmTvZl.js → index-BiEgzzkg.js} +1 -1
- package/dist/assets/index-Cwmuwk3V.js +7 -0
- package/dist/assets/index-GNm1wgUH.css +1 -0
- package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-BG53Ixxy.js} +1 -1
- package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-BbV-39jl.js} +1 -1
- package/dist/assets/ja-DQLQJL2J.js +15 -0
- package/dist/assets/ko-BeElEB4Y.js +15 -0
- package/dist/assets/main-Dpzo18z7.js +2 -0
- package/dist/assets/main-WMjtYzJs.js +921 -0
- package/dist/assets/markdownCore--tDmyI_v.js +2 -0
- package/dist/assets/miniChat-ldEghBLB.js +2 -0
- package/dist/assets/mobile-Dk-VGreF.js +2 -0
- package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BcFaMtMu.js} +2 -2
- package/dist/assets/pl-CLHt2_vV.js +15 -0
- package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
- package/dist/assets/{renderMobileApp-BiMbzPq9.js → renderMobileApp-CDfHS5rr.js} +7 -7
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
- package/dist/assets/{scheduledTasksApi-01zzfzqH.js → scheduledTasksApi-BFSlqgnG.js} +1 -1
- package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-DCT2Sq_z.js} +1 -1
- package/dist/assets/uk-PhsC-c4-.js +15 -0
- package/dist/assets/{useAppFontEffects-CbzHzFop.js → useAppFontEffects-B53Rb6m7.js} +166 -159
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
- package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-DsHmyMwp.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
- package/dist/assets/{web-components-DCLjCO9n.js → web-components-pcwCTWjC.js} +4 -4
- package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
- package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
- package/dist/index.html +5 -4
- package/dist/mini-chat.html +4 -3
- package/dist/mobile.html +4 -3
- package/package.json +3 -5
- package/server/index.js +36 -0
- package/server/lib/agent-memory/project-resolution.js +10 -1
- package/server/lib/agent-memory/project-resolution.test.js +9 -0
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/routes.test.js +76 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +85 -5
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/feature-routes-runtime.js +5 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +15 -0
- package/server/lib/opencode/settings-helpers.test.js +22 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +32 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +2 -0
- package/server/lib/project-context/runtime.js +7 -2
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -1
- package/server/lib/quota/providers/claude/index.js +2 -2
- package/server/lib/quota/providers/command-code.js +1 -1
- package/server/lib/quota/providers/command-code.test.js +13 -0
- package/server/lib/quota/providers/index.js +12 -4
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +4 -4
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +51 -8
- package/server/lib/small-model/index.test.js +73 -3
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
- package/dist/assets/DiffView-BWNq-0ov.js +0 -4
- package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
- package/dist/assets/PlanView-UvuxIl9-.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
- package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
- package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
- package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
- package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
- package/dist/assets/de-DbV6CLxv.js +0 -9
- package/dist/assets/es-CVDlyzZ4.js +0 -15
- package/dist/assets/fr-Czc-p0g-.js +0 -13
- package/dist/assets/index-1OhiMDBz.css +0 -1
- package/dist/assets/index-DzriVon2.js +0 -7
- package/dist/assets/ja-dwc9NM_S.js +0 -15
- package/dist/assets/ko-Ds1DZ8FX.js +0 -15
- package/dist/assets/main-BF51IOVF.js +0 -921
- package/dist/assets/main-D7UPARut.js +0 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
- package/dist/assets/miniChat-BISXSGOo.js +0 -2
- package/dist/assets/mobile-BnYxVuvw.js +0 -2
- package/dist/assets/pl-CLiTO7i-.js +0 -15
- package/dist/assets/pt-BR-GIimJgpK.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
- package/dist/assets/uk-DLfgD1ki.js +0 -15
- package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
- package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
- package/dist/assets/zh-CN-DkeP5awK.js +0 -15
- package/dist/assets/zh-TW-BocaFm3d.js +0 -15
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
|
@@ -5,7 +5,16 @@ import { readAuthFile } from '../opencode/auth.js';
|
|
|
5
5
|
import { readConfigLayers } from '../opencode/shared.js';
|
|
6
6
|
import { getModelCatalog } from './catalog.js';
|
|
7
7
|
import { resolveSmallModel, parseModelRef, isUsableAuthEntry, getAuthEntryForProvider } from './resolve.js';
|
|
8
|
-
import { callSmallModel, resolveProviderLogin } from './call.js';
|
|
8
|
+
import { DEDICATED_WIRE_FORMAT_PROVIDERS, callSmallModel, resolveProviderLogin } from './call.js';
|
|
9
|
+
import { getRuntimeProviderSnapshot } from './runtime-providers.js';
|
|
10
|
+
|
|
11
|
+
// Never a small model, whatever the transport looks like. A plugin can publish
|
|
12
|
+
// an OpenAI-compatible endpoint for Claude Code, but it is a façade over the
|
|
13
|
+
// Claude Agent SDK, which spawns the Claude Code CLI per request and spends
|
|
14
|
+
// the user's Claude subscription rate limit. Paying that for a session title
|
|
15
|
+
// or a summary is the wrong trade, so the refusal is unconditional rather than
|
|
16
|
+
// conditional on an endpoint existing.
|
|
17
|
+
const CLAUDE_CODE_PROVIDER = 'claude-code';
|
|
9
18
|
|
|
10
19
|
const OPENCHAMBER_SETTINGS_FILE = path.join(
|
|
11
20
|
process.env.OPENCHAMBER_DATA_DIR
|
|
@@ -120,7 +129,7 @@ export async function generateSmallModelText({ prompt, system, maxOutputTokens,
|
|
|
120
129
|
);
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
if (resolved.providerID ===
|
|
132
|
+
if (resolved.providerID === CLAUDE_CODE_PROVIDER) {
|
|
124
133
|
throw Object.assign(
|
|
125
134
|
new Error('Claude Code cannot be used for background small-model actions. Choose another Small Model in Settings → Sessions.'),
|
|
126
135
|
{ statusCode: 422, code: 'small-model-provider-unsupported' },
|
|
@@ -180,28 +189,62 @@ export async function generateSmallModelText({ prompt, system, maxOutputTokens,
|
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
/**
|
|
183
|
-
* Provider ids
|
|
184
|
-
*
|
|
185
|
-
*
|
|
192
|
+
* Provider ids the small model can actually call — an auth.json login, or a
|
|
193
|
+
* credential and endpoint the running OpenCode resolved for a plugin. Used by
|
|
194
|
+
* the Small Model and Changes Walkthrough pickers to hide providers that would
|
|
195
|
+
* only ever fail (e.g. opencode free models without a token).
|
|
186
196
|
*/
|
|
187
|
-
export function listAuthenticatedProviders() {
|
|
197
|
+
export async function listAuthenticatedProviders() {
|
|
188
198
|
try {
|
|
189
199
|
const auth = readAuthFile();
|
|
190
200
|
const ids = new Set(
|
|
191
201
|
Object.keys(auth || {}).filter((providerID) => isUsableAuthEntry(auth[providerID])),
|
|
192
202
|
);
|
|
193
|
-
ids.delete('claude-code');
|
|
194
203
|
// The catalog id is github-copilot while legacy auth entries may sit
|
|
195
204
|
// under the copilot alias.
|
|
196
205
|
if (isUsableAuthEntry(getAuthEntryForProvider(auth, 'github-copilot'))) {
|
|
197
206
|
ids.add('github-copilot');
|
|
198
207
|
}
|
|
208
|
+
// Kept separate so a runtime lookup that goes wrong costs the providers it
|
|
209
|
+
// would have added, never the logins already established from disk.
|
|
210
|
+
try {
|
|
211
|
+
for (const providerID of await listRuntimeCallableProviders()) ids.add(providerID);
|
|
212
|
+
} catch {
|
|
213
|
+
// The auth.json set below stands on its own.
|
|
214
|
+
}
|
|
215
|
+
ids.delete(CLAUDE_CODE_PROVIDER);
|
|
199
216
|
return Array.from(ids);
|
|
200
217
|
} catch {
|
|
201
218
|
return [];
|
|
202
219
|
}
|
|
203
220
|
}
|
|
204
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Providers that only the running OpenCode knows about — plugin-registered
|
|
224
|
+
* ones, and any whose endpoint is resolved at startup.
|
|
225
|
+
*
|
|
226
|
+
* The test is the same one applied to an auth.json login: a credential we may
|
|
227
|
+
* use and somewhere to send it. Whether the endpoint answers the protocol we
|
|
228
|
+
* speak is not knowable from any field OpenCode reports, and guessing it wrong
|
|
229
|
+
* removes a working model from the picker with nothing to explain it.
|
|
230
|
+
*/
|
|
231
|
+
async function listRuntimeCallableProviders() {
|
|
232
|
+
const snapshot = await getRuntimeProviderSnapshot();
|
|
233
|
+
if (!snapshot) return [];
|
|
234
|
+
const ids = [];
|
|
235
|
+
for (const id of snapshot.connected) {
|
|
236
|
+
const provider = snapshot.providers.get(id);
|
|
237
|
+
// No credential we may use — including the zen sentinel, whose free models
|
|
238
|
+
// belong to OpenCode's own server.
|
|
239
|
+
if (!provider?.apiKey || !provider.baseURL) continue;
|
|
240
|
+
// Reached through a dedicated wire format and already covered by the
|
|
241
|
+
// auth.json scan above.
|
|
242
|
+
if (DEDICATED_WIRE_FORMAT_PROVIDERS.has(id)) continue;
|
|
243
|
+
ids.push(id);
|
|
244
|
+
}
|
|
245
|
+
return ids;
|
|
246
|
+
}
|
|
247
|
+
|
|
205
248
|
/**
|
|
206
249
|
* Reports which model would be used, without calling it.
|
|
207
250
|
*
|
|
@@ -262,7 +305,7 @@ export async function describeSmallModel({ directory, preferredProviderID, prefe
|
|
|
262
305
|
|
|
263
306
|
// Settings/config/request overrides can name a provider with no usable login.
|
|
264
307
|
// Report that here so readiness can refuse before the user pays for a 401.
|
|
265
|
-
const hasLogin = Boolean(resolveProviderLogin({
|
|
308
|
+
const hasLogin = Boolean(await resolveProviderLogin({
|
|
266
309
|
auth,
|
|
267
310
|
workingDirectory: directory,
|
|
268
311
|
providerID: resolved.providerID,
|
|
@@ -19,15 +19,20 @@ vi.mock('./catalog.js', () => ({
|
|
|
19
19
|
getCatalogProvider: vi.fn(),
|
|
20
20
|
}));
|
|
21
21
|
vi.mock('./call.js', () => ({
|
|
22
|
+
DEDICATED_WIRE_FORMAT_PROVIDERS: new Set(['github-copilot', 'copilot', 'openai', 'anthropic', 'google']),
|
|
22
23
|
callSmallModel: vi.fn(),
|
|
23
|
-
resolveProviderLogin: vi.fn(({ auth, providerID }) => {
|
|
24
|
+
resolveProviderLogin: vi.fn(async ({ auth, providerID }) => {
|
|
24
25
|
const entry = auth?.[providerID];
|
|
25
26
|
return entry && typeof entry === 'object' ? entry : null;
|
|
26
27
|
}),
|
|
27
28
|
}));
|
|
29
|
+
vi.mock('./runtime-providers.js', () => ({
|
|
30
|
+
getRuntimeProviderSnapshot: vi.fn(async () => null),
|
|
31
|
+
}));
|
|
28
32
|
|
|
29
33
|
const { generateSmallModelText, describeSmallModel, listAuthenticatedProviders } = await import('./index.js');
|
|
30
34
|
const { readAuthFile } = await import('../opencode/auth.js');
|
|
35
|
+
const { getRuntimeProviderSnapshot } = await import('./runtime-providers.js');
|
|
31
36
|
const { readConfigLayers } = await import('../opencode/shared.js');
|
|
32
37
|
const { getModelCatalog } = await import('./catalog.js');
|
|
33
38
|
const { callSmallModel } = await import('./call.js');
|
|
@@ -44,6 +49,7 @@ describe('unsupported small-model providers', () => {
|
|
|
44
49
|
readConfigLayers.mockReturnValue({ mergedConfig: {} });
|
|
45
50
|
getModelCatalog.mockResolvedValue({});
|
|
46
51
|
callSmallModel.mockReset();
|
|
52
|
+
getRuntimeProviderSnapshot.mockResolvedValue(null);
|
|
47
53
|
});
|
|
48
54
|
|
|
49
55
|
it('rejects Claude Code with an actionable error before transport dispatch', async () => {
|
|
@@ -57,8 +63,72 @@ describe('unsupported small-model providers', () => {
|
|
|
57
63
|
expect(callSmallModel).not.toHaveBeenCalled();
|
|
58
64
|
});
|
|
59
65
|
|
|
60
|
-
it('does not offer Claude Code in the Small Model picker', () => {
|
|
61
|
-
expect(listAuthenticatedProviders()).not.toContain('claude-code');
|
|
66
|
+
it('does not offer Claude Code in the Small Model picker', async () => {
|
|
67
|
+
expect(await listAuthenticatedProviders()).not.toContain('claude-code');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// A plugin can publish an OpenAI-compatible endpoint for Claude Code, but it
|
|
71
|
+
// is a façade over the Claude Agent SDK: every call spawns the CLI and
|
|
72
|
+
// spends the user's Claude subscription. The refusal is about that cost, so
|
|
73
|
+
// an available endpoint must not lift it.
|
|
74
|
+
it('still refuses Claude Code when a plugin publishes an HTTP endpoint for it', async () => {
|
|
75
|
+
getRuntimeProviderSnapshot.mockResolvedValue({
|
|
76
|
+
providers: new Map([['claude-code', { id: 'claude-code', apiKey: 'plugin-key', baseURL: 'http://127.0.0.1:60668/v1', anonymousZen: false }]]),
|
|
77
|
+
connected: new Set(['claude-code']),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await expect(generateSmallModelText({
|
|
81
|
+
prompt: 'summarize this',
|
|
82
|
+
model: 'claude-code/haiku',
|
|
83
|
+
})).rejects.toMatchObject({ code: 'small-model-provider-unsupported' });
|
|
84
|
+
expect(await listAuthenticatedProviders()).not.toContain('claude-code');
|
|
85
|
+
|
|
86
|
+
getRuntimeProviderSnapshot.mockResolvedValue(null);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('provider availability for the model pickers', () => {
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
readAuthFile.mockReturnValue({ openai: { type: 'api', key: 'sk-test' } });
|
|
93
|
+
readConfigLayers.mockReturnValue({ mergedConfig: {} });
|
|
94
|
+
getModelCatalog.mockResolvedValue({});
|
|
95
|
+
getRuntimeProviderSnapshot.mockResolvedValue(null);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const snapshot = (providers, connected) => ({
|
|
99
|
+
providers: new Map(providers.map((provider) => [provider.id, provider])),
|
|
100
|
+
connected: new Set(connected ?? providers.map((provider) => provider.id)),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('offers a plugin provider that OpenCode resolved at runtime', async () => {
|
|
104
|
+
getRuntimeProviderSnapshot.mockResolvedValue(snapshot([
|
|
105
|
+
{ id: 'llmapi', apiKey: 'plugin-key', baseURL: 'https://api.llmapi.ai/v1', anonymousZen: false },
|
|
106
|
+
]));
|
|
107
|
+
|
|
108
|
+
expect(await listAuthenticatedProviders()).toEqual(expect.arrayContaining(['openai', 'llmapi']));
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('hides a provider with no endpoint to send a request to', async () => {
|
|
112
|
+
getRuntimeProviderSnapshot.mockResolvedValue(snapshot([
|
|
113
|
+
{ id: 'endpointless', apiKey: 'plugin-key', baseURL: null, anonymousZen: false },
|
|
114
|
+
]));
|
|
115
|
+
|
|
116
|
+
expect(await listAuthenticatedProviders()).not.toContain('endpointless');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('never offers opencode zen without a real login', async () => {
|
|
120
|
+
// The zen sentinel is not a credential, so the snapshot carries no apiKey.
|
|
121
|
+
getRuntimeProviderSnapshot.mockResolvedValue(snapshot([
|
|
122
|
+
{ id: 'opencode', apiKey: null, baseURL: 'https://opencode.ai/zen/v1', anonymousZen: true },
|
|
123
|
+
]));
|
|
124
|
+
|
|
125
|
+
expect(await listAuthenticatedProviders()).not.toContain('opencode');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('keeps the auth.json providers when OpenCode cannot be reached', async () => {
|
|
129
|
+
getRuntimeProviderSnapshot.mockResolvedValue(null);
|
|
130
|
+
|
|
131
|
+
expect(await listAuthenticatedProviders()).toContain('openai');
|
|
62
132
|
});
|
|
63
133
|
});
|
|
64
134
|
|
|
@@ -10,7 +10,7 @@ export function registerSmallModelRoutes(app, { getSmallModelService }) {
|
|
|
10
10
|
res.json({
|
|
11
11
|
available: Boolean(resolved),
|
|
12
12
|
model: resolved,
|
|
13
|
-
authenticatedProviders: listAuthenticatedProviders(),
|
|
13
|
+
authenticatedProviders: await listAuthenticatedProviders(),
|
|
14
14
|
});
|
|
15
15
|
} catch (error) {
|
|
16
16
|
console.error('Failed to resolve small model:', error);
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Provider state that exists only inside the running OpenCode process.
|
|
2
|
+
//
|
|
3
|
+
// A plugin registers its provider from the `config` hook and supplies the
|
|
4
|
+
// credential from its `auth` loader, both at startup. Neither ends up in
|
|
5
|
+
// `opencode.json` or `auth.json`, so a server that only reads files sees
|
|
6
|
+
// nothing — which is why plugin-backed models used to fail here with
|
|
7
|
+
// "has no known API base URL" while working fine in chat (#2666).
|
|
8
|
+
//
|
|
9
|
+
// `GET /provider` is where that state becomes visible. It reports, per
|
|
10
|
+
// provider, the resolved `options.baseURL` and `options.apiKey`, and per model
|
|
11
|
+
// the wire adapter (`api.npm`) and endpoint (`api.url`).
|
|
12
|
+
//
|
|
13
|
+
// What it does NOT report is `options.fetch`. OpenCode strips functions from
|
|
14
|
+
// the response, and a plugin is free to put its whole protocol in there:
|
|
15
|
+
// rewriting the path, signing the request, translating the payload. Such a
|
|
16
|
+
// provider advertises a perfectly ordinary base URL that answers nothing we
|
|
17
|
+
// know how to ask, and no field distinguishes the two.
|
|
18
|
+
//
|
|
19
|
+
// Asking the endpoint (`GET /models`) looked like the way to tell them apart,
|
|
20
|
+
// and it does answer correctly for that case — but measured against the 166
|
|
21
|
+
// providers in the models.dev catalog it also denies six that work fine and
|
|
22
|
+
// simply have no `/models` route. A provider that vanishes from the picker
|
|
23
|
+
// explains nothing; one that fails on use says why. So this module reports
|
|
24
|
+
// what it knows and leaves the verdict to the call itself.
|
|
25
|
+
|
|
26
|
+
const SNAPSHOT_TTL_MS = 30_000;
|
|
27
|
+
const SNAPSHOT_TIMEOUT_MS = 5_000;
|
|
28
|
+
|
|
29
|
+
// opencode zen hands out this sentinel instead of a key when the user has no
|
|
30
|
+
// zen login, and trims its catalog to the free models. Those run on OpenCode's
|
|
31
|
+
// own subsidised infrastructure and are meant to be reached through OpenCode,
|
|
32
|
+
// not by us. Treating the sentinel as a credential would do exactly that, so
|
|
33
|
+
// it is never accepted as one.
|
|
34
|
+
export const ZEN_ANONYMOUS_API_KEY = 'public';
|
|
35
|
+
|
|
36
|
+
let connection = null;
|
|
37
|
+
let snapshot = null;
|
|
38
|
+
let snapshotAt = 0;
|
|
39
|
+
let inflight = null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Wires this module to the running OpenCode instance. Called once at server
|
|
43
|
+
* startup; pass `null` to detach. Until it is wired every lookup answers
|
|
44
|
+
* "nothing known", which leaves the file-based resolution unchanged.
|
|
45
|
+
*/
|
|
46
|
+
export function configureOpenCodeRuntimeProviders(next) {
|
|
47
|
+
connection = next ?? null;
|
|
48
|
+
resetOpenCodeRuntimeProviders();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Drops every cached answer. OpenCode restarts reload plugins, which can
|
|
53
|
+
* change ports, keys and the provider list itself.
|
|
54
|
+
*/
|
|
55
|
+
export function resetOpenCodeRuntimeProviders() {
|
|
56
|
+
snapshot = null;
|
|
57
|
+
snapshotAt = 0;
|
|
58
|
+
inflight = null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The boundary. Everything the `/provider` payload claims is checked here, so
|
|
63
|
+
* the rest of this module and its callers work with settled values:
|
|
64
|
+
* a credential we may use, an endpoint, and whether the provider is the
|
|
65
|
+
* anonymous zen case.
|
|
66
|
+
*
|
|
67
|
+
* The credential deliberately prefers `options.apiKey` over the `key` field:
|
|
68
|
+
* for a plugin provider the former is what its auth loader produced and what
|
|
69
|
+
* OpenCode itself sends, while `key` only carries env/auth.json values this
|
|
70
|
+
* server can already read from disk.
|
|
71
|
+
*/
|
|
72
|
+
function parseProviderListing(payload) {
|
|
73
|
+
const providers = new Map();
|
|
74
|
+
const connected = new Set();
|
|
75
|
+
if (!payload || typeof payload !== 'object') return { providers, connected };
|
|
76
|
+
|
|
77
|
+
const text = (value) => (typeof value === 'string' && value.trim() ? value.trim() : null);
|
|
78
|
+
const record = (value) => (value && typeof value === 'object' ? value : {});
|
|
79
|
+
const endpoint = (value) => text(value)?.replace(/\/+$/, '') ?? null;
|
|
80
|
+
|
|
81
|
+
for (const raw of Array.isArray(payload.all) ? payload.all : []) {
|
|
82
|
+
const id = text(record(raw).id);
|
|
83
|
+
if (!id) continue;
|
|
84
|
+
const options = record(record(raw).options);
|
|
85
|
+
const firstModel = record(Object.values(record(record(raw).models))[0]);
|
|
86
|
+
const declaredKey = text(options.apiKey);
|
|
87
|
+
providers.set(id, {
|
|
88
|
+
id,
|
|
89
|
+
source: text(record(raw).source),
|
|
90
|
+
apiKey: declaredKey === ZEN_ANONYMOUS_API_KEY ? null : (declaredKey ?? text(record(raw).key)),
|
|
91
|
+
baseURL: endpoint(options.baseURL) ?? endpoint(record(firstModel.api).url),
|
|
92
|
+
// True only for the zen-without-login case: a provider that is present
|
|
93
|
+
// and usable through OpenCode, but that we must not call ourselves.
|
|
94
|
+
anonymousZen: declaredKey === ZEN_ANONYMOUS_API_KEY,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Providers OpenCode considers usable right now. A provider can be present
|
|
99
|
+
// in `all` (it is in the catalog) without any credential behind it.
|
|
100
|
+
for (const raw of Array.isArray(payload.connected) ? payload.connected : []) {
|
|
101
|
+
const id = text(raw);
|
|
102
|
+
if (id) connected.add(id);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return { providers, connected };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const fetchSnapshot = async () => {
|
|
109
|
+
const response = await fetch(connection.buildOpenCodeUrl('/provider', ''), {
|
|
110
|
+
headers: { Accept: 'application/json', ...connection.getOpenCodeAuthHeaders() },
|
|
111
|
+
signal: AbortSignal.timeout(SNAPSHOT_TIMEOUT_MS),
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`OpenCode provider listing failed with ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
return parseProviderListing(await response.json());
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The current runtime provider snapshot, or `null` when OpenCode cannot be
|
|
121
|
+
* reached.
|
|
122
|
+
*
|
|
123
|
+
* `null` means "unknown", never "no providers": callers must fall back to
|
|
124
|
+
* their file-based resolution rather than treat an unreachable OpenCode as an
|
|
125
|
+
* empty provider list.
|
|
126
|
+
*/
|
|
127
|
+
export async function getRuntimeProviderSnapshot() {
|
|
128
|
+
if (!connection) return null;
|
|
129
|
+
if (snapshot && Date.now() - snapshotAt < SNAPSHOT_TTL_MS) return snapshot;
|
|
130
|
+
if (!inflight) {
|
|
131
|
+
inflight = fetchSnapshot().finally(() => {
|
|
132
|
+
inflight = null;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
snapshot = await inflight;
|
|
137
|
+
snapshotAt = Date.now();
|
|
138
|
+
return snapshot;
|
|
139
|
+
} catch {
|
|
140
|
+
// Keep serving the previous snapshot when there is one: a momentarily
|
|
141
|
+
// unreachable OpenCode should not retract providers that were resolving a
|
|
142
|
+
// second ago.
|
|
143
|
+
return snapshot;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Runtime credential and endpoint for one provider, or `null` when OpenCode
|
|
149
|
+
* knows nothing about it.
|
|
150
|
+
*/
|
|
151
|
+
export async function getRuntimeProvider(providerID) {
|
|
152
|
+
const current = await getRuntimeProviderSnapshot();
|
|
153
|
+
return current?.providers.get(providerID) ?? null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ZEN_ANONYMOUS_API_KEY,
|
|
5
|
+
configureOpenCodeRuntimeProviders,
|
|
6
|
+
getRuntimeProvider,
|
|
7
|
+
getRuntimeProviderSnapshot,
|
|
8
|
+
resetOpenCodeRuntimeProviders,
|
|
9
|
+
} from './runtime-providers.js';
|
|
10
|
+
|
|
11
|
+
const providerPayload = (overrides = {}) => ({
|
|
12
|
+
all: [
|
|
13
|
+
{
|
|
14
|
+
id: 'llmapi',
|
|
15
|
+
source: 'config',
|
|
16
|
+
options: { apiKey: 'plugin-key', baseURL: 'https://api.llmapi.ai/v1/' },
|
|
17
|
+
models: { 'claude-opus-4-8': { api: { id: 'claude-opus-4-8', url: '', npm: '@ai-sdk/anthropic' } } },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'opencode',
|
|
21
|
+
source: 'custom',
|
|
22
|
+
options: { apiKey: ZEN_ANONYMOUS_API_KEY },
|
|
23
|
+
models: { 'free-model': { api: { id: 'free-model', url: 'https://opencode.ai/zen/v1', npm: '@ai-sdk/openai-compatible' } } },
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'zai-coding-plan',
|
|
27
|
+
source: 'api',
|
|
28
|
+
key: 'auth-json-key',
|
|
29
|
+
options: {},
|
|
30
|
+
models: { 'glm-5': { api: { id: 'glm-5', url: 'https://api.z.ai/api/coding/paas/v4', npm: '@ai-sdk/openai-compatible' } } },
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
connected: ['llmapi', 'opencode', 'zai-coding-plan'],
|
|
34
|
+
...overrides,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('OpenCode runtime provider snapshot', () => {
|
|
38
|
+
let fetchMock;
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
fetchMock = vi.fn(async () => new Response(JSON.stringify(providerPayload()), {
|
|
42
|
+
status: 200,
|
|
43
|
+
headers: { 'content-type': 'application/json' },
|
|
44
|
+
}));
|
|
45
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
46
|
+
configureOpenCodeRuntimeProviders({
|
|
47
|
+
buildOpenCodeUrl: (pathname) => `http://127.0.0.1:4096${pathname}`,
|
|
48
|
+
getOpenCodeAuthHeaders: () => ({ Authorization: 'Basic test' }),
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(() => {
|
|
53
|
+
configureOpenCodeRuntimeProviders(null);
|
|
54
|
+
resetOpenCodeRuntimeProviders();
|
|
55
|
+
vi.unstubAllGlobals();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('reports the credential and endpoint a plugin registered at runtime', async () => {
|
|
59
|
+
const provider = await getRuntimeProvider('llmapi');
|
|
60
|
+
|
|
61
|
+
expect(provider).toMatchObject({ apiKey: 'plugin-key', baseURL: 'https://api.llmapi.ai/v1' });
|
|
62
|
+
expect(fetchMock.mock.calls[0][0]).toBe('http://127.0.0.1:4096/provider');
|
|
63
|
+
expect(fetchMock.mock.calls[0][1].headers).toMatchObject({ Authorization: 'Basic test' });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('refuses the zen sentinel as a credential', async () => {
|
|
67
|
+
const provider = await getRuntimeProvider('opencode');
|
|
68
|
+
|
|
69
|
+
expect(provider.apiKey).toBeNull();
|
|
70
|
+
expect(provider.anonymousZen).toBe(true);
|
|
71
|
+
// The endpoint is still reported; only the credential is withheld.
|
|
72
|
+
expect(provider.baseURL).toBe('https://opencode.ai/zen/v1');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('falls back to the model endpoint when the provider carries no baseURL', async () => {
|
|
76
|
+
expect((await getRuntimeProvider('zai-coding-plan')).baseURL).toBe('https://api.z.ai/api/coding/paas/v4');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('serves one snapshot to concurrent callers instead of refetching', async () => {
|
|
80
|
+
await Promise.all([getRuntimeProvider('llmapi'), getRuntimeProvider('opencode'), getRuntimeProvider('zai-coding-plan')]);
|
|
81
|
+
|
|
82
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('answers "unknown" rather than "no providers" when OpenCode is unreachable', async () => {
|
|
86
|
+
resetOpenCodeRuntimeProviders();
|
|
87
|
+
fetchMock.mockRejectedValue(new Error('connection refused'));
|
|
88
|
+
|
|
89
|
+
expect(await getRuntimeProviderSnapshot()).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('keeps the previous snapshot when a later refresh fails', async () => {
|
|
93
|
+
await getRuntimeProviderSnapshot();
|
|
94
|
+
fetchMock.mockRejectedValue(new Error('connection refused'));
|
|
95
|
+
|
|
96
|
+
// Past the snapshot TTL, so the next read genuinely attempts a refresh.
|
|
97
|
+
vi.useFakeTimers();
|
|
98
|
+
vi.setSystemTime(Date.now() + 60_000);
|
|
99
|
+
const refreshed = await getRuntimeProviderSnapshot();
|
|
100
|
+
vi.useRealTimers();
|
|
101
|
+
|
|
102
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
103
|
+
expect(refreshed.providers.has('llmapi')).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('stays on file-based resolution until it is configured', async () => {
|
|
107
|
+
configureOpenCodeRuntimeProviders(null);
|
|
108
|
+
|
|
109
|
+
expect(await getRuntimeProvider('llmapi')).toBeNull();
|
|
110
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as r,j as i}from"./vendor-react-BUCujlKS.js";import{u as n}from"./index-DzriVon2.js";import{f as j,V as b,I as m}from"./useAppFontEffects-CbzHzFop.js";import{D as y}from"./DiagramEditor-B9NCadU7.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./vendor-react-drawio-Ct3Q0DsD.js";function Yi(){const{t:s}=j(),{files:o}=b(),[e,g]=r.useState(null),[p,a]=r.useState(""),[x,l]=r.useState(!0),c=r.useRef(null),u=n(t=>t.pendingDiagramFile),f=r.useCallback(async t=>{l(!0),g(t);try{const d=await o?.readFile?.(t);d&&a(d.content)}catch{a("")}finally{l(!1)}},[o]);r.useEffect(()=>{if(!u)return;const t=n.getState().consumePendingDiagramFile();t&&f(t)},[f,u]);const h=r.useCallback(async()=>{const t=c.current?.getXml();e&&o?.writeFile&&t&&t!==p&&(await o.writeFile(e,t),a(t))},[e,o,p]),v=e?e.split("/").pop()||e:"";return e?x?i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx(m,{name:"loader-4",className:"size-4 animate-spin"})}):i.jsxs("div",{className:"flex h-full flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[i.jsx(m,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),i.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:v}),i.jsx("button",{type:"button",onClick:()=>{h()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.saveDiagram"),children:i.jsx(m,{name:"save-3",className:"size-4"})}),i.jsx("button",{type:"button",onClick:()=>n.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:s("filesView.diagram.closeDiagramView"),children:i.jsx(m,{name:"close",className:"size-4"})})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(y,{ref:c,xml:p,className:"h-full"})})]}):i.jsx("div",{className:"flex h-full items-center justify-center p-3",children:i.jsx("div",{className:"typography-ui text-muted-foreground",children:s("filesView.editor.pickFileFromTree")})})}export{Yi as DiagramView};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{R as o,j as n,f as pe}from"./vendor-react-BUCujlKS.js";import{u as Z,E as Ze,a as lt}from"./index-DzriVon2.js";import{f as me,V as ct,a0 as Mt,aV as It,a2 as _t,a1 as Bt,a3 as zt,a4 as le,y as Je,k as Pt,cq as Ot,t as Ie,hA as $t,ab as De,B as ue,I as _,h as ne,aX as Gt,aY as Kt,aZ as Wt,h2 as ft,hB as Ht,fd as qt,bU as dt,ad as ut,aa as Ut,aR as Xt,fg as Ke,aT as Yt,fh as Qt,aU as Zt}from"./useAppFontEffects-CbzHzFop.js";import{P as Jt}from"./PierreDiffViewer-D_Gt4A_6.js";import{b as en,v as tn,g as nn,W as sn}from"./main-BF51IOVF.js";import{f as rn}from"./patchFileDiff-BEDPDypx.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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-B37yB9jZ.js";import"./isDiffPlainText-DwHKxDYc.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-CegKdDXi.js";import"./runtimeEndpointReset-BMBRhIbf.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-xKU4LRuQ.js";import"./scheduledTasksApi-01zzfzqH.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const et=(r,e)=>{if(e.length===0)return null;let i=null,a=null;for(const c of e)c.top<=r?(!i||c.top>i.top)&&(i=c):(!a||c.top<a.top)&&(a=c);const d=i??a;return d?{path:d.path,topOffset:d.top-r}:null},on=(r,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,r+i-e)),tt=r=>{if(!r)return null;const e=r.split(`
|
|
2
|
-
`);let i=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const c=Number.parseInt(d[1]??"",10);i=Number.isFinite(c)&&c>=1?c:null;continue}if(i!==null){if(a.startsWith(" ")){i+=1;continue}if(a.startsWith("+"))return i;if(a.startsWith("-"))return Math.max(1,i)}}return null},an=1100,ln=15e3,nt=500,st=300,cn=1e6,fn=3,dn=r=>r<=6?r:r<=12?6:r<=25?4:2,un=o.memo(()=>{const r=pe.c(4),{t:e}=me();let i;r[0]!==e?(i=e("diffView.binary.unavailable"),r[0]=e,r[1]=i):i=r[1];let a;return r[2]!==i?(a=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:i})}),r[2]=i,r[3]=a):a=r[3],a}),pt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},pn=pt.M,mn=r=>{const e=r.index?.trim(),i=r.working_dir?.trim();return e&&e!=="?"?e.charAt(0):i?i.charAt(0):e?.charAt(0)||i?.charAt(0)||"M"},mt=r=>{const e=mn(r);return pt[e]??pn},gn=r=>{const{index:e,working_dir:i}=r;return e==="A"||i==="A"||e==="?"||i==="?"},it=r=>{const e=r.index?.trim();return!!(e&&e!=="?")},rt=r=>!!r.working_dir?.trim()||r.index==="?",hn=(r,e)=>qt(r,e),ot=r=>(r||"").replace(/\\/g,"/").replace(/\/+$/,""),at=(r,e)=>{const i=r.split(`
|
|
3
|
-
`),a=e.split(`
|
|
4
|
-
`),d=Math.min(i.length,a.length);for(let c=0;c<d;c+=1)if(i[c]!==a[c])return c+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},xn=r=>/^Binary files .+ differ$/m.test(r)||/^GIT binary patch$/m.test(r),wn=r=>Array.isArray(r)?r.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],yn=r=>r==="added"?"A":r==="deleted"?"D":"M",gt=(r,e,i)=>xn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:rn(r,e),contextMode:i},ht=(r,e,i)=>{const a=r??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:ne("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},bn=o.memo(r=>{const e=pe.c(53),{scope:i,workingCount:a,stagedCount:d,turnCount:c,onScopeChange:g}=r,{t:p}=me(),[f,x]=o.useState(!1),w=i==="staged"?d:i==="turn"?c:a;let u;e[0]!==i||e[1]!==p?(u=p(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":"diffView.scope.changed"),e[0]=i,e[1]=p,e[2]=u):u=e[2];const N=u;let y;e[3]!==p?(y=p("diffView.scope.selectorAria"),e[3]=p,e[4]=y):y=e[4];let D;e[5]!==w?(D=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",w]}),e[5]=w,e[6]=D):D=e[6];let T;e[7]!==N||e[8]!==D?(T=n.jsxs("span",{className:"whitespace-nowrap",children:[N,D]}),e[7]=N,e[8]=D,e[9]=T):T=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(_,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let j;e[11]!==y||e[12]!==T?(j=n.jsx(Xt,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":y,children:[T,k]})}),e[11]=y,e[12]=T,e[13]=j):j=e[13];let M;e[14]!==g?(M=X=>{(X==="working"||X==="staged"||X==="turn")&&(g?.(X),x(!1))},e[14]=g,e[15]=M):M=e[15];let W;e[16]!==p?(W=p("diffView.scope.changed"),e[16]=p,e[17]=W):W=e[17];let H;e[18]!==W?(H=n.jsx("span",{children:W}),e[18]=W,e[19]=H):H=e[19];let J;e[20]!==a?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=J):J=e[21];let q;e[22]!==J||e[23]!==H?(q=n.jsx(Ke,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[H,J]})}),e[22]=J,e[23]=H,e[24]=q):q=e[24];let U;e[25]!==p?(U=p("diffView.scope.staged"),e[25]=p,e[26]=U):U=e[26];let V;e[27]!==U?(V=n.jsx("span",{children:U}),e[27]=U,e[28]=V):V=e[28];let I;e[29]!==d?(I=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=I):I=e[30];let ee;e[31]!==V||e[32]!==I?(ee=n.jsx(Ke,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[V,I]})}),e[31]=V,e[32]=I,e[33]=ee):ee=e[33];let L;e[34]!==p?(L=p("diffView.scope.lastTurn"),e[34]=p,e[35]=L):L=e[35];let z;e[36]!==L?(z=n.jsx("span",{children:L}),e[36]=L,e[37]=z):z=e[37];let P;e[38]!==c?(P=n.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),e[38]=c,e[39]=P):P=e[39];let E;e[40]!==z||e[41]!==P?(E=n.jsx(Ke,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[z,P]})}),e[40]=z,e[41]=P,e[42]=E):E=e[42];let O;e[43]!==i||e[44]!==q||e[45]!==ee||e[46]!==E||e[47]!==M?(O=n.jsx(Yt,{align:"start",className:"w-40",children:n.jsxs(Qt,{value:i,onValueChange:M,children:[q,ee,E]})}),e[43]=i,e[44]=q,e[45]=ee,e[46]=E,e[47]=M,e[48]=O):O=e[48];let te;return e[49]!==f||e[50]!==O||e[51]!==j?(te=n.jsxs(Zt,{open:f,onOpenChange:x,children:[j,O]}),e[49]=f,e[50]=O,e[51]=j,e[52]=te):te=e[52],te}),vn=o.memo(r=>{const e=pe.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=r,{t:c}=me();if(i.length===0)return null;let g;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==c){let f;e[5]!==d||e[6]!==a||e[7]!==c?(f=x=>{const w=mt(x),u=a===x.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(x.path),className:ne("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",u?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(ut,{filePath:x.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:c(w.descriptionKey),"aria-label":c(w.descriptionKey),children:w.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:x.path,children:x.path}),ht(x.insertions,x.deletions)]})},x.path)},e[5]=d,e[6]=a,e[7]=c,e[8]=f):f=e[8],g=i.map(f),e[0]=i,e[1]=d,e[2]=a,e[3]=c,e[4]=g}else g=e[4];let p;return e[9]!==g?(p=n.jsx(dt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:g})}),e[9]=g,e[10]=p):p=e[10],p}),jn=o.memo(r=>{const e=pe.c(20),{filePath:i,diff:a,renderSideBySide:d}=r,{t:c}=me(),g=a.original.length>0,p=a.modified.length>0,f=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",x=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let u;e[1]!==a.original||e[2]!==i||e[3]!==g||e[4]!==x||e[5]!==d||e[6]!==c?(u=g&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c("diffView.image.original")}),n.jsx("img",{src:a.original,alt:c("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=g,e[4]=x,e[5]=d,e[6]=c,e[7]=u):u=e[7];let N;e[8]!==a.modified||e[9]!==i||e[10]!==p||e[11]!==g||e[12]!==x||e[13]!==d||e[14]!==c?(N=p&&n.jsxs("div",{className:x,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:c(g?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:c("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=p,e[11]=g,e[12]=x,e[13]=d,e[14]=c,e[15]=N):N=e[15];let y;return e[16]!==f||e[17]!==u||e[18]!==N?(y=n.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:n.jsxs("div",{className:f,children:[u,N]})}),e[16]=f,e[17]=u,e[18]=N,e[19]=y):y=e[19],y}),Sn=o.memo(r=>{const e=pe.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:c}=r;let g;e[0]!==i?(g=Ut(i)||"text",e[0]=i,e[1]=g):g=e[1];const p=g;if(a.isBinary){let w;return e[2]===Symbol.for("react.memo_cache_sentinel")?(w=n.jsx(un,{}),e[2]=w):w=e[2],w}if(De(i)){let w;return e[3]!==a||e[4]!==i||e[5]!==d?(w=n.jsx(jn,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=w):w=e[6],w}let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f={contain:"layout"},e[7]=f):f=e[7];let x;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==p||e[13]!==d||e[14]!==c?(x=n.jsx("div",{className:"w-full",style:f,children:n.jsx(Jt,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:p,fileName:i,renderSideBySide:d,wrapLines:c,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=p,e[13]=d,e[14]=c,e[15]=x):x=e[15],x}),Nn=o.memo(r=>{const e=pe.c(7),{filePath:i,staged:a,busyAction:d,disabled:c,onAction:g}=r,{t:p}=me();let f;return e[0]!==d||e[1]!==c||e[2]!==i||e[3]!==g||e[4]!==a||e[5]!==p?(f=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(We,{label:p("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:c,onClick:()=>g("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(We,{label:p("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:c,tone:"failure",onClick:()=>g("discard")}),n.jsx(We,{label:p("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:c,tone:"success",onClick:()=>g("stage")})]})}),e[0]=d,e[1]=c,e[2]=i,e[3]=g,e[4]=a,e[5]=p,e[6]=f):f=e[6],f}),We=r=>{const e=pe.c(14),{label:i,icon:a,loading:d,disabled:c,tone:g,onClick:p}=r,f=g==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",x=g==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let w;e[0]!==f||e[1]!==x?(w=ne("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",f,x),e[0]=f,e[1]=x,e[2]=w):w=e[2];let u;e[3]!==p?(u=D=>{D.stopPropagation(),p()},e[3]=p,e[4]=u):u=e[4];let N;e[5]!==a||e[6]!==d?(N=d?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=N):N=e[7];let y;return e[8]!==c||e[9]!==i||e[10]!==w||e[11]!==u||e[12]!==N?(y=n.jsx(ue,{variant:"ghost",size:"sm",className:w,disabled:c,title:i,"aria-label":i,onClick:u,children:N}),e[8]=c,e[9]=i,e[10]=w,e[11]=u,e[12]=N,e[13]=y):y=e[13],y},Fn=o.memo(({directory:r,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:c,isMounted:g,onSelect:p,onExpandedChange:f,registerSectionRef:x,showOpenInEditorAction:w=!1,isOpeningInEditor:u=!1,onOpenInEditor:N,staged:y=!1,loadFullFiles:D=!1,initialDiffData:T=null})=>{const{t:k}=me(),{git:j}=ct(),M=le(o.useCallback(m=>m.directories.get(r)?.diffCache.get(e.path)??null,[r,e.path])),W=le(m=>m.setDiff),H=le(m=>m.fetchStatus),J=Z(m=>m.setDiffFileLayout),[q,U]=o.useState(0),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[z,P]=o.useState(null),[E,O]=o.useState(!1),[te,X]=o.useState(null),[se,je]=o.useState(null),ie=o.useRef(null),Se=o.useRef(null),ce=o.useMemo(()=>mt(e),[e]),Re=i==="side-by-side",ge=D?"full":"patch",fe=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Y=o.useMemo(()=>T||(y?se:te||(M?{original:M.original,modified:M.modified,isBinary:M.isBinary,contextMode:"full"}:null)),[M,T,te,y,se]),Ne=Y?.contextMode===ge,b=o.useCallback(m=>{Se.current=m,x(e.path,m)},[e.path,x]),he=o.useCallback(m=>{f(e.path,m)},[e.path,f]),re=o.useCallback(()=>{p(e.path)},[e.path,p]);o.useEffect(()=>{y?je(null):X(null),I(null),ie.current=null},[fe,y]),o.useEffect(()=>{if(!c||!g)return;if(!r||T||Y&&Ne){ie.current=null,L(!1);return}const m=`${r}::${e.path}::${y?"staged":"unstaged"}::${fe}::${ge}::${q}`;if(ie.current===m)return;ie.current=m,I(null),L(!0);let C=!1;const ae=lt(),Ae=D?cn:fn,Ve=De(e.path)?j.getGitFileDiff(r,{path:e.path,staged:y}):j.getGitDiff(r,{path:e.path,staged:y,contextLines:Ae}),Le=ln,Ee=new Promise((R,$)=>{setTimeout(()=>$(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ve,Ee]).then(R=>{if(!C){if("diff"in R){const $=gt(e.path,R.diff,ge);y?je($):X($)}else{const $={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};y?je($):W(r,e.path,$,ae)}L(!1)}}).catch(R=>{if(C)return;const $=R instanceof Error?R.message:String(R);I($),L(!1)}),()=>{C=!0,ie.current===m&&(ie.current=null)}},[ge,Y,Ne,q,r,e.path,fe,j,T,c,g,D,W,y]);const Fe=o.useCallback(()=>{he(!c),re()},[he,re,c]),oe=o.useCallback(async m=>{if(!(!r||z!==null)){P(m);try{m==="stage"?await j.stageGitFile(r,e.path):m==="unstage"?await j.unstageGitFile(r,e.path):await j.revertGitFile(r,e.path,{scope:"working"}),U(C=>C+1),await H(r,j)}catch(C){const ae=m==="unstage"?"gitView.toast.unstageFileFailed":m==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ie.error(C instanceof Error?C.message:k(ae))}finally{P(C=>C===m?null:C)}}},[r,H,e.path,z,j,k]);return n.jsxs("div",{ref:b,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Fe,onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),Fe())},className:ne("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:c?n.jsx(_,{name:"arrow-down-s",className:"size-4"}):n.jsx(_,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ce.color},title:k(ce.descriptionKey),"aria-label":k(ce.descriptionKey),children:ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(ut,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const m=e.path.lastIndexOf("/");if(m===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const C=e.path.slice(0,m),ae=e.path.slice(m+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:C}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ae})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[ht(e.insertions,e.deletions),w&&N?n.jsx(ue,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:m=>{m.stopPropagation(),N(e.path,Y)},disabled:u,children:u?n.jsx(_,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(_,{name:"edit",className:"size-3.5"})}):null,n.jsx(ft,{mode:Re?"side-by-side":"unified",onModeChange:m=>{const C=m==="side-by-side"?"side-by-side":"inline";J(e.path,C)},className:"opacity-70"})]})]})}),c&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!g&&!V?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,V?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:V}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>U(m=>m+1),children:k("diffView.actions.retry")})]}):null,g&&ee&&!Y&&!V?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,g&&Y&&!E&&e.insertions+e.deletions>nt?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>O(!0),children:k("diffView.actions.renderAnyway")})]}):null,g&&Y&&(E||e.insertions+e.deletions<=nt)?n.jsxs(n.Fragment,{children:[n.jsx(Sn,{filePath:e.path,diff:Y,renderSideBySide:Re,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:n.jsx(Nn,{filePath:e.path,staged:y,busyAction:z,disabled:z!==null,onAction:oe})})})]}):null]})]})}),zi=({hideStackedFileSidebar:r=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:c,targetFilePath:g=null,flushContent:p=!1})=>{const{t:f}=me(),{git:x,files:w}=ct(),u=Mt(),N=Z(t=>t.openContextSurface),y=en(t=>t.requestSource),{screenWidth:D,isMobile:T}=It(),k=_t(u??null),j=Bt(u??null),M=zt(u??null),W=le(t=>t.setActiveDirectory),H=le(t=>t.ensureStatus),J=le(t=>t.fetchStatus),q=le(t=>t.clearDiffCache),U=le(t=>t.setDiff),[V,I]=o.useState(null),[ee,L]=o.useState(!1),[z,P]=o.useState(null),[E,O]=o.useState(()=>new Set),[te,X]=o.useState(()=>new Set),[se,je]=o.useState(!1),[ie,Se]=o.useState(0),[ce,Re]=o.useState(()=>new Map),[ge,fe]=o.useState(!1),[Y,Ne]=o.useState(!1),[b,he]=o.useState(d);o.useEffect(()=>{he(d)},[d]);const re=Z(t=>t.pendingDiffFile),Fe=Z(t=>t.pendingDiffStaged),oe=Z(t=>t.pendingDiffScope),m=Z(t=>t.setPendingDiffFile),C=Z(t=>t.diffLayoutPreference),ae=Z(t=>t.diffFileLayout),Ae=Z(t=>t.setDiffFileLayout),Ve=Z(t=>t.diffWrapLines),Le=Z(t=>t.setDiffWrapLines),Ee=Z(t=>t.openContextFileAtLine),R=Je(t=>t.currentSessionId),$=Pt(R??"",u??void 0),_e=Ve,Be=b==="staged"?!0:b==="working"?!1:null,Te=Be??ee,ze=T||D<=768,xt=!!R&&b!=="turn"&&!ze&&!Ze(),wt=b!=="turn"&&!ze&&!Ze(),yt=!r&&!ze&&D>=1024,xe=o.useRef(null),Ce=o.useRef(new Map),de=o.useRef(null),B=o.useRef(null),we=o.useRef(!1),ye=o.useRef(null),He=o.useRef(null),Pe=o.useRef(null),Oe=o.useRef(null),qe=o.useCallback(()=>{const t=xe.current;if(!t)return null;const s=t.getBoundingClientRect().top,l=[];for(const[h,v]of Ce.current)v&&l.push({path:h,top:v.getBoundingClientRect().top});return et(s,l)},[]),be=o.useCallback(()=>{de.current=null,we.current=!1,P(null),B.current!==null&&(window.cancelAnimationFrame(B.current),B.current=null)},[]),ve=o.useCallback(t=>{O(s=>{if(s.has(t))return s;const l=new Set(s);return l.add(t),l})},[]),ke=o.useMemo(()=>{for(let t=$.length-1;t>=0;t-=1){const s=$[t];if(s.role==="user")return wn(s.summary?.diffs)}return[]},[$]),bt=o.useMemo(()=>{const t=new Map;for(const s of ke)if(s.file){if(typeof s.patch=="string"){t.set(s.file,gt(s.file,s.patch,"patch"));continue}t.set(s.file,{original:s.before??"",modified:s.after??"",contextMode:"full"})}return t},[ke]),S=o.useMemo(()=>{if(b==="turn")return ke.map(l=>({path:l.file??"",index:"",working_dir:yn(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,h)=>l.path.localeCompare(h.path));if(!j?.files)return[];const t=j.diffStats??{},s=b==="staged"?it:b==="working"?rt:()=>!0;return j.files.filter(s).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:gn(l)})).sort((l,h)=>l.path.localeCompare(h.path))},[b,ke,j]),vt=o.useMemo(()=>j?.files?j.files.filter(rt).length:0,[j]),jt=o.useMemo(()=>j?.files?j.files.filter(it).length:0,[j]),St=ke.length,$e=o.useMemo(()=>S.map(t=>t.path).join("\0"),[S]);o.useEffect(()=>{const t=$e?$e.split("\0"):[],s=new Set(t),l=`${u??""}:${b}:${e?"collapsed":"default"}`,h=He.current!==l;He.current=l,O(v=>{if(h){const A=e?0:dn(t.length);return new Set(t.slice(0,A))}let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v}),X(v=>{if(h)return new Set;let G=!1;const F=new Set;for(const A of v){if(!s.has(A)){G=!0;continue}F.add(A)}return G?F:v})},[b,$e,u,e]);const Ue=o.useCallback(()=>{ye.current=null;const t=xe.current;if(!t)return;const s=t.getBoundingClientRect(),l=s.top-st,h=s.bottom+st,v={},G=[];for(const[F,A]of Ce.current){if(!A)continue;const K=A.getBoundingClientRect();G.push({path:F,top:K.top}),E.has(F)&&(K.bottom<l||K.top>h||(v[F]=!0))}Pe.current=et(s.top,G),X(F=>{let A=!1;const K=new Set(F);for(const Qe of Object.keys(v))K.has(Qe)||(K.add(Qe),A=!0);return A?K:F})},[E]),Q=o.useCallback(()=>{typeof window>"u"||ye.current===null&&(ye.current=window.requestAnimationFrame(Ue))},[Ue]);o.useEffect(()=>{const t=xe.current;if(t)return Q(),t.addEventListener("scroll",Q,{passive:!0}),window.addEventListener("resize",Q),()=>{t.removeEventListener("scroll",Q),window.removeEventListener("resize",Q),ye.current!==null&&(window.cancelAnimationFrame(ye.current),ye.current=null)}},[S,E,Q]);const Ge=o.useCallback(t=>{const s=ae[t.path];if(s)return s;if(C==="inline")return"inline";if(C==="side-by-side")return"side-by-side";const l=D<an;return t.isNew||l?"inline":"side-by-side"},[ae,C,D]),Xe=o.useMemo(()=>S.length===0?null:S.every(t=>Ge(t)==="side-by-side")?"side-by-side":"inline",[S,Ge]);o.useEffect(()=>{u&&(W(u),H(u,x))},[u,W,H,x]),o.useEffect(()=>{if(u)return Ot.onGitRefreshHint(t=>{ot(t.directory)===ot(u)&&(t.paths?.length&&(Oe.current=qe()??Pe.current,q(u,t.paths),Re(s=>{const l=new Map(s);for(const h of t.paths??[])l.set(h,(l.get(h)??0)+1);return l})),J(u,x,{silent:!0}))})},[qe,q,u,J,x]),o.useLayoutEffect(()=>{const t=Oe.current;if(!t)return;Oe.current=null;const s=xe.current,l=Ce.current.get(t.path);if(!s||!l)return;const h=s.getBoundingClientRect().top,v=l.getBoundingClientRect().top-h;s.scrollTop=on(s.scrollTop,t.topOffset,v,s.scrollHeight-s.clientHeight),Pe.current=t},[ce]),o.useEffect(()=>{b!=="all"&&!oe||re&&(oe&&he(oe),I(re),L(oe==="staged"||!oe&&Fe),m(null),we.current=!0,de.current=re,ve(re),Se(t=>t+1))},[b,ve,re,oe,Fe,m]),o.useEffect(()=>{if(b==="all")return;const t=g?.trim();t&&(I(t),L(b==="staged"),we.current=!0,de.current=t,ve(t),Se(s=>s+1))},[b,ve,g]),o.useEffect(()=>{if(!V)return;S.some(s=>s.path===V)||(I(null),L(!1))},[S,V]);const Nt=o.useCallback((t,s)=>{const l=Ce.current;s?l.set(t,s):l.delete(t),Q()},[Q]),Ft=o.useCallback((t,s)=>{be(),O(l=>{const h=l.has(t);if(s===h)return l;const v=new Set(l);return s?v.add(t):v.delete(t),v}),s||X(l=>{if(!l.has(t))return l;const h=new Set(l);return h.delete(t),h}),Q()},[be,Q]),Ct=o.useCallback(()=>{be(),O(t=>t.size>0?new Set:new Set(S.map(s=>s.path))),X(new Set),Q()},[be,S,Q]),kt=o.useCallback(async t=>{if(!R)return;const s=Je.getState().getDirectoryForSession(R)||u||"";if(!s){Ie.error(f("diffView.reviewDialog.toast.noSessionDirectory"));return}Ne(!0);try{await $t({originalSessionID:R,directory:s,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),fe(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ie.error(l instanceof Error?l.message:f("diffView.reviewDialog.toast.startFailed"))}finally{Ne(!1)}},[R,u,f]),Me=o.useCallback(t=>{const s=Ce.current.get(t),l=xe.current;if(!s||!l)return!1;const h=s.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+h,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!de.current)return;let s=0;const l=20;let h=!1;const v=(F=!0)=>{h||(h=!0,de.current=null,we.current=!1,F&&P(null),B.current!==null&&(window.cancelAnimationFrame(B.current),B.current=null))},G=()=>{if(h){B.current=null;return}const F=de.current;if(!F){v(),B.current=null;return}if(!Me(F)){s+=1,s<l?B.current=window.requestAnimationFrame(G):(v(),B.current=null);return}if(i&&we.current){P(F),v(!1);return}v()};return B.current=window.requestAnimationFrame(G),()=>{h=!0,B.current!==null&&(window.cancelAnimationFrame(B.current),B.current=null)}},[i,ie,Me]);const Dt=o.useCallback(t=>{},[]),Rt=o.useCallback(t=>{be(),I(t),L(!1),we.current=!0,de.current=t,ve(t),Se(s=>s+1),Me(t)},[be,ve,Me]),At=o.useCallback(t=>{const s=t==="side-by-side"?"side-by-side":"inline";S.forEach(l=>{Ae(l.path,s)})},[S,Ae]),[Vt,Ye]=o.useState(null),Lt=o.useCallback(async(t,s)=>{if(!u||!t)return;Ye(t);const l=lt();try{let h=null;if(s?.patch&&!s.isBinary&&!De(t)?h=tt(s.patch):s&&s.contextMode==="full"&&!s.isBinary&&!De(t)&&(h=at(s.original,s.modified)),h===null)try{const K=await x.getGitDiff(u,{path:t,staged:Te,contextLines:3});h=tt(K.diff)}catch{h=null}let v=s;if(h===null||!v){const K=await x.getGitFileDiff(u,{path:t,staged:Te});v={original:K.original??"",modified:K.modified??"",isBinary:K.isBinary},Te||U(u,t,v,l)}const G=h??(v.isBinary||De(t)?1:at(v.original,v.modified)),F=hn(u,t),A=await tn(w,F,{directory:u});if(!A.ok){Ie.error(nn(A.reason));return}Ee(u,F,G,1)}finally{Ye(h=>h===t?null:h)}},[Te,u,w,x,Ee,U]),Et=()=>{if(!u)return null;const t=s=>Be!==null?Be:ee&&s===V;return n.jsxs("div",{className:ne("flex min-w-0 flex-1 min-h-0 h-full",p?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[yt&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:f("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S.length})]}),n.jsx(vn,{changedFiles:S,selectedFile:null,onSelectFile:Rt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(dt,{ref:xe,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:S.map(s=>n.jsx(Fn,{directory:u,file:s,layout:Ge(s),wrapLines:_e,isSelected:!1,isExpanded:E.has(s.path),isMounted:te.has(s.path)||s.path===z,onSelect:Dt,onExpandedChange:Ft,registerSectionRef:Nt,showOpenInEditorAction:a&&b!=="turn",isOpeningInEditor:Vt===s.path,onOpenInEditor:(l,h)=>{Lt(l,h)},staged:t(s.path),loadFullFiles:se,initialDiffData:b==="turn"?bt.get(s.path)??null:null},`${s.path}:${ce.get(s.path)??0}`))})})})]})},Tt=()=>u?b!=="turn"&&M&&!j?n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}),f("diffView.state.loadingRepositoryStatus")]}):b!=="turn"&&k===!1?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.notGitRepository")}):S.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f(b==="turn"?"diffView.state.noLastTurnChanges":"diffView.state.cleanWorkingTree")}):Et():n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:f("diffView.state.selectSessionDirectory")});return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[!T&&(b==="working"||b==="staged"||b==="turn"?n.jsx(bn,{scope:b,workingCount:vt,stagedCount:jt,turnCount:St,onScopeChange:t=>{he(t),c?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:M&&!j?f("diffView.state.loadingChanges"):S.length===1?f("diffView.summary.changedFilesSingle",{count:S.length}):f("diffView.summary.changedFilesPlural",{count:S.length})})})),S.length>0&&n.jsxs(ue,{variant:"ghost",size:"sm",onClick:Ct,className:ne("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll"),children:[n.jsx(_,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?f("diffView.actions.collapseAll"):f("diffView.actions.expandAll")})]}),S.length>0&&xt&&n.jsxs(ue,{variant:"default",size:"sm",onClick:()=>fe(!0),disabled:Y,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":f("diffView.actions.reviewAria"),children:[Y?n.jsx(_,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(_,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:f("diffView.actions.review")})]}),S.length>0&&wt&&n.jsxs(ue,{variant:"outline",size:"sm",onClick:()=>{const t=u??"";y(t,{kind:"working-tree",scope:b==="staged"||b==="working"?b:"all"}),N(t,"walkthrough")},className:ne("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",sn),"aria-label":f("walkthrough.action.open"),children:[n.jsx(_,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:f("walkthrough.action.open")})]}),S.length>0&&n.jsxs(Gt,{children:[n.jsx(Kt,{asChild:!0,children:n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>je(t=>!t),"aria-pressed":se,"aria-label":f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:ne("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",se&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(_,{name:"file-download",className:"size-4"})})}),n.jsx(Wt,{children:n.jsx("p",{children:f(se?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),S.length>0&&n.jsx(ue,{variant:"ghost",size:"sm",onClick:()=>Le(!Ve),className:ne("h-5 w-5 p-0 transition-opacity",_e?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:f(_e?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(_,{name:"text-wrap",className:"size-4"})}),Xe&&n.jsx(ft,{mode:Xe==="side-by-side"?"side-by-side":"unified",onModeChange:At})]}),n.jsx(Ht,{open:ge,onOpenChange:fe,projectDirectory:u??null,submitting:Y,onConfirm:kt}),Tt()]})};export{zi as DiffView};
|