zidane-gui 7.1.3 → 7.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/main/index.js CHANGED
@@ -1,13 +1,13 @@
1
+ import { fixPath, IPC_BUILD_ID, defaultSocketPath, probeSocket, ensureDaemonRunning, connectIpcClient, IpcVersionMismatchError } from "zidane/ipc";
1
2
  import { resolve, delimiter, join, dirname, basename, isAbsolute } from "node:path";
2
3
  import { config } from "dotenv";
3
4
  import { app, shell, BrowserWindow, ipcMain, dialog, nativeImage } from "electron";
4
5
  import { randomUUID } from "node:crypto";
5
- import { parseEditorCommand, keybindingsPath, stripJsonComments, ensureKeybindingsFile, readProjects, writeProjects, credentialsPath, applyApiKeyEnv, BUILTIN_PROVIDERS, readCredentials, detectAuth, supportsOAuth, runOAuthLogin, setProviderCredential, scopeCwd, resolveConfig, DEFAULT_SETTINGS, enforceSettingsInvariants, mcpsWritePath, upsertMcpServer, discoverProjectMcps, removeMcpServer, loadMcpToolsCache, subscribeMcpToolsCache, refreshMcpToolsCatalog, createFileMcpCredentialStore, createChatHost, toTodosSnapshot, searchSessionHistory, searchableTurnText, deriveSessionTitle, toolCallPreview, modelChainMetadata, sessionModelFallbacks, resolveSessionCwd, modelSupportsReasoning, enabledModelOptions, buildModelCatalog, modelsForDescriptor, getContextWindow, truncateTurnsAt, deleteTurnSafely, generateSessionTitle, writeSessionExport, toolResultText, sumRunCosts, effectiveContextWindow, lastContextSizeFromTurns, fmtTokens, groupArtifacts, selectActiveTodos, setTodosForRun, sanitizeTodoItems, DEFAULT_MAX_TODO_ITEMS, fetchAllProviderUsage, fetchProviderUsage, listProjectFiles, discoverProjectSkills, discoverProjectPlugins, readProviderCredential, removeProviderCredential, setPreferredCredential, hasClaudeCodeSetup, countClaudeSessionFiles, importFromClaudeCode, isMainSession, findGitRoot, restoreModelOptions, modelOptionsFor, eventsFromTurns, watchInstalledVersion, checkForUpdate, upgradeInstalledPackages, performSelfUpdate, compareSemver, findInstalledCompanion } from "zidane/chat";
6
+ import { parseEditorCommand, keybindingsPath, stripJsonComments, ensureKeybindingsFile, readProjects, writeProjects, credentialsPath, applyApiKeyEnv, BUILTIN_PROVIDERS, readCredentials, detectAuth, supportsOAuth, runOAuthLogin, DEFAULT_OAUTH_ACCOUNT_LABEL, setProviderCredential, scopeCwd, resolveConfig, DEFAULT_SETTINGS, enforceSettingsInvariants, mcpsWritePath, upsertMcpServer, discoverProjectMcps, removeMcpServer, loadMcpToolsCache, subscribeMcpToolsCache, refreshMcpToolsCatalog, createFileMcpCredentialStore, createChatHost, toTodosSnapshot, searchSessionHistory, searchableTurnText, deriveSessionTitle, toolCallPreview, modelChainMetadata, sessionModelFallbacks, resolveSessionCwd, modelSupportsReasoning, enabledModelOptions, buildModelCatalog, modelsForDescriptor, getContextWindow, truncateTurnsAt, deleteTurnSafely, generateSessionTitle, writeSessionExport, toolResultText, sumRunCosts, effectiveContextWindow, lastContextSizeFromTurns, fmtTokens, groupArtifacts, selectActiveTodos, setTodosForRun, sanitizeTodoItems, DEFAULT_MAX_TODO_ITEMS, fetchAllProviderUsage, fetchProviderUsage, listProjectFiles, discoverProjectSkills, discoverProjectPlugins, readProviderCredential, removeProviderCredential, setPreferredCredential, removeStoredCredential, setCredentialLabel, hasClaudeCodeSetup, countClaudeSessionFiles, importFromClaudeCode, isMainSession, findGitRoot, restoreModelOptions, modelOptionsFor, eventsFromTurns, watchInstalledVersion, checkForUpdate, upgradeInstalledPackages, performSelfUpdate, compareSemver, findInstalledCompanion } from "zidane/chat";
6
7
  import { spawn, execFile } from "node:child_process";
7
8
  import { mkdirSync, readFileSync, writeFileSync, existsSync, accessSync, constants, statSync, readdirSync, copyFileSync, rmSync } from "node:fs";
8
9
  import { homedir, userInfo } from "node:os";
9
10
  import { migrateSessionArtifactDirs, createRingBufferSink, fanoutSink, consoleSink, createLogger, mergeArtifact, selectArtifactEvictions, createExtensionBus, createExtensionHostRuntimeBridge, toWireConfigSchema, resolveCompletionSubmit, inlineLoadedExtension, discoverAndBuildExtensionRegistry, disposeExtensionRegistry, installExtensionFromSpec, ExtensionInstallError, updateInstalledExtension, removeInstalledExtension, sanitizeExtensionConfigActionPatch, loginMcpServer, McpOAuthProvider, refreshArtifact, extensionScaffold, resolveInlineSuggestion, createPathAutocompleteProvider, editSessionMetadata, renderArtifactRow, loadSession } from "zidane";
10
- import { IPC_BUILD_ID, defaultSocketPath, probeSocket, ensureDaemonRunning, connectIpcClient, IpcVersionMismatchError } from "zidane/ipc";
11
11
  import { createRequire } from "node:module";
12
12
  import { DatabaseSync } from "node:sqlite";
13
13
  import { P as PARENT_USER_TURN, u as usageAssistantDaily$1, b as usageUserDaily$1, a as usageSessionDaily$1 } from "./chunks/usage-sql-BdDLRz11.js";
@@ -22,6 +22,7 @@ import __cjs_mod__ from "node:module";
22
22
  const __filename = import.meta.filename;
23
23
  const __dirname = import.meta.dirname;
24
24
  const require2 = __cjs_mod__.createRequire(import.meta.url);
25
+ fixPath();
25
26
  let resolvedDir = null;
26
27
  function userDataDir() {
27
28
  if (resolvedDir) {
@@ -185,7 +186,7 @@ function broadcastOAuth(signal) {
185
186
  function descriptorFor$1(provider) {
186
187
  return BUILTIN_PROVIDERS[provider] ?? null;
187
188
  }
188
- function startOAuth(provider) {
189
+ function startOAuth(provider, options = {}) {
189
190
  const descriptor = descriptorFor$1(provider);
190
191
  if (!descriptor) {
191
192
  throw new Error(`Unknown provider: ${provider}`);
@@ -212,7 +213,13 @@ function startOAuth(provider) {
212
213
  },
213
214
  signal: controller.signal
214
215
  }).then((creds) => {
215
- setProviderCredential(userDataDir(), descriptor, { kind: "oauth", ...creds });
216
+ const label = options.label?.trim() || DEFAULT_OAUTH_ACCOUNT_LABEL;
217
+ setProviderCredential(
218
+ userDataDir(),
219
+ descriptor,
220
+ { kind: "oauth", ...creds, label },
221
+ options.replaceKey ? { replaceKey: options.replaceKey } : {}
222
+ );
216
223
  applyAuthEnv();
217
224
  broadcastOAuth({ requestId, kind: "success" });
218
225
  }).catch((err) => {
@@ -4449,21 +4456,54 @@ function registerChatIpc() {
4449
4456
  });
4450
4457
  ipcMain.handle(
4451
4458
  "auth:setPreferredCredential",
4452
- async (_e, provider, source, cwd) => {
4459
+ async (_e, provider, target, cwd) => {
4453
4460
  const providers = await providersFor(cwd);
4454
4461
  const desc = descriptorFor(provider, providers);
4455
4462
  if (!desc) {
4456
4463
  throw new Error(`Unknown provider: ${provider}`);
4457
4464
  }
4458
- const outcome = setPreferredCredential(userDataDir(), desc, source);
4465
+ const outcome = setPreferredCredential(userDataDir(), desc, target);
4466
+ const what = typeof target === "string" ? `${target} credential` : `credential ${target.key}`;
4459
4467
  if (outcome === "not-stored") {
4460
- throw new Error(`no stored ${source} credential for ${desc.label} — sign in with it first`);
4468
+ throw new Error(`no stored ${what} for ${desc.label} — sign in with it first`);
4469
+ }
4470
+ applyAuthEnv();
4471
+ return detectAuth(userDataDir(), providers).map((r) => toAuthStatus(r, providers));
4472
+ }
4473
+ );
4474
+ ipcMain.handle(
4475
+ "auth:removeCredential",
4476
+ async (_e, provider, key, cwd) => {
4477
+ const providers = await providersFor(cwd);
4478
+ const desc = descriptorFor(provider, providers);
4479
+ if (!desc) {
4480
+ throw new Error(`Unknown provider: ${provider}`);
4481
+ }
4482
+ if (!removeStoredCredential(userDataDir(), desc, key)) {
4483
+ throw new Error(`no stored credential ${key} for ${desc.label}`);
4461
4484
  }
4462
4485
  applyAuthEnv();
4463
4486
  return detectAuth(userDataDir(), providers).map((r) => toAuthStatus(r, providers));
4464
4487
  }
4465
4488
  );
4466
- ipcMain.handle("auth:startOAuth", (_e, provider) => startOAuth(provider));
4489
+ ipcMain.handle(
4490
+ "auth:renameCredential",
4491
+ async (_e, provider, key, label, cwd) => {
4492
+ const providers = await providersFor(cwd);
4493
+ const desc = descriptorFor(provider, providers);
4494
+ if (!desc) {
4495
+ throw new Error(`Unknown provider: ${provider}`);
4496
+ }
4497
+ if (!setCredentialLabel(userDataDir(), desc, key, label)) {
4498
+ throw new Error(`no stored OAuth account ${key} for ${desc.label}`);
4499
+ }
4500
+ return detectAuth(userDataDir(), providers).map((r) => toAuthStatus(r, providers));
4501
+ }
4502
+ );
4503
+ ipcMain.handle(
4504
+ "auth:startOAuth",
4505
+ (_e, provider, options) => startOAuth(provider, options)
4506
+ );
4467
4507
  ipcMain.handle("auth:cancelOAuth", (_e, requestId) => cancelOAuth(requestId));
4468
4508
  ipcMain.handle("settings:get", () => {
4469
4509
  return readSettings();
@@ -204,8 +204,10 @@ const api = {
204
204
  setApiKey: (provider, key, cwd) => ipcRenderer.invoke("auth:setApiKey", provider, key, cwd),
205
205
  configureProvider: (provider, input, cwd) => ipcRenderer.invoke("auth:configureProvider", provider, input, cwd),
206
206
  clear: (provider, cwd) => ipcRenderer.invoke("auth:clear", provider, cwd),
207
- setPreferredCredential: (provider, source, cwd) => ipcRenderer.invoke("auth:setPreferredCredential", provider, source, cwd),
208
- startOAuth: (provider) => ipcRenderer.invoke("auth:startOAuth", provider),
207
+ setPreferredCredential: (provider, target, cwd) => ipcRenderer.invoke("auth:setPreferredCredential", provider, target, cwd),
208
+ removeCredential: (provider, key, cwd) => ipcRenderer.invoke("auth:removeCredential", provider, key, cwd),
209
+ renameCredential: (provider, key, label, cwd) => ipcRenderer.invoke("auth:renameCredential", provider, key, label, cwd),
210
+ startOAuth: (provider, options) => ipcRenderer.invoke("auth:startOAuth", provider, options),
209
211
  cancelOAuth: (requestId) => ipcRenderer.invoke("auth:cancelOAuth", requestId),
210
212
  onOAuthProgress: (cb) => subscribe("auth:oauth", cb)
211
213
  },
@@ -12507,6 +12507,7 @@ function utf8ByteLength(text2) {
12507
12507
  }
12508
12508
  return bytes;
12509
12509
  }
12510
+ const DEFAULT_OAUTH_ACCOUNT_LABEL = "Default";
12510
12511
  function fmtTokens(n) {
12511
12512
  if (n < 1e3) return String(n);
12512
12513
  if (n < 1e6) return `${(n / 1e3).toFixed(n < 1e4 ? 2 : 1)}k`;
@@ -14644,6 +14645,13 @@ function splitPromptSegments(text2, refs) {
14644
14645
  }
14645
14646
  return out;
14646
14647
  }
14648
+ function showsAccount(snapshot, all2) {
14649
+ return snapshot.account !== null && all2.some((s2) => s2 !== snapshot && s2.providerKey === snapshot.providerKey);
14650
+ }
14651
+ function activeSnapshotFor(all2, providerKey) {
14652
+ const mine = all2.filter((s2) => s2.providerKey === providerKey);
14653
+ return mine.find((s2) => s2.activeCredential) ?? mine[0] ?? null;
14654
+ }
14647
14655
  function mostConstrainedWindow(snapshot) {
14648
14656
  let worst = null;
14649
14657
  for (const win of snapshot.windows) if (!worst || win.usedPercent > worst.usedPercent) worst = win;
@@ -14670,6 +14678,14 @@ function resetLabel(resetsAt, now = Date.now()) {
14670
14678
  }
14671
14679
  return `resets in ${Math.max(1, Math.floor(hours / 24))}d`;
14672
14680
  }
14681
+ function updatedLabel(snapshots, now = Date.now()) {
14682
+ let newest = -Infinity;
14683
+ for (const s2 of snapshots) newest = Math.max(newest, s2.fetchedAt);
14684
+ if (!Number.isFinite(newest)) return null;
14685
+ const seconds = Math.max(0, Math.floor((now - newest) / 1e3));
14686
+ if (seconds < 60) return `updated ${seconds}s ago`;
14687
+ return `updated ${Math.floor(seconds / 60)}m ago`;
14688
+ }
14673
14689
  function formatCredits(value) {
14674
14690
  return value >= 100 ? value.toFixed(0) : value.toFixed(2);
14675
14691
  }
@@ -86446,16 +86462,25 @@ function ProviderUsageProvider({ children }) {
86446
86462
  const [loading, setLoading] = reactExports.useState(false);
86447
86463
  const [loaded, setLoaded] = reactExports.useState(false);
86448
86464
  const inFlight = reactExports.useRef(false);
86465
+ const pendingRefresh = reactExports.useRef(false);
86449
86466
  const load = reactExports.useCallback(async (refresh2) => {
86450
86467
  if (inFlight.current) {
86468
+ if (refresh2) {
86469
+ pendingRefresh.current = true;
86470
+ }
86451
86471
  return;
86452
86472
  }
86453
86473
  inFlight.current = true;
86454
86474
  setLoading(true);
86455
86475
  try {
86456
- const next = await window.api.providerUsage.fetchAll(void 0, refresh2 ? { refresh: true } : void 0);
86457
- setSnapshots(next);
86458
- setLoaded(true);
86476
+ let force = refresh2;
86477
+ do {
86478
+ pendingRefresh.current = false;
86479
+ const next = await window.api.providerUsage.fetchAll(void 0, force ? { refresh: true } : void 0);
86480
+ setSnapshots(next);
86481
+ setLoaded(true);
86482
+ force = true;
86483
+ } while (pendingRefresh.current);
86459
86484
  } finally {
86460
86485
  inFlight.current = false;
86461
86486
  setLoading(false);
@@ -86790,7 +86815,7 @@ function UsageIndicator() {
86790
86815
  const { settings } = useSettings();
86791
86816
  const active = sessions.find((s2) => s2.id === activeSessionId) ?? null;
86792
86817
  const { snapshots } = useProviderUsage();
86793
- const snapshot = active ? snapshots.find((s2) => s2.providerKey === active.providerKey) ?? null : null;
86818
+ const snapshot = active?.providerKey ? activeSnapshotFor(snapshots, active.providerKey) : null;
86794
86819
  const worst = snapshot && snapshot.status === "ok" ? mostConstrainedWindow(snapshot) : null;
86795
86820
  if (!worst) {
86796
86821
  return null;
@@ -86801,7 +86826,7 @@ function UsageIndicator() {
86801
86826
  "span",
86802
86827
  {
86803
86828
  className: `inline-flex items-center gap-1 h-5 px-1.5 rounded bg-[var(--zg-bg-hover)] font-mono tabular-nums shrink-0 ${toneCls}`,
86804
- title: `${snapshot?.label ?? ""} · ${worst.label} window ${formatUsagePercent(worst.usedPercent)}% used${worst.resetsAt ? ` · ${resetLabel(worst.resetsAt) ?? ""}` : ""}
86829
+ title: `${snapshot?.label ?? ""}${snapshot?.account ? ` (${snapshot.account})` : ""} · ${worst.label} window ${formatUsagePercent(worst.usedPercent)}% used${worst.resetsAt ? ` · ${resetLabel(worst.resetsAt) ?? ""}` : ""}
86805
86830
  Ctrl+P opens the usage panel.`,
86806
86831
  children: [
86807
86832
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "aria-hidden": true, children: "▰" }),
@@ -89249,7 +89274,7 @@ const PROVIDERS = [
89249
89274
  {
89250
89275
  key: "anthropic",
89251
89276
  label: "Anthropic",
89252
- description: "Claude — Opus / Sonnet / Haiku. API key or OAuth.",
89277
+ description: "Claude Opus, Sonnet and Haiku. API key or OAuth.",
89253
89278
  placeholder: "sk-ant-…",
89254
89279
  supportsOAuth: true
89255
89280
  },
@@ -89257,13 +89282,13 @@ const PROVIDERS = [
89257
89282
  key: "openai",
89258
89283
  label: "OpenAI Codex",
89259
89284
  description: "GPT-5 family via Codex. OAuth-only (Sign in with ChatGPT).",
89260
- placeholder: "(OAuth only — use Sign in)",
89285
+ placeholder: "(OAuth only, use Sign in)",
89261
89286
  supportsOAuth: true
89262
89287
  },
89263
89288
  {
89264
89289
  key: "openrouter",
89265
89290
  label: "OpenRouter",
89266
- description: "Cross-model proxy — any model, one API key.",
89291
+ description: "Cross-model proxy: any model, one API key.",
89267
89292
  placeholder: "sk-or-…",
89268
89293
  supportsOAuth: false
89269
89294
  },
@@ -89328,12 +89353,12 @@ function AuthPanel({ cwd: cwd2 }) {
89328
89353
  });
89329
89354
  return () => unsubscribe();
89330
89355
  }, [refresh]);
89331
- const handleStartOAuth = reactExports.useCallback(async (provider) => {
89356
+ const handleStartOAuth = reactExports.useCallback(async (provider, options) => {
89332
89357
  try {
89333
- const { requestId } = await window.api.auth.startOAuth(provider);
89358
+ const { requestId } = await window.api.auth.startOAuth(provider, options);
89334
89359
  setFlows((prev) => [
89335
89360
  ...prev.filter((f2) => f2.provider !== provider),
89336
- { requestId, provider, phase: { kind: "progress", message: "Starting…" } }
89361
+ { requestId, provider, phase: { kind: "progress", message: "Starting…" }, options }
89337
89362
  ]);
89338
89363
  } catch (err) {
89339
89364
  setFlows((prev) => [
@@ -89341,7 +89366,8 @@ function AuthPanel({ cwd: cwd2 }) {
89341
89366
  {
89342
89367
  requestId: `${provider}-error-${Date.now()}`,
89343
89368
  provider,
89344
- phase: { kind: "error", error: err.message }
89369
+ phase: { kind: "error", error: err.message },
89370
+ options
89345
89371
  }
89346
89372
  ]);
89347
89373
  }
@@ -89375,9 +89401,9 @@ function AuthPanel({ cwd: cwd2 }) {
89375
89401
  flow: flow2,
89376
89402
  cwd: cwd2,
89377
89403
  onChanged: () => void refresh(),
89378
- onStartOAuth: () => void handleStartOAuth(meta.key),
89404
+ onStartOAuth: (options) => void handleStartOAuth(meta.key, options),
89379
89405
  onCancelFlow: (requestId) => void handleCancelFlow(requestId),
89380
- onRetryFlow: () => void handleStartOAuth(meta.key)
89406
+ onRetryFlow: () => void handleStartOAuth(meta.key, flow2?.options)
89381
89407
  },
89382
89408
  meta.key
89383
89409
  );
@@ -89409,6 +89435,16 @@ function ProviderRow$1({
89409
89435
  const [fieldValues, setFieldValues] = reactExports.useState({});
89410
89436
  const [busy, setBusy] = reactExports.useState(null);
89411
89437
  const [rowError, setRowError] = reactExports.useState(null);
89438
+ const [namingAccount, setNamingAccount] = reactExports.useState(false);
89439
+ const [accountName, setAccountName] = reactExports.useState("");
89440
+ const trimmedAccountName = accountName.trim();
89441
+ const startNamedAccount = () => {
89442
+ if (!trimmedAccountName) {
89443
+ return;
89444
+ }
89445
+ setNamingAccount(false);
89446
+ onStartOAuth({ label: trimmedAccountName });
89447
+ };
89412
89448
  const customFields = status?.customFields ?? [];
89413
89449
  const hasCustomFields = customFields.length > 0;
89414
89450
  const apiKeySupported = !hasCustomFields && meta.key !== "openai";
@@ -89484,13 +89520,21 @@ function ProviderRow$1({
89484
89520
  ] }),
89485
89521
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-[var(--zg-text-muted)] mt-0.5", children: meta.description })
89486
89522
  ] }),
89487
- !editing && meta.supportsOAuth && !flow2 && /* @__PURE__ */ jsxRuntimeExports.jsx(
89523
+ !editing && !namingAccount && meta.supportsOAuth && !flow2 && /* @__PURE__ */ jsxRuntimeExports.jsx(
89488
89524
  "button",
89489
89525
  {
89490
89526
  type: "button",
89491
- onClick: onStartOAuth,
89527
+ onClick: () => {
89528
+ if (hasOAuth) {
89529
+ setRowError(null);
89530
+ setAccountName("");
89531
+ setNamingAccount(true);
89532
+ } else {
89533
+ onStartOAuth();
89534
+ }
89535
+ },
89492
89536
  className: `${BTN_PRIMARY} focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)]`,
89493
- children: hasOAuth ? "Re-authorize" : `Sign in with ${meta.label}`
89537
+ children: hasOAuth ? "Add account" : `Sign in with ${meta.label}`
89494
89538
  }
89495
89539
  ),
89496
89540
  !editing && (apiKeySupported || hasCustomFields) && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -89522,6 +89566,46 @@ function ProviderRow$1({
89522
89566
  onRetry: onRetryFlow
89523
89567
  }
89524
89568
  ),
89569
+ namingAccount && !flow2 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 flex items-center gap-2", children: [
89570
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
89571
+ "input",
89572
+ {
89573
+ autoFocus: true,
89574
+ type: "text",
89575
+ placeholder: "Account name, for example work or personal",
89576
+ value: accountName,
89577
+ onChange: (e) => setAccountName(e.target.value),
89578
+ onKeyDown: (e) => {
89579
+ if (e.key === "Enter") {
89580
+ startNamedAccount();
89581
+ }
89582
+ if (e.key === "Escape") {
89583
+ setNamingAccount(false);
89584
+ }
89585
+ },
89586
+ className: "flex-1 text-sm bg-[var(--zg-bg)] border border-[var(--zg-border)] rounded-md px-3 py-2 text-[var(--zg-text)] outline-none focus:border-[var(--zg-accent)] focus:ring-2 focus:ring-[var(--zg-accent)]/20"
89587
+ }
89588
+ ),
89589
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
89590
+ "button",
89591
+ {
89592
+ type: "button",
89593
+ disabled: !trimmedAccountName,
89594
+ onClick: startNamedAccount,
89595
+ className: `${BTN_PRIMARY} focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)]`,
89596
+ children: "Sign in"
89597
+ }
89598
+ ),
89599
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
89600
+ "button",
89601
+ {
89602
+ type: "button",
89603
+ onClick: () => setNamingAccount(false),
89604
+ className: `${BTN_SECONDARY} focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--zg-accent)]`,
89605
+ children: "Cancel"
89606
+ }
89607
+ )
89608
+ ] }),
89525
89609
  editing && (hasCustomFields ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 space-y-3", children: [
89526
89610
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-2", children: customFields.map((field, index2) => {
89527
89611
  const valueForField = fieldValues[field.key] ?? "";
@@ -89614,7 +89698,16 @@ function ProviderRow$1({
89614
89698
  }
89615
89699
  )
89616
89700
  ] })),
89617
- status && isExpandableProvider(status) && /* @__PURE__ */ jsxRuntimeExports.jsx(CredentialSources, { status, cwd: cwd2 ?? null, onChanged, onError: setRowError }),
89701
+ status && isExpandableProvider(status) && /* @__PURE__ */ jsxRuntimeExports.jsx(
89702
+ CredentialSources,
89703
+ {
89704
+ status,
89705
+ cwd: cwd2 ?? null,
89706
+ onChanged,
89707
+ onError: setRowError,
89708
+ onReauth: meta.supportsOAuth && !flow2 ? (options) => onStartOAuth(options) : void 0
89709
+ }
89710
+ ),
89618
89711
  rowError && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-xs text-[#ef4444]", children: rowError })
89619
89712
  ] });
89620
89713
  }
@@ -89694,14 +89787,60 @@ function CredentialSources({
89694
89787
  status,
89695
89788
  cwd: cwd2,
89696
89789
  onChanged,
89697
- onError
89790
+ onError,
89791
+ onReauth
89698
89792
  }) {
89699
89793
  const [busy, setBusy] = reactExports.useState(null);
89700
- const use = async (source) => {
89794
+ const [renaming, setRenaming] = reactExports.useState(null);
89795
+ const identity = (method) => method.key ?? method.source;
89796
+ const use = async (method) => {
89797
+ try {
89798
+ onError(null);
89799
+ setBusy(`use:${identity(method)}`);
89800
+ await window.api.auth.setPreferredCredential(
89801
+ status.key,
89802
+ method.key ? { key: method.key } : method.source,
89803
+ cwd2 ?? void 0
89804
+ );
89805
+ onChanged();
89806
+ } catch (err) {
89807
+ onError(err.message);
89808
+ } finally {
89809
+ setBusy(null);
89810
+ }
89811
+ };
89812
+ const remove = async (method) => {
89813
+ if (!method.key) {
89814
+ return;
89815
+ }
89816
+ const name2 = method.label ?? method.source;
89817
+ if (!confirm(`Remove ${status.label} ${name2}${method.active ? " (in use)" : ""}?`)) {
89818
+ return;
89819
+ }
89820
+ try {
89821
+ onError(null);
89822
+ setBusy(`remove:${method.key}`);
89823
+ await window.api.auth.removeCredential(status.key, method.key, cwd2 ?? void 0);
89824
+ onChanged();
89825
+ } catch (err) {
89826
+ onError(err.message);
89827
+ } finally {
89828
+ setBusy(null);
89829
+ }
89830
+ };
89831
+ const commitRename = async (method) => {
89832
+ if (!renaming || !method.key) {
89833
+ return;
89834
+ }
89835
+ const next = renaming.draft.trim();
89836
+ setRenaming(null);
89837
+ if (next === (method.label ?? "")) {
89838
+ return;
89839
+ }
89701
89840
  try {
89702
89841
  onError(null);
89703
- setBusy(source);
89704
- await window.api.auth.setPreferredCredential(status.key, source, cwd2 ?? void 0);
89842
+ setBusy(`rename:${method.key}`);
89843
+ await window.api.auth.renameCredential(status.key, method.key, next, cwd2 ?? void 0);
89705
89844
  onChanged();
89706
89845
  } catch (err) {
89707
89846
  onError(err.message);
@@ -89709,9 +89848,15 @@ function CredentialSources({
89709
89848
  setBusy(null);
89710
89849
  }
89711
89850
  };
89851
+ const ROW_BTN = "zg-press ml-1 h-5 px-1.5 shrink-0 rounded text-[11px] leading-none text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border border-[var(--zg-border)] bg-transparent cursor-pointer disabled:opacity-40";
89712
89852
  return /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "mt-2 ml-6 flex flex-col gap-1 list-none m-0 p-0", "aria-label": `${status.label} credential sources`, children: status.methods.map((method) => {
89713
89853
  const isEnv = method.source === "env";
89714
89854
  const selectable = !isEnv && !method.active;
89855
+ const id = identity(method);
89856
+ const title = method.label ?? method.source;
89857
+ const detail = method.label && method.detail.startsWith(`${method.label} · `) ? `${method.source} · ${method.detail.slice(method.label.length + 3)}` : method.detail;
89858
+ const isRenaming = renaming !== null && renaming.key === method.key;
89859
+ const renamable = method.source === "oauth" && !!method.key;
89715
89860
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex items-center gap-2 text-xs", children: [
89716
89861
  /* @__PURE__ */ jsxRuntimeExports.jsx(
89717
89862
  "span",
@@ -89721,21 +89866,84 @@ function CredentialSources({
89721
89866
  children: isEnv || method.active ? "●" : "○"
89722
89867
  }
89723
89868
  ),
89724
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-mono ${method.active ? "text-[var(--zg-accent)]" : "text-[var(--zg-text)]"}`, children: method.source }),
89725
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] truncate min-w-0 shrink", title: method.detail, children: method.detail }),
89869
+ isRenaming ? /* @__PURE__ */ jsxRuntimeExports.jsx(
89870
+ "input",
89871
+ {
89872
+ autoFocus: true,
89873
+ type: "text",
89874
+ "aria-label": `New name for ${title}`,
89875
+ placeholder: DEFAULT_OAUTH_ACCOUNT_LABEL,
89876
+ value: renaming.draft,
89877
+ onChange: (e) => setRenaming({ key: renaming.key, draft: e.target.value }),
89878
+ onKeyDown: (e) => {
89879
+ if (e.key === "Enter") {
89880
+ void commitRename(method);
89881
+ }
89882
+ if (e.key === "Escape") {
89883
+ setRenaming(null);
89884
+ }
89885
+ },
89886
+ className: "font-mono text-xs h-5 px-1.5 min-w-0 flex-1 bg-[var(--zg-bg)] border border-[var(--zg-accent)] rounded text-[var(--zg-text)] outline-none"
89887
+ }
89888
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
89889
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-mono ${method.active ? "text-[var(--zg-accent)]" : "text-[var(--zg-text)]"}`, children: title }),
89890
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] truncate min-w-0 shrink", title: detail, children: detail })
89891
+ ] }),
89726
89892
  method.active && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[var(--zg-text-muted)] shrink-0", children: "(in use)" }),
89727
- selectable && /* @__PURE__ */ jsxRuntimeExports.jsx(
89893
+ isRenaming && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
89894
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => void commitRename(method), className: ROW_BTN, title: "Save name", children: "Save" }),
89895
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => setRenaming(null), className: ROW_BTN, title: "Cancel rename", children: "Cancel" })
89896
+ ] }),
89897
+ selectable && !isRenaming && /* @__PURE__ */ jsxRuntimeExports.jsx(
89898
+ "button",
89899
+ {
89900
+ type: "button",
89901
+ disabled: busy !== null,
89902
+ onClick: () => void use(method),
89903
+ className: ROW_BTN,
89904
+ title: `Make this ${method.source} credential the one zidane uses for ${status.label}`,
89905
+ children: busy === `use:${id}` ? "Switching…" : "Use"
89906
+ }
89907
+ ),
89908
+ renamable && !isRenaming && /* @__PURE__ */ jsxRuntimeExports.jsx(
89909
+ "button",
89910
+ {
89911
+ type: "button",
89912
+ disabled: busy !== null,
89913
+ onClick: () => {
89914
+ if (method.key) {
89915
+ onError(null);
89916
+ setRenaming({ key: method.key, draft: method.label ?? "" });
89917
+ }
89918
+ },
89919
+ className: ROW_BTN,
89920
+ title: `Rename ${title}`,
89921
+ children: busy === `rename:${id}` ? "Renaming…" : "Rename"
89922
+ }
89923
+ ),
89924
+ renamable && !isRenaming && onReauth && /* @__PURE__ */ jsxRuntimeExports.jsx(
89925
+ "button",
89926
+ {
89927
+ type: "button",
89928
+ disabled: busy !== null,
89929
+ onClick: () => onReauth({ replaceKey: method.key, ...method.label ? { label: method.label } : {} }),
89930
+ className: ROW_BTN,
89931
+ title: `Sign in again for ${title}`,
89932
+ children: "Re-auth"
89933
+ }
89934
+ ),
89935
+ method.key && !isRenaming && /* @__PURE__ */ jsxRuntimeExports.jsx(
89728
89936
  "button",
89729
89937
  {
89730
89938
  type: "button",
89731
89939
  disabled: busy !== null,
89732
- onClick: () => void use(method.source),
89733
- className: "zg-press ml-1 h-5 px-1.5 shrink-0 rounded text-[11px] leading-none text-[var(--zg-text-muted)] hover:text-[var(--zg-text)] hover:bg-[var(--zg-bg-hover)] border border-[var(--zg-border)] bg-transparent cursor-pointer disabled:opacity-40",
89734
- title: `Make the ${method.source} credential the one zidane uses for ${status.label}`,
89735
- children: busy === method.source ? "Switching…" : "Use"
89940
+ onClick: () => void remove(method),
89941
+ className: `${ROW_BTN} hover:text-[#ef4444]`,
89942
+ title: `Remove ${title} from ${status.label}`,
89943
+ children: busy === `remove:${id}` ? "Removing…" : "Remove"
89736
89944
  }
89737
89945
  )
89738
- ] }, method.source);
89946
+ ] }, id);
89739
89947
  }) });
89740
89948
  }
89741
89949
  function McpsPanel({ cwd: cwd2 }) {
@@ -92609,6 +92817,7 @@ function UsagePanelModal({ activeProviderKey }) {
92609
92817
  const autoLoad = settings.subscriptionUsage !== false;
92610
92818
  const { snapshots, loading, loaded, refresh } = useProviderUsage();
92611
92819
  const empty2 = snapshots.length === 0;
92820
+ const updated = updatedLabel(snapshots);
92612
92821
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
92613
92822
  ModalShell,
92614
92823
  {
@@ -92616,19 +92825,27 @@ function UsagePanelModal({ activeProviderKey }) {
92616
92825
  description: empty2 ? autoLoad || loaded ? loading ? "Checking signed-in providers…" : "No signed-in provider reports usage." : "Usage checks are off — refresh fetches once." : "Rate-limit windows and credits for signed-in providers. Read-only.",
92617
92826
  onClose: close2,
92618
92827
  size: "medium",
92619
- footer: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-end gap-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN, disabled: loading, onClick: refresh, children: loading ? "Refreshing…" : "Refresh" }) }),
92828
+ footer: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-2 w-full", children: [
92829
+ updated && !loading && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-[var(--zg-text-muted)]", children: updated }),
92830
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: GHOST_BTN, disabled: loading, onClick: refresh, children: loading ? "Refreshing…" : "Refresh" })
92831
+ ] }),
92620
92832
  children: empty2 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "flex flex-col gap-3 p-4 m-0 list-none overflow-y-auto", children: snapshots.map((snapshot) => /* @__PURE__ */ jsxRuntimeExports.jsx(
92621
92833
  ProviderRow,
92622
92834
  {
92623
92835
  snapshot,
92624
- active: snapshot.providerKey === activeProviderKey
92836
+ account: showsAccount(snapshot, snapshots) ? snapshot.account : null,
92837
+ active: snapshot.providerKey === activeProviderKey && snapshot.activeCredential
92625
92838
  },
92626
- snapshot.providerKey
92839
+ snapshot.credentialKey
92627
92840
  )) })
92628
92841
  }
92629
92842
  );
92630
92843
  }
92631
- function ProviderRow({ snapshot, active }) {
92844
+ function ProviderRow({
92845
+ snapshot,
92846
+ account,
92847
+ active
92848
+ }) {
92632
92849
  const creditsWindow = snapshot.windows.some((win) => win.id === "credits");
92633
92850
  const looseCredits = creditsWindow ? null : snapshot.credits;
92634
92851
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "flex flex-col gap-2 px-3 py-2.5 rounded-md bg-[var(--zg-bg)] border border-[var(--zg-border)]", children: [
@@ -92641,6 +92858,10 @@ function ProviderRow({ snapshot, active }) {
92641
92858
  children: snapshot.label
92642
92859
  }
92643
92860
  ),
92861
+ account && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-[var(--zg-text-muted)] truncate", children: [
92862
+ "· ",
92863
+ account
92864
+ ] }),
92644
92865
  snapshot.plan && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-[var(--zg-text-muted)] truncate", children: [
92645
92866
  "· ",
92646
92867
  snapshot.plan
@@ -61,7 +61,7 @@
61
61
  pointer-events: none;
62
62
  }
63
63
  </style>
64
- <script type="module" crossorigin src="./assets/index-Cu2TKaTl.js"></script>
64
+ <script type="module" crossorigin src="./assets/index-DnkpUra3.js"></script>
65
65
  <link rel="stylesheet" crossorigin href="./assets/index-BZjkKf9P.css">
66
66
  </head>
67
67
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zidane-gui",
3
3
  "productName": "Zidane",
4
- "version": "7.1.3",
4
+ "version": "7.1.5",
5
5
  "description": "Zidane Desktop",
6
6
  "author": "StackBlitz",
7
7
  "type": "module",
@@ -52,14 +52,14 @@
52
52
  "@tiptap/starter-kit": "^3.23.6",
53
53
  "@tiptap/suggestion": "^3.23.6",
54
54
  "dotenv": "^17.4.2",
55
+ "electron": "^41.7.0",
55
56
  "react": "^19.2.6",
56
57
  "react-dom": "^19.2.6",
57
58
  "react-markdown": "^10.1.0",
58
59
  "remark-gfm": "^4.0.1",
59
60
  "shiki": "^4.1.0",
60
- "electron": "^41.7.0",
61
61
  "tippy.js": "^6.3.7",
62
- "zidane": "7.1.3",
62
+ "zidane": "7.1.5",
63
63
  "zod": "^4.4.3"
64
64
  },
65
65
  "devDependencies": {