claude-code-session-manager 0.112.0 → 0.113.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/.claude-plugin/marketplace.json +1 -1
- package/dist/assets/{AgentLibrary-RwPvEgqm.js → AgentLibrary-wvrcLGGS.js} +2 -2
- package/dist/assets/{Button-36j3PzYv.js → Button-B6h0F0XT.js} +1 -1
- package/dist/assets/{DataModel-DUhANo4l.js → DataModel-C5pW9E3u.js} +1 -1
- package/dist/assets/{History-BeZzNjmv.js → History-BV4e8YOM.js} +2 -2
- package/dist/assets/{Hooks-iQ8845Hp.js → Hooks-CrFSv4x1.js} +3 -3
- package/dist/assets/{Library-DPE1h-1L.js → Library-D-GIt3EY.js} +7 -7
- package/dist/assets/{ListDetail-PStOuQAo.js → ListDetail-Bco_wfs6.js} +1 -1
- package/dist/assets/{MarkdownEditor-DPw-N2-m.js → MarkdownEditor-C-yHSXNV.js} +1 -1
- package/dist/assets/{McpServers-CUyRTNep.js → McpServers-CfDekadG.js} +2 -2
- package/dist/assets/{Memory-bZ2xjBGy.js → Memory-CGGLexkR.js} +6 -6
- package/dist/assets/{Panel-_VZ_uXNg.js → Panel-DGMEuYYG.js} +1 -1
- package/dist/assets/{Permissions-PPRmfNbK.js → Permissions-Cx2zjtYZ.js} +3 -3
- package/dist/assets/{Plugins-BFcvfvlx.js → Plugins-Bc_W3IyR.js} +2 -2
- package/dist/assets/ProvenanceBadge-DiKAUR1u.js +1 -0
- package/dist/assets/{RemoteMachines-D5V0lzgW.js → RemoteMachines-8_77-WPD.js} +2 -2
- package/dist/assets/{SaveBar-Dw64FVdM.js → SaveBar-Blpzdq1R.js} +1 -1
- package/dist/assets/{Scheduler-C8s_pJ3I.js → Scheduler-Bd70AM4X.js} +8 -8
- package/dist/assets/{ScopeSwitcher-D-nKDMAE.js → ScopeSwitcher-wxN0h4YW.js} +1 -1
- package/dist/assets/Settings-CQ7DA3zW.js +4 -0
- package/dist/assets/{SkillReferenceGraph-BbZFMHim.js → SkillReferenceGraph-DH1NLOiS.js} +1 -1
- package/dist/assets/Skills-CmyRyu4_.js +2 -0
- package/dist/assets/SystemPrompt-KAc3UMCd.js +1 -0
- package/dist/assets/TagLibrary-C8EvHnpg.js +1 -0
- package/dist/assets/{TiptapBody-Cr-hxX8L.js → TiptapBody-d423mH6D.js} +1 -1
- package/dist/assets/{Toggle-7WpPzcZH.js → Toggle-D1wsGE9S.js} +1 -1
- package/dist/assets/{ViewTabs-9lQCRwWJ.js → ViewTabs-CjHw3kGY.js} +1 -1
- package/dist/assets/{historyTotals-BrFxw5J1.js → historyTotals-DFHzqLt7.js} +1 -1
- package/dist/assets/{index-CTBpf-26.js → index-Ci1u018F.js} +143 -143
- package/dist/assets/{settingsSchema-Dh5Kl7VO.js → settingsSchema-Ctf3pZVI.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-CMpx0d04.js → useAgentsDirWatch-B1NBmOAe.js} +1 -1
- package/dist/assets/{useRemotePeers-CI2axd-L.js → useRemotePeers-BHjSJs9D.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -0
- package/scripts/scheduler-mcp-server.cjs +23 -5
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +18 -1
- package/src/main/config.cjs +18 -1
- package/src/main/index.cjs +6 -0
- package/src/main/ipcSchemas.cjs +3 -0
- package/src/main/lib/activeSessions.cjs +13 -0
- package/src/main/lib/claude/rateLimitDetect.cjs +29 -10
- package/src/main/lib/claude/rateLimitWindow.cjs +23 -11
- package/src/main/lib/credentials.cjs +16 -90
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +107 -9
- package/src/main/lib/feedback-remote/humanPromptLedger.cjs +93 -0
- package/src/main/lib/mcpToolCatalog.cjs +9 -3
- package/src/main/lib/prd/depSlugResolve.cjs +16 -1
- package/src/main/lib/scheduler/finalizeReason.cjs +30 -0
- package/src/main/lib/scheduler/flatSweepThrottle.cjs +17 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +34 -13
- package/src/main/lib/scheduler/schedulerBatch.cjs +8 -12
- package/src/main/lib/telemetry/telemetryClient.cjs +8 -4
- package/src/main/lib/util/atomicFs.cjs +42 -0
- package/src/main/lib/util/loopDelay.cjs +1 -1
- package/src/main/runVerify.cjs +5 -2
- package/src/main/scheduler.cjs +43 -10
- package/src/main/supervisor.cjs +45 -22
- package/src/main/webRemote.cjs +15 -0
- package/src/preload/api.d.ts +6 -0
- package/src/preload/index.cjs +6 -0
- package/dist/assets/ProvenanceBadge-B1WUknak.js +0 -1
- package/dist/assets/Settings-CQSrR4mO.js +0 -4
- package/dist/assets/Skills-Bzyrh6EQ.js +0 -2
- package/dist/assets/SystemPrompt-DP6i3Dx0.js +0 -1
- package/dist/assets/TagLibrary-iip0C6Bl.js +0 -1
package/src/main/runVerify.cjs
CHANGED
|
@@ -41,6 +41,7 @@ const fs = require('node:fs');
|
|
|
41
41
|
const path = require('node:path');
|
|
42
42
|
const { execFileSync } = require('node:child_process');
|
|
43
43
|
const { parsePrdFile } = require('./lib/prd/prdFrontmatter.cjs');
|
|
44
|
+
const { isSatisfiedDepRow } = require('./lib/prd/depSlugResolve.cjs');
|
|
44
45
|
|
|
45
46
|
const VERDICTS_SCHEMA_VERSION = 1;
|
|
46
47
|
|
|
@@ -468,7 +469,9 @@ function checkDeps(queueEntry, allJobs, prdBody) {
|
|
|
468
469
|
// bare dep name that never matched any row, and ended up on disk with no
|
|
469
470
|
// queue row at all.
|
|
470
471
|
if (deps.length === 0) continue;
|
|
471
|
-
|
|
472
|
+
// Same predicate as findBlockingDep — an auto-resolve skip the picker
|
|
473
|
+
// dispatched past must not be re-judged unmet here (same infinite re-run).
|
|
474
|
+
const unfinished = deps.find((d) => !isSatisfiedDepRow(d));
|
|
472
475
|
if (unfinished) {
|
|
473
476
|
return { ok: false, reason: `dependsOn: "${depSlug}" is ${unfinished.status} (need completed)` };
|
|
474
477
|
}
|
|
@@ -488,7 +491,7 @@ function checkDeps(queueEntry, allJobs, prdBody) {
|
|
|
488
491
|
if (matches.length === 0) continue; // unresolvable fragment — skip
|
|
489
492
|
|
|
490
493
|
for (const dep of matches) {
|
|
491
|
-
if (dep
|
|
494
|
+
if (!isSatisfiedDepRow(dep)) {
|
|
492
495
|
return {
|
|
493
496
|
ok: false,
|
|
494
497
|
reason: `PRD body dep "${frag}" → "${dep.slug}" is ${dep.status} (need completed)`,
|
package/src/main/scheduler.cjs
CHANGED
|
@@ -65,6 +65,8 @@ const { headlessPermissionArgs, ensureCliCapsProbed } = require('./lib/claude/cl
|
|
|
65
65
|
// as the authoritative guarantee.
|
|
66
66
|
ensureCliCapsProbed().catch(() => {});
|
|
67
67
|
const launchFailure = require('./lib/scheduler/launchFailure.cjs');
|
|
68
|
+
const { finalizeReasonFor } = require('./lib/scheduler/finalizeReason.cjs');
|
|
69
|
+
const { shouldRunFlatSweep, FLAT_SWEEP_INTERVAL_MS } = require('./lib/scheduler/flatSweepThrottle.cjs');
|
|
68
70
|
const { appendError } = require('./lib/telemetry/opsErrorLog.cjs');
|
|
69
71
|
const { readTail } = require('./lib/util/fileTail.cjs');
|
|
70
72
|
const {
|
|
@@ -1389,6 +1391,9 @@ function reconcileSourcePromptId(job, parsedSourcePromptId) {
|
|
|
1389
1391
|
// process rather than one per 60s reconcile tick.
|
|
1390
1392
|
const warnedUnregisteredEpics = new Set();
|
|
1391
1393
|
|
|
1394
|
+
/** @type {number | null} last flat-sweep start (ms); null until first pass. */
|
|
1395
|
+
let lastFlatSweepMs = null;
|
|
1396
|
+
|
|
1392
1397
|
async function reconcile(state) {
|
|
1393
1398
|
// Defence in depth — tickQueue already gates on this, but reconcile is the
|
|
1394
1399
|
// function that would do the damage (every unmatched PRD .md becomes a
|
|
@@ -1414,8 +1419,17 @@ async function reconcile(state) {
|
|
|
1414
1419
|
// instead of ever reaching the onDisk scan below.
|
|
1415
1420
|
let phaseStartMs = Date.now();
|
|
1416
1421
|
const skipCwds = quarantinedCwdSet(state);
|
|
1417
|
-
|
|
1418
|
-
|
|
1422
|
+
// Throttled: the flat layout is retired, and the sweep (plus the ~270 ms
|
|
1423
|
+
// allProjectCwds() scan) cost ~1 s per pass. A PRD dropped into a flat dir
|
|
1424
|
+
// is still consolidated within one FLAT_SWEEP_INTERVAL_MS; the first pass
|
|
1425
|
+
// after boot always runs.
|
|
1426
|
+
if (shouldRunFlatSweep(phaseStartMs, lastFlatSweepMs, FLAT_SWEEP_INTERVAL_MS)) {
|
|
1427
|
+
lastFlatSweepMs = phaseStartMs;
|
|
1428
|
+
await prdPaths.consolidateAllFlatPrds(allProjectCwds(), skipCwds);
|
|
1429
|
+
phaseMs.flatPrdSweep = Date.now() - phaseStartMs;
|
|
1430
|
+
} else {
|
|
1431
|
+
phaseMs.flatPrdSweep = 0;
|
|
1432
|
+
}
|
|
1419
1433
|
|
|
1420
1434
|
phaseStartMs = Date.now();
|
|
1421
1435
|
const { files, dirCount } = await listPrdFiles(skipCwds);
|
|
@@ -2048,18 +2062,34 @@ function getNextResetCached() {
|
|
|
2048
2062
|
* (usageCircuit.isResetFresh): a stale reset must never arm a resume timer
|
|
2049
2063
|
* that already elapsed (that's the 30-second-nap bug computeEffectiveResumeAt
|
|
2050
2064
|
* below also guards against), so a stale value here returns null and lets
|
|
2051
|
-
* the caller's 30-minute fallback take over instead.
|
|
2065
|
+
* the caller's 30-minute fallback take over instead. The billing fallback is
|
|
2066
|
+
* used only when its binding reading is at/above `threshold` — a 58% weekly
|
|
2067
|
+
* reading once paused the queue to the weekly reset 4 days out (2026-10-11);
|
|
2068
|
+
* an unknown/non-finite reading returns null so the 30-minute fallback applies.
|
|
2052
2069
|
*/
|
|
2053
|
-
function resolveRateLimitPauseReset(logPath, billingResetIso, nowMs = Date.now()) {
|
|
2070
|
+
function resolveRateLimitPauseReset(logPath, billingResetIso, nowMs = Date.now(), { billingUtilization, threshold } = {}) {
|
|
2054
2071
|
const logReset = resolveBindingRateLimitReset(logPath);
|
|
2055
2072
|
if (logReset != null) {
|
|
2056
2073
|
const iso = new Date(logReset * 1000).toISOString();
|
|
2057
2074
|
if (isResetFresh(iso, nowMs)) return iso;
|
|
2058
2075
|
}
|
|
2059
|
-
if (
|
|
2076
|
+
if (
|
|
2077
|
+
billingResetIso
|
|
2078
|
+
&& Number.isFinite(billingUtilization)
|
|
2079
|
+
&& Number.isFinite(threshold)
|
|
2080
|
+
&& billingUtilization >= threshold
|
|
2081
|
+
&& isResetFresh(billingResetIso, nowMs)
|
|
2082
|
+
) return billingResetIso;
|
|
2060
2083
|
return null;
|
|
2061
2084
|
}
|
|
2062
2085
|
|
|
2086
|
+
/** Logs when a fresh billing reset was discarded because its reading is under threshold. */
|
|
2087
|
+
function logBillingResetRejected(billingResetIso, billingUtilization, threshold) {
|
|
2088
|
+
if (!billingResetIso || !Number.isFinite(threshold)) return;
|
|
2089
|
+
if (Number.isFinite(billingUtilization) && billingUtilization >= threshold) return;
|
|
2090
|
+
console.log(`[scheduler] rate_limit pause: billing binding window at ${Number.isFinite(billingUtilization) ? `${billingUtilization}%` : 'unknown'} < ${threshold}% — using 30-min fallback, not ${billingResetIso}`);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2063
2093
|
/**
|
|
2064
2094
|
* Shared by both rate-limit pause sites (spawnJob's rateLimited branch and
|
|
2065
2095
|
* reapDeadRunningJobs): the billing-endpoint-derived fallback reset used
|
|
@@ -6077,7 +6107,10 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6077
6107
|
billing.usageCircuit.recordFailure('executor_429');
|
|
6078
6108
|
const logPath = path.join(runDir, `${job.slug}.log`);
|
|
6079
6109
|
const billingResetIso = await billingResetForPause();
|
|
6080
|
-
const
|
|
6110
|
+
const pauseState = await readQueue().catch(() => null);
|
|
6111
|
+
const pauseThreshold = pauseState?.config?.utilizationThreshold;
|
|
6112
|
+
const resetIso = resolveRateLimitPauseReset(logPath, billingResetIso, Date.now(), { billingUtilization: cachedUtilization, threshold: pauseThreshold });
|
|
6113
|
+
if (resetIso == null) logBillingResetRejected(billingResetIso, cachedUtilization, pauseThreshold);
|
|
6081
6114
|
const observedAt = dispatchStartedAtMs;
|
|
6082
6115
|
const prevCount = consecutiveRapidRateLimitsBySlug.get(job.slug) || 0;
|
|
6083
6116
|
const nextCount = nextRapidRateLimitCount(prevCount, { rateLimited: true, durationMs: res.durationMs });
|
|
@@ -6570,9 +6603,7 @@ async function spawnJob(job, runId, runDir, defaultCwd, resumeTarget = null, sib
|
|
|
6570
6603
|
// reason — surface that on the completed row's statusHistory
|
|
6571
6604
|
// instead of the generic "run finished with exit 0" every other
|
|
6572
6605
|
// completed run gets.
|
|
6573
|
-
const finalizeReason = (effectiveStatus
|
|
6574
|
-
? verifyResult.reason
|
|
6575
|
-
: (sigtermOverrideReason ?? `run finished with exit ${res.exitCode}`);
|
|
6606
|
+
const finalizeReason = finalizeReasonFor({ effectiveStatus, verifyResult, sigtermOverrideReason, exitCode: res.exitCode });
|
|
6576
6607
|
// error/verifierVerdict are stamped BEFORE transitionJob() below —
|
|
6577
6608
|
// needsReviewLedger's buildNeedsReviewEntryLine reads job.
|
|
6578
6609
|
// verifierVerdict/heldReason/error synchronously off `job` the
|
|
@@ -7875,7 +7906,9 @@ async function reapDeadRunningJobs() {
|
|
|
7875
7906
|
billing.usageCircuit.recordFailure('executor_429');
|
|
7876
7907
|
const triggering = dead.find((d) => d.outcome === 'rate_limited');
|
|
7877
7908
|
const billingResetIso = await billingResetForPause();
|
|
7878
|
-
const
|
|
7909
|
+
const pauseThreshold = state.config?.utilizationThreshold;
|
|
7910
|
+
const resetIso = resolveRateLimitPauseReset(triggering.logPath, billingResetIso, Date.now(), { billingUtilization: cachedUtilization, threshold: pauseThreshold });
|
|
7911
|
+
if (resetIso == null) logBillingResetRejected(billingResetIso, cachedUtilization, pauseThreshold);
|
|
7879
7912
|
const triggeringRow = triggering ? state.jobs.find((x) => x.slug === triggering.slug) : null;
|
|
7880
7913
|
const observedAtMs = triggeringRow?.startedAt ? Date.parse(triggeringRow.startedAt) : null;
|
|
7881
7914
|
// Same rapid-repeat circuit breaker spawnJob's own res.rateLimited
|
package/src/main/supervisor.cjs
CHANGED
|
@@ -205,6 +205,41 @@ Decision rules:
|
|
|
205
205
|
- "stuck"/kill-agent only if the agent itself is wedged (no child processes, no recent log events, > 60 min stale). Set targetPid to the claude root pid.`;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Parse `claude -p --output-format json` stdout from a probe.
|
|
210
|
+
* @param {string} stdout
|
|
211
|
+
* @returns {{ verdictObj: any, costUsd: number|null, errorSubtype: string|null }}
|
|
212
|
+
*/
|
|
213
|
+
function parseProbeOutput(stdout) {
|
|
214
|
+
let costUsd = null;
|
|
215
|
+
let verdictObj = null;
|
|
216
|
+
let errorSubtype = null;
|
|
217
|
+
|
|
218
|
+
// --output-format json emits a single JSON result object.
|
|
219
|
+
// The `result` field contains the assistant's raw text response.
|
|
220
|
+
for (const line of String(stdout).split('\n').reverse()) {
|
|
221
|
+
const trimmed = line.trim();
|
|
222
|
+
if (!trimmed) continue;
|
|
223
|
+
try {
|
|
224
|
+
const obj = JSON.parse(trimmed);
|
|
225
|
+
if (!obj || typeof obj !== 'object') continue;
|
|
226
|
+
if (typeof obj.total_cost_usd === 'number') costUsd = obj.total_cost_usd;
|
|
227
|
+
if (obj.is_error === true || (typeof obj.subtype === 'string' && obj.subtype !== 'success')) {
|
|
228
|
+
errorSubtype = typeof obj.subtype === 'string' && obj.subtype ? obj.subtype : 'error';
|
|
229
|
+
}
|
|
230
|
+
// Extract verdict from the result text field (assistant's response).
|
|
231
|
+
if (obj.result && typeof obj.result === 'string') {
|
|
232
|
+
const m = obj.result.match(/\{[^{}]+\}/);
|
|
233
|
+
if (m) {
|
|
234
|
+
try { verdictObj = JSON.parse(m[0]); } catch { /* */ }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
} catch { /* not JSON */ }
|
|
238
|
+
if (verdictObj) break;
|
|
239
|
+
}
|
|
240
|
+
return { verdictObj, costUsd, errorSubtype };
|
|
241
|
+
}
|
|
242
|
+
|
|
208
243
|
async function runProbe(claudeBin, prompt) {
|
|
209
244
|
await ensureCliCapsProbed();
|
|
210
245
|
return new Promise((resolve) => {
|
|
@@ -213,10 +248,10 @@ async function runProbe(claudeBin, prompt) {
|
|
|
213
248
|
const target = claudeSpawnTarget('aux', 'supervisor', claudeBin);
|
|
214
249
|
child = spawn(target.command, [
|
|
215
250
|
'-p', prompt,
|
|
216
|
-
'--model', 'claude-
|
|
251
|
+
'--model', 'claude-haiku-5-5',
|
|
217
252
|
'--no-session-persistence',
|
|
218
253
|
'--output-format', 'json',
|
|
219
|
-
'--max-budget-usd', '0.
|
|
254
|
+
'--max-budget-usd', '0.50',
|
|
220
255
|
'--dangerously-skip-permissions',
|
|
221
256
|
...headlessPermissionArgs(),
|
|
222
257
|
'--allowedTools', 'Bash',
|
|
@@ -254,26 +289,13 @@ async function runProbe(claudeBin, prompt) {
|
|
|
254
289
|
child.on('exit', () => {
|
|
255
290
|
clearTimers();
|
|
256
291
|
const stdout = Buffer.concat(stdoutChunks).toString('utf8');
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (!trimmed) continue;
|
|
265
|
-
try {
|
|
266
|
-
const obj = JSON.parse(trimmed);
|
|
267
|
-
if (typeof obj.total_cost_usd === 'number') costUsd = obj.total_cost_usd;
|
|
268
|
-
// Extract verdict from the result text field (assistant's response).
|
|
269
|
-
if (obj.result && typeof obj.result === 'string') {
|
|
270
|
-
const m = obj.result.match(/\{[^{}]+\}/);
|
|
271
|
-
if (m) {
|
|
272
|
-
try { verdictObj = JSON.parse(m[0]); } catch { /* */ }
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
} catch { /* not JSON */ }
|
|
276
|
-
if (verdictObj) break;
|
|
292
|
+
const { verdictObj, costUsd, errorSubtype } = parseProbeOutput(stdout);
|
|
293
|
+
|
|
294
|
+
if ((!verdictObj || !verdictObj.verdict) && errorSubtype) {
|
|
295
|
+
// Budget cap / CLI error exit: record it distinctly, never as a real verdict.
|
|
296
|
+
console.warn('[supervisor] probe error exit (treating as ok):', errorSubtype);
|
|
297
|
+
resolve({ verdict: 'ok', action: 'none', targetPid: null, reason: `probe_error:${errorSubtype}`, costUsd });
|
|
298
|
+
return;
|
|
277
299
|
}
|
|
278
300
|
|
|
279
301
|
if (!verdictObj || !verdictObj.verdict) {
|
|
@@ -506,4 +528,5 @@ module.exports = {
|
|
|
506
528
|
supervisorTick,
|
|
507
529
|
applyAction,
|
|
508
530
|
registerHandlers,
|
|
531
|
+
parseProbeOutput,
|
|
509
532
|
};
|
package/src/main/webRemote.cjs
CHANGED
|
@@ -83,6 +83,7 @@ let _pongTimer = null;
|
|
|
83
83
|
let _missedPongs = 0;
|
|
84
84
|
let _configCache = null;
|
|
85
85
|
let _configCacheAt = 0;
|
|
86
|
+
let _repairNeeded = false; // relay rejected the device token (invalid_token / 401): terminal until re-pair
|
|
86
87
|
let _destroyed = false; // set at app shutdown to stop reconnect loops
|
|
87
88
|
|
|
88
89
|
// E2E session state — reset on each new WS connection.
|
|
@@ -274,6 +275,7 @@ function computeStatus(cfg) {
|
|
|
274
275
|
enabled: cfg.remoteEnabled,
|
|
275
276
|
remoteControlEnabled: cfg.remoteControlEnabled ?? false,
|
|
276
277
|
connected,
|
|
278
|
+
linkState: _repairNeeded ? 'repair-needed' : 'ok',
|
|
277
279
|
e2eActive: connected && _clients.values().some((r) => r.e2e.sessionKey !== null),
|
|
278
280
|
e2eAuthenticated: connected && authed !== null,
|
|
279
281
|
e2eState: connected ? e2eState : 'idle',
|
|
@@ -389,9 +391,18 @@ async function connect() {
|
|
|
389
391
|
scope: 'webRemote', level: 'warn',
|
|
390
392
|
message: 'device ticket request failed', meta: { error: e?.message },
|
|
391
393
|
});
|
|
394
|
+
// invalid_token / 401 is final (device unpaired server-side): retrying only
|
|
395
|
+
// spams the relay. Park in repair-needed until a new pair stores a fresh token.
|
|
396
|
+
if (e?.message === 'invalid_token' || e?.message === 'HTTP 401') {
|
|
397
|
+
cancelReconnect();
|
|
398
|
+
_repairNeeded = true;
|
|
399
|
+
broadcastStatus();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
392
402
|
scheduleReconnect();
|
|
393
403
|
return;
|
|
394
404
|
}
|
|
405
|
+
_repairNeeded = false;
|
|
395
406
|
|
|
396
407
|
// Step 2: open WSS connection with the ticket.
|
|
397
408
|
let ws;
|
|
@@ -1278,6 +1289,7 @@ async function pair(otp) {
|
|
|
1278
1289
|
}];
|
|
1279
1290
|
|
|
1280
1291
|
await saveConfig({ ...cfg, devices });
|
|
1292
|
+
_repairNeeded = false;
|
|
1281
1293
|
|
|
1282
1294
|
if (cfg.remoteEnabled) {
|
|
1283
1295
|
connect().catch(() => {});
|
|
@@ -1480,6 +1492,9 @@ module.exports = {
|
|
|
1480
1492
|
getDispatchMap,
|
|
1481
1493
|
buildRemoteSessionList,
|
|
1482
1494
|
setWs: (ws) => { _ws = ws; },
|
|
1495
|
+
connect,
|
|
1496
|
+
hasReconnectTimer: () => _reconnectTimer !== null,
|
|
1497
|
+
cancelReconnect,
|
|
1483
1498
|
invalidateConfigCache,
|
|
1484
1499
|
setE2eAuthenticated: (key, clientKey = LEGACY_CLIENT_KEY) => {
|
|
1485
1500
|
_clients.getOrCreate(clientKey).e2e = makeState('authenticated', key, null);
|
package/src/preload/api.d.ts
CHANGED
|
@@ -1495,6 +1495,8 @@ export interface ChatRunPayload {
|
|
|
1495
1495
|
/** Originating PromptTicket.id (PRD 748) when dequeued from a tab's
|
|
1496
1496
|
* prompt queue — absent for a fresh manual send. */
|
|
1497
1497
|
promptId?: string;
|
|
1498
|
+
/** Who wrote the prompt: a local human, an injected external source, or an Epic proposal from another project. */
|
|
1499
|
+
origin?: 'human' | 'external' | 'inbound-proposal';
|
|
1498
1500
|
}
|
|
1499
1501
|
|
|
1500
1502
|
export interface ChatCreatePrdPayload {
|
|
@@ -1649,6 +1651,8 @@ export interface WebRemoteStatus {
|
|
|
1649
1651
|
enabled: boolean;
|
|
1650
1652
|
remoteControlEnabled: boolean;
|
|
1651
1653
|
connected: boolean;
|
|
1654
|
+
/** 'repair-needed' once the relay rejected the device token; the device must be re-paired. */
|
|
1655
|
+
linkState?: 'ok' | 'repair-needed';
|
|
1652
1656
|
e2eActive: boolean;
|
|
1653
1657
|
/** True once the user has confirmed the SAS on the desktop. */
|
|
1654
1658
|
e2eAuthenticated: boolean;
|
|
@@ -2260,6 +2264,8 @@ export interface SessionManagerAPI {
|
|
|
2260
2264
|
}) => Promise<Exchange[]>;
|
|
2261
2265
|
};
|
|
2262
2266
|
promptSessions: {
|
|
2267
|
+
/** Main requests approve-and-start of a verified inbound proposal. */
|
|
2268
|
+
onInboundAutoApprove: (handler: (e: { cwd: string; epicId: string }) => void) => () => void;
|
|
2263
2269
|
/** Fires when the main process appends an event to a PromptSession's
|
|
2264
2270
|
* chain on disk (currently only the scheduler's response-event append
|
|
2265
2271
|
* from notifyOriginatingTab) — lets an already-hydrated Epic pick it up
|
package/src/preload/index.cjs
CHANGED
|
@@ -543,6 +543,12 @@ contextBridge.exposeInMainWorld('api', {
|
|
|
543
543
|
list: (payload) => ipcRenderer.invoke('exchanges:list', payload),
|
|
544
544
|
},
|
|
545
545
|
promptSessions: {
|
|
546
|
+
/** Main asks the renderer to approve-and-start a verified inbound proposal. */
|
|
547
|
+
onInboundAutoApprove: (handler) => {
|
|
548
|
+
const listener = (_e, payload) => handler(payload);
|
|
549
|
+
ipcRenderer.on('promptSessions:inbound-auto-approve', listener);
|
|
550
|
+
return () => ipcRenderer.removeListener('promptSessions:inbound-auto-approve', listener);
|
|
551
|
+
},
|
|
546
552
|
/** Fires when the main process (currently only the scheduler's
|
|
547
553
|
* response-event append) appends an event to a PromptSession's chain on
|
|
548
554
|
* disk — lets an already-hydrated Epic pick it up live instead of
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a4 as P,b2 as G,aE as x,ao as i,Z as R,B as T,a as _}from"./index-CTBpf-26.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-DPE1h-1L.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(E.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(_,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),b&&i.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(w,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${T[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(w,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{aE as c,ao as e,S as I,A as Q,n as V,a3 as Oe,aV as ge,bd as z,b4 as be,a as F,be as De,aX as Me,b8 as $e,b5 as Le,a_ as _e,c as ie,aC as Fe,b2 as Ue,bc as le,aY as X,aq as Be,av as Ge,J as He,H as oe,aM as Je}from"./index-CTBpf-26.js";import{P as Ke}from"./Panel-_VZ_uXNg.js";import{S as Ve}from"./ScopeSwitcher-D-nKDMAE.js";import{S as ve}from"./SaveBar-Dw64FVdM.js";import{u as We,s as ce,E as qe}from"./settingsSchema-Dh5Kl7VO.js";import{V as Xe}from"./ViewTabs-9lQCRwWJ.js";import{T as W}from"./Toggle-7WpPzcZH.js";import{u as Ye,b as J,P as M,E as se,R as ye,a as je,S as ee}from"./useRemotePeers-CI2axd-L.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";const ze=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],Ze={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function we(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,a)=>{const r=Ze[i];return r||(a===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function Ne(t){const s=new Set,n=[];for(const a of ze){const r=a.keys.filter(l=>t.has(l));r.forEach(l=>s.add(l)),r.length!==0&&n.push({id:a.id,title:a.title,summary:a.summary,advanced:!!a.advanced,keys:r})}const i=Array.from(t).filter(a=>!s.has(a)&&a!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}function Qe(t,s){return Ne(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(i=>s.has(i)).length}))}const et={};function ke(t,s){if(s)return{text:s,authored:!1};const n=et[t];return n?{text:n,authored:!0}:null}const tt={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},st=["user","project","local","default"],nt={user:"user",project:"project",local:"local",default:"default"};function at({node:t,targetScope:s,onOverride:n,schema:i}){const[a,r]=c.useState(""),[l,p]=c.useState(!1),[u,g]=c.useState(!0),m=t.kind==="object"?t:null,S=m?Object.keys(m.children):[],b=i.rootKeys(),j=new Set([...S,...b]),o=c.useMemo(()=>Ne(j),[Array.from(j).sort().join(",")]),k=c.useMemo(()=>Qe(j,new Set(S)),[Array.from(j).sort().join(","),S.join(",")]),[R,A]=c.useState(null),y=c.useRef(null),C=f=>{const w=o.find(x=>x.id===f);w!=null&&w.advanced&&!l&&p(!0),A(f)};c.useEffect(()=>{if(!R)return;A(null);const f=y.current,w=document.getElementById(`settings-group-${R}`);if(!f||!w)return;const x=w.getBoundingClientRect().top-f.getBoundingClientRect().top;f.scrollBy({top:x,behavior:"smooth"})},[R]);const E=c.useMemo(()=>o.filter(f=>l||!f.advanced).map(f=>({...f,keys:f.keys.filter(w=>{const x=(m==null?void 0:m.children[w])!==void 0;if(!u&&!x)return!1;if(!a.trim())return!0;const v=i.at([w]);return[w,we(w),(v==null?void 0:v.description)??""].join(" ").toLowerCase().includes(a.toLowerCase())})})).filter(f=>f.keys.length>0),[o,a,l,u,m,i]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:I[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:f=>g(f.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:f=>p(f.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:a,onChange:f=>r(f.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(rt,{groups:k,onJump:C}),e.jsxs("div",{ref:y,className:"flex-1 overflow-auto py-3",children:[E.map(f=>e.jsx(it,{id:f.id,title:f.title,summary:f.summary,advanced:f.advanced,children:f.keys.map(w=>{const x=m==null?void 0:m.children[w],v=i.at([w]);return e.jsx(lt,{keyName:w,node:x,info:v,targetScope:s,onOverride:(h,T)=>n([w],h,T)},w)})},f.id)),E.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',a,'"']})]})]})]})}function rt({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(Q,{name:tt[n.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function it({id:t,title:s,summary:n,advanced:i,children:a}){const[r,l]=c.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>l(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:s}),i&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:n})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:a})]})}function lt({keyName:t,node:s,info:n,targetScope:i,onOverride:a}){const[r,l]=c.useState(!1),[p,u]=c.useState(!1),g=we(t),m=s!==void 0,b=(s==null?void 0:s.kind)==="leaf"?s:null,j=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",o=n==null?void 0:n.default,k=b&&o!==void 0&&Ce(b.value,o),R=ft({isSet:m,leafNode:b,defaultVal:o,isDefault:!!k,node:s}),A=ot(b,o),y=A.length>=2,C=!!b&&!k,E=ke(t,n==null?void 0:n.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>l(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:g}),e.jsx(ht,{kind:R.kind,label:R.label}),y&&e.jsxs("button",{onClick:f=>{f.stopPropagation(),r||l(!0),u(w=>!w)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",A.map(f=>nt[f]).join(" · ")]}),C&&b&&e.jsx("button",{onClick:f=>{f.stopPropagation(),a(void 0,b.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${I[b.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!m&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),E&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${E.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:E.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:gt(E.text)}),r&&p&&b&&e.jsx(ct,{leaf:b,defaultVal:o,onReset:f=>a(void 0,f)}),r&&e.jsx(dt,{keyName:t,node:s,info:n,targetScope:i,onOverride:f=>a(f)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(mt,{node:s,info:n,onSet:f=>{a(f)},disabled:j&&m})})]})})}function ot(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const i of t.shadowed)n.add(i.scope);return s!==void 0&&n.add("default"),st.filter(i=>n.has(i))}function ct({leaf:t,defaultVal:s,onReset:n}){const i={};i[t.winner]={value:t.value,winner:!0};for(const a of t.shadowed)i[a.scope]={value:a.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(a=>{const r=i[a],l=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:I[a].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:l?U(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),l?e.jsx("button",{onClick:()=>n(a),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${I[a].label}`,children:"↺"}):e.jsx("span",{})]},a)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:s!==void 0?U(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function dt({keyName:t,node:s,info:n,targetScope:i,onOverride:a}){const l=(s==null?void 0:s.kind)==="leaf"?s:null,p=ke(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:U(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(u=>String(u)).join(" | ")})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:U(l.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",I[l.winner].label]})]})]}),l&&l.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:l.shadowed.map((u,g)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[U(u.value)," —"," ",e.jsx("span",{className:"no-underline",children:I[u.scope].label})]},g))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(xt,{keyName:t,node:s,info:n,onChange:a,targetScope:i})})]})}function xt({node:t,info:s,onChange:n,targetScope:i}){const r=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,l=Se(s==null?void 0:s.type);if(l==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:u,label:g})=>e.jsx("button",{onClick:()=>n(u),className:`px-3 py-0.5 text-xs transition-colors ${p===u?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:g},g))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",I[i].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(p=>{const u=Ce(r,p);return e.jsx("button",{onClick:()=>n(p),className:`px-2 py-0.5 text-xs rounded border ${u?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",I[i].label]})]}):l==="integer"||l==="number"?e.jsx(pt,{value:typeof r=="number"?r:void 0,integer:l==="integer",onCommit:n,target:I[i].label}):l==="string"?e.jsx(ut,{value:typeof r=="string"?r:"",onCommit:n,target:I[i].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",l??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function pt({value:t,integer:s,onCommit:n,target:i}){const[a,r]=c.useState(t!==void 0?String(t):""),l=()=>{const p=s?parseInt(a,10):parseFloat(a);Number.isNaN(p)||n(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:a,onChange:p=>r(p.target.value),onBlur:l,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:l,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function ut({value:t,onCommit:s,target:n}){const[i,a]=c.useState(t);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:i,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&s(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>s(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function mt({node:t,info:s,onSet:n,disabled:i}){const a=(t==null?void 0:t.kind)==="leaf",r=Se(s==null?void 0:s.type);if(i)return null;if(r==="boolean"){const l=a&&t.value===!0;return e.jsx("button",{onClick:()=>n(!l),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${l?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:l?"on":"off"})}return null}function ft({isSet:t,leafNode:s,defaultVal:n,isDefault:i,node:a}){return t?(a==null?void 0:a.kind)==="array"?{kind:"accumulated",label:`${a.items.length} items`}:(a==null?void 0:a.kind)==="object"?{kind:"set",label:"configured"}:s?i?{kind:"default",label:`= default · ${I[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${I[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${U(n)}`}:{kind:"unset",label:"not configured"}}function ht({kind:t,label:s}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function Se(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function Ce(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function gt(t){const s=t.trim().split(`
|
|
2
|
-
`)[0],n=s.match(/^([^.!?]+[.!?])/);return n?n[1]:s.length>120?s.slice(0,120)+"…":s}function U(t){if(typeof t=="string")return t===""?'""':JSON.stringify(t);if(t===null)return"null";if(t===void 0)return"—";if(typeof t=="object"){const s=JSON.stringify(t);return s.length>60?s.slice(0,60)+"…":s}return String(t)}const bt=1440*60*1e3;function de(t){if(!t)return"never";const s=new Date(t).getTime();return Number.isNaN(s)?"never":new Date(s).toLocaleString()}function xe(t){return t?new Date(t).toLocaleString():"never"}function vt(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(yt,{}),e.jsx("hr",{className:"border-line"}),e.jsx(jt,{})]})}function yt(){const[t,s]=c.useState(null),[n,i]=c.useState(null),[a,r]=c.useState(null),[l,p]=c.useState(null),[u,g]=c.useState(!1),[m,S]=c.useState(null),[b,j]=c.useState(null);if(c.useEffect(()=>{let y=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([C,E,f])=>{y||(s(C),r(C),i(E),p(f))}).catch(C=>{console.warn("[telemetry] load failed:",C==null?void 0:C.message)}),()=>{y=!0}},[]),!a||!t)return e.jsx(V,{title:"loading…"});const o=JSON.stringify(a)!==JSON.stringify(t),k=(y,C)=>{S(null),r({...a,[y]:C})},R=async()=>{g(!0),S(null);try{const y=await window.api.otel.setConfig(a);!y.ok&&y.error&&S(y.error),s(y.config),r(y.config),i(y.status),j(Date.now())}catch(y){S(y instanceof Error?y.message:String(y))}finally{g(!1)}},A=()=>{S(null),r(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),l&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:l})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(W,{checked:a.enabled,onChange:y=>k("enabled",y),label:a.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:a.endpoint,onChange:y=>k("endpoint",y.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:a.headers,onChange:y=>k("headers",y.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:a.serviceName,onChange:y=>k("serviceName",y.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(W,{checked:a.includeContent,onChange:y=>k("includeContent",y),label:a.includeContent?"on":"off"})]})]}),n&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:n.enabled?"text-accent":"text-fg-dim",children:String(n.enabled)})]}),n.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",n.error]}),!n.error&&n.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:R,disabled:!o||u,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:u?"saving…":"Save"}),e.jsx("button",{onClick:A,disabled:!o||u,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),m&&e.jsx("span",{className:"text-red-400 text-xs",children:m}),!m&&b&&!o&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function jt(){const[t,s]=c.useState(null),[n,i]=c.useState(null),[a,r]=c.useState("Copy"),[l,p]=c.useState(!1),[u,g]=c.useState(null),[m,S]=c.useState(null),[b,j]=c.useState(null),[o,k]=c.useState(!1),R=()=>{window.api.telemetry.status().then(i).catch(v=>{console.warn("[product-telemetry] status reload failed:",v==null?void 0:v.message)})};if(c.useEffect(()=>{let v=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([h,T])=>{v||(s(h),i(T))}).catch(h=>{console.warn("[product-telemetry] load failed:",h==null?void 0:h.message)}),()=>{v=!0}},[]),!t||!n)return e.jsx(V,{title:"loading…"});const A=async v=>{S(null);try{const h=await window.api.telemetry.setConfig(v);s(h.config),i(h.status)}catch(h){S(h instanceof Error?h.message:String(h))}},y=v=>{A({...t,enabled:v})},C=v=>{A({...t,enabled:v.turnOff?!1:t.enabled,noticeAckedAt:new Date().toISOString()})},E=async()=>{await Oe(t.installId)?(r("Copied"),setTimeout(()=>r("Copy"),1500)):ge.error("Could not copy install id to the clipboard")},f=async()=>{p(!0),g(null);try{const v=await window.api.telemetry.flushNow();g(`sent ${v.sent.length}, failed ${v.failed.length}`),R()}catch(v){g(v instanceof Error?v.message:String(v))}finally{p(!1)}},w=async()=>{if(o){k(!1);return}try{const v=await window.api.telemetry.recentRecords();j(v),k(!0)}catch(v){console.warn("[product-telemetry] recentRecords failed:",v instanceof Error?v.message:v)}},x=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+bt:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),!t.noticeAckedAt&&e.jsxs("section",{"data-testid":"telemetry-first-run-notice",className:"border border-accent rounded p-3 space-y-2 text-xs",children:[e.jsx("div",{className:"text-fg font-medium",children:"This app sends anonymous product telemetry"}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Collected: a coarse machine profile (OS/arch/app version, no hardware id), error and warning counts, and session counts — sent on start-up, after an update, and once a day."}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Never collected: prompts, transcripts, file paths, project names, email, or username."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:()=>C({turnOff:!1}),className:"px-3 py-1 rounded bg-accent text-bg",children:"OK"}),e.jsx("button",{onClick:()=>C({turnOff:!0}),className:"px-3 py-1 rounded border border-line text-fg-dim hover:text-fg",children:"Turn off"})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(W,{checked:t.enabled,onChange:y,label:t.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:t.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:E,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:a})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:t.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),m&&e.jsx("div",{className:"text-red-400 text-xs",children:m})]}),n.pendingCount>0&&n.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[n.pendingCount," record",n.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",xe(n.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",de(x?new Date(x).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",n.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",n.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",n.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",n.evictedCount]}),n.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",n.backlog.reason,", ",de(n.backlog.ranAt),"):"," ",n.backlog.linesEnqueued," enqueued, ",n.backlog.linesConfirmed," confirmed,"," ",n.backlog.watermarksRewound," watermarks rewound"]}),n.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",n.lastError.message," ","(",xe(n.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:f,disabled:l,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:l?"sending…":"Send now"}),u&&e.jsx("span",{className:"text-fg-faint text-xs",children:u})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:w,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:o?"Hide last records":"Inspect last records sent"}),o&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(b??[],null,2)})]})]})}const te="relay_client_auth_unavailable",K=t=>(t==null?void 0:t.message)||String(t),wt=["relay_client_unpaired","token_revoked"],pe={invalid_code:"That code didn't match. Check it and try again.",code_expired:"That code expired. Mint a new one on bilko.run → Desktop clients.",invalid_code_format:"Codes are 8 letters or numbers. Check it and try again.",rate_limited:"Too many tries. Wait a minute and try again.",relay_client_unpaired:"This computer is no longer connected to your account. Enter a new code to reconnect."};function ue(t){return Object.prototype.hasOwnProperty.call(pe,t)?pe[t]:`Pairing failed (${t})`}const me=t=>{const s=/^v?(\d+)\.(\d+)\.(\d+)/.exec(t.trim());return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null};function Nt(t,s){const n=me(t),i=me(s);if(!n||!i)return!1;for(let a=0;a<3;a++)if(n[a]!==i[a])return n[a]>i[a];return!1}function kt({peer:t,onConnect:s,onRevoke:n,onConfirmSas:i}){var b;const a=t.status==="authenticated",[r,l]=c.useState(null),p=((b=De())==null?void 0:b.latest)??null;c.useEffect(()=>{if(!a){l(null);return}let j=!1;return window.api.remoteClient.send(t.peerId,"cmd:app:version").then(o=>{j||l(typeof o=="string"?o:null)}).catch(()=>{j||l(null)}),()=>{j=!0}},[t.peerId,a]);const u=r!=null&&p!=null&&Nt(p,r),g=t.status==="failed"&&t.reason===te,m=t.status==="connecting",S=new Date(t.pairedAt).toLocaleString();return e.jsxs("div",{className:"space-y-2","data-testid":"remote-machine-row",children:[e.jsx(ye,{testId:"remote-machine",icon:"terminal",title:t.machineName,badge:a?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.peerId} · last seen ${S}`,action:e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!a&&!g&&t.status!=="pending_sas"&&e.jsx(M,{testId:"remote-machine-connect",disabled:m,onClick:()=>s(t.peerId),children:m?"Connecting…":"Connect"}),e.jsx(je,{testId:"remote-machine-revoke",onClick:()=>n(t.peerId),children:"Revoke"})]})}),r&&e.jsxs("p",{"data-testid":"remote-machine-version",className:"text-[12.5px] leading-snug text-fg-faint",children:["v",r]}),u&&e.jsx("p",{"data-testid":"remote-machine-update-available",className:"text-[12.5px] leading-snug text-fg-faint",children:`Update available on ${t.machineName} (v${r} → v${p}) — update it on that machine`}),g&&e.jsx("p",{"data-testid":"remote-machine-unavailable",className:"text-[12.5px] leading-snug text-fg-faint",children:"The bilko.run relay does not support desktop clients yet"}),t.status==="pending_sas"&&t.sas&&e.jsx(ee,{peer:"other machine",testId:"remote-machine-sas",codeTestId:"remote-machine-sas-code",confirmTestId:"remote-machine-sas-confirm",code:t.sas,onConfirm:()=>i(t.peerId)})]})}function St({paired:t,revoked:s,peers:n,onAuthChanged:i,onAdded:a}){const r=z(x=>x.show),[l,p]=c.useState(""),[u,g]=c.useState(!1),[m,S]=c.useState(!1),[b,j]=c.useState(null),[o,k]=c.useState({}),R=async()=>{g(!0);try{const x=await window.api.remoteClient.pair(l.trim());x.ok?(S(!1),p(""),i()):x.error===te?S(!0):r("error",ue(x.error??"unknown"))}catch(x){r("error",K(x))}finally{g(!1)}},A=async()=>{g(!0);try{const x=await window.api.remoteClient.devices();x.ok?j(x.devices??[]):x.error===te?S(!0):r("error",ue(x.error??"unknown"))}catch(x){r("error",K(x))}finally{g(!1)}},y=async x=>{try{await window.api.remoteClient.add(x,o[x]??`Machine ${x.slice(0,8)}`),a()}catch(v){r("error",K(v))}},C=async()=>{try{await window.api.remoteClient.unpair(),j(null),i()}catch(x){r("error",K(x))}},E=m&&e.jsx("p",{"data-testid":"remote-machine-unavailable",className:"text-[12.5px] leading-snug text-fg-faint",children:"The bilko.run relay does not support desktop clients yet"});if(!t)return e.jsxs("div",{className:"space-y-2 mb-3","data-testid":"remote-client-pairing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{"data-testid":"remote-client-code",value:l,maxLength:8,onChange:x=>p(x.target.value),placeholder:"8-character code",className:"px-2 py-1 text-[13px] rounded border border-line bg-transparent"}),e.jsx(M,{testId:"remote-client-pair",disabled:u||l.trim().length===0,onClick:()=>{R()},children:"Pair"})]}),e.jsx("p",{className:"text-[12.5px] leading-snug text-fg-faint",children:"Mint a desktop code on your phone: Session Manager remote → Desktop clients."}),s&&e.jsx("p",{"data-testid":"remote-client-revoked",className:"text-[12.5px] leading-snug text-fg-faint",children:"This computer was disconnected from your account on bilko.run. Enter a new code to reconnect."}),E]});const f=new Set(n.map(x=>x.deviceId)),w=(b??[]).filter(x=>!f.has(x.deviceId));return e.jsxs("div",{className:"space-y-2 mb-3","data-testid":"remote-client-pairing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{testId:"remote-client-find",disabled:u,onClick:()=>{A()},children:"Find my devices"}),e.jsx(M,{testId:"remote-client-unpair",kind:"ghost",onClick:()=>{C()},children:"Unpair"})]}),E,b&&w.length===0&&e.jsx(se,{testId:"remote-client-devices-empty",children:"No other devices to add."}),w.map(x=>e.jsxs("div",{"data-testid":"remote-client-device",className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12.5px] text-fg-faint shrink-0",children:x.email}),e.jsx(F,{tone:"default",className:x.isOnline?"!text-sage !border-sage/40":void 0,children:x.isOnline?"online":"offline"}),e.jsx("input",{"data-testid":"remote-client-name",value:o[x.deviceId]??`Machine ${x.deviceId.slice(0,8)}`,onChange:v=>k(h=>({...h,[x.deviceId]:v.target.value})),className:"px-2 py-1 text-[13px] rounded border border-line bg-transparent min-w-0"}),e.jsx(M,{testId:"remote-client-add",onClick:()=>{y(x.deviceId)},children:"Add"})]},x.deviceId))]})}function Ct(){const t=z(o=>o.show),s=be(o=>o.openPanel),[n,i]=c.useState(!1),[a,r]=c.useState(!1),l=c.useCallback(async()=>{try{const o=(await window.api.remoteClient.authStatus()).paired;i(o),o&&r(!1)}catch(o){t("error",K(o))}},[t]),p=c.useCallback(o=>{o.reason&&wt.includes(o.reason)&&(o.reason==="token_revoked"&&r(!0),l())},[l]),{peers:u,refresh:g,connect:m,confirmSas:S,revoke:b}=Ye(p);c.useEffect(()=>{l()},[l]);const j=c.useCallback(o=>b(o),[b]);return e.jsxs("div",{"data-testid":"remote-machines",children:[e.jsx(J,{right:u.length>0?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[u.length," paired"]}),e.jsx(M,{testId:"remote-machines-open-view",onClick:()=>s("remote"),children:"Open Remote view"})]}):void 0,children:"Remote machines"}),e.jsx(St,{paired:n,revoked:a,peers:u,onAuthChanged:()=>{l()},onAdded:()=>{g()}}),u.length===0?e.jsx(se,{testId:"remote-machines-empty",children:"No machines paired yet."}):e.jsx("div",{className:"space-y-2",children:u.map(o=>e.jsx(kt,{peer:o,onConnect:m,onRevoke:j,onConfirmSas:S},o.peerId))})]})}function fe({label:t,hint:s,on:n,onChange:i,warn:a,disabled:r,first:l,testId:p}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${l?"":"border-t border-rule"} ${r?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${a?"text-honey-dark":"text-fg-faint"}`,children:[a&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),s]})]}),e.jsx("span",{"data-testid":p,className:"inline-flex",children:e.jsx(W,{checked:n,onChange:r?()=>{}:i,disabled:r})})]})}function Et({device:t,online:s,onRevoke:n,revoking:i}){const a=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(ye,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:s?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${a}`,action:e.jsx(je,{testId:"settings-remote-revoke",onClick:()=>n(t.deviceId),disabled:i})})}const $=t=>(t==null?void 0:t.message)||String(t);function Rt(){var re;const t=z(d=>d.show),[s,n]=c.useState(null),[i,a]=c.useState(!0),[r,l]=c.useState(!1),[p,u]=c.useState(!1),[g,m]=c.useState("idle"),[S,b]=c.useState(""),[j,o]=c.useState(null),[k,R]=c.useState(!1),[A,y]=c.useState([]),[C,E]=c.useState(!1),f=c.useRef(null);c.useEffect(()=>{let d=!1;const N=()=>window.api.webRemote.getStatus().then(D=>{d||n(D)}).catch(()=>{});window.api.webRemote.getStatus().then(D=>{d||(n(D),a(!1))}).catch(D=>{d||(t("error",`Remote status: ${$(D)}`),a(!1))});const Ie=window.api.webRemote.onStatus(D=>n(D)),Te=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),N()}),Pe=window.api.webRemote.onRevokedAll(({revokedCount:D})=>{t("info",`Panic: all ${D} device(s) revoked and sessions torn down.`),N()});return()=>{d=!0,Ie(),Te(),Pe()}},[t]),c.useEffect(()=>{if(g!=="enter-otp")return;const d=setTimeout(()=>{var N;return(N=f.current)==null?void 0:N.focus()},50);return()=>clearTimeout(d)},[g]);const w=async()=>n(await window.api.webRemote.getStatus()),x=async()=>{if(s){l(!0);try{const d=s.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();d&&d.ok===!1&&t("error",d.error||"Failed to change remote state."),await w()}catch(d){t("error",`Failed: ${$(d)}`)}finally{l(!1)}}},v=async()=>{if(s){u(!0);try{const d=s.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();d&&d.ok===!1&&t("error",d.error||"Failed to change command writes."),await w()}catch(d){t("error",`Failed: ${$(d)}`)}finally{u(!1)}}},h=async()=>{const d=S.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(d)){t("warn","Pairing code must be 8 alphanumeric characters.");return}m("pairing");try{const N=await window.api.webRemote.pair(d);if(!N.ok){t("error",N.error||"Pairing failed."),m("enter-otp");return}t("info","Device paired successfully."),b(""),m("idle"),await w()}catch(N){t("error",`Pairing error: ${$(N)}`),m("enter-otp")}},T=async d=>{o(d);try{const N=await window.api.webRemote.revokeDevice(d);if(!N.ok){t("error",N.error||"Revoke failed.");return}await w()}catch(N){t("error",`Revoke error: ${$(N)}`)}finally{o(null)}},P=async()=>{R(!0);try{const d=await window.api.webRemote.revokeAll();d.ok||t("error",d.error||"Panic revoke failed.")}catch(d){t("error",`Panic revoke error: ${$(d)}`)}finally{R(!1)}},ne=async()=>{if(C){E(!1);return}try{const d=await window.api.webRemote.auditTail(100);if(!d.ok){t("error",`Audit log: ${d.error||"unavailable"}`);return}y(d.lines??[]),E(!0)}catch(d){t("error",`Audit log: ${$(d)}`)}},_=async d=>{try{const N=await window.api.webRemote.confirmSas(d);N!=null&&N.ok||t("error",`SAS confirm failed: ${(N==null?void 0:N.error)??"unexpected state — reconnect the mobile app"}`)}catch(N){t("error",`SAS confirm failed: ${$(N)}`)}};if(i)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const O=(s==null?void 0:s.enabled)??!1,L=(s==null?void 0:s.remoteControlEnabled)??!1,q=(s==null?void 0:s.connected)??!1,B=(s==null?void 0:s.e2eActive)??!1,Ee=(s==null?void 0:s.e2eAuthenticated)??!1,Re=(s==null?void 0:s.e2eState)??"idle",ae=(s==null?void 0:s.pendingSas)??null,Z=((s==null?void 0:s.clients)??[]).filter(d=>d.state==="pending_sas"&&d.pendingSas),G=(s==null?void 0:s.devices)??[],H=O&&q,Ae=q?((re=G.reduce((d,N)=>N.lastConnectedAt&&(!d||(d.lastConnectedAt??"")<N.lastConnectedAt)?N:d,null))==null?void 0:re.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[Z.length>0?Z.map((d,N)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[Z.length>1&&e.jsx("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:d.clientId??"Phone"}),e.jsx(ee,{testId:N===0?"settings-remote-sas":void 0,codeTestId:N===0?"settings-remote-sas-code":void 0,confirmTestId:N===0?"settings-remote-sas-confirm":void 0,code:d.pendingSas,onConfirm:()=>_(d.key)})]},d.key)):ae&&e.jsx(ee,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:ae,onConfirm:()=>_()}),Re==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${H?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${H?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(Q,{name:H?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:H?"Remote control is active":O?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:H?"A web session can send commands to this machine. Revoke below if unexpected.":O?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),B&&Ee?e.jsx(F,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):B?e.jsx(F,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(F,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(J,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(fe,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:O,disabled:r,onChange:()=>{r||x()}}),e.jsx(fe,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:L?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:L,disabled:!O||p,on:L&&O,onChange:()=>{O&&!p&&v()}})]})]}),e.jsxs("div",{children:[e.jsx(J,{children:"Pair a device"}),g==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(M,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>m("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(Q,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:f,"data-testid":"settings-remote-otp",value:S,onChange:d=>b(d.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:d=>{d.key==="Enter"&&h()},maxLength:8,placeholder:"XXXXXXXX",disabled:g==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(M,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:h,disabled:g==="pairing"||S.length<8,children:g==="pairing"?"Pairing…":"Confirm"}),e.jsx(M,{kind:"ghost",onClick:()=>{m("idle"),b("")},disabled:g==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(J,{right:G.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[G.length," paired"]}):void 0,children:"Paired devices"}),G.length===0?e.jsx(se,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:G.map(d=>e.jsx(Et,{device:d,online:d.deviceId===Ae,onRevoke:T,revoking:j===d.deviceId},d.deviceId))})]}),e.jsx(Ct,{}),e.jsxs("div",{children:[e.jsx(J,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:ne,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:C?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),C&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:A.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:A.join(`
|
|
3
|
-
`)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:P,disabled:k,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:k?"Revoking…":"Revoke all"})]})]})}const Y="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function At(){const t=Me(),s=z(p=>p.show),n=async p=>{try{const g=await p();g&&g.ok===!1&&s("error",g.error??"Update action failed")}catch(u){s("error",u instanceof Error?u.message:String(u))}};if(!t)return null;const{state:i}=t,a=i==="unsupported",r=t.latest?`v${t.latest}`:"—",l=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&n(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",r]})]})]}),a?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{checked:t.enabled,onChange:p=>void n(()=>window.api.updater.setEnabled(p)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:Y,disabled:i==="checking"||i==="downloading",onClick:()=>void n(()=>window.api.updater.check()),children:"Check for updates"})]}),i==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),i==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),i==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:Y,onClick:()=>void n(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),i==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:Y,onClick:l,children:"Install now"}),e.jsx("button",{type:"button",className:Y,onClick:()=>void n(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),i==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}const It={compact:"Compact",roomy:"Roomy"};function Tt(){const{model:t,setModel:s}=$e(),{catalog:n}=Le(null),{density:i,setDensity:a}=_e();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx(ie,{options:Fe(n),value:t,onChange:s,mono:!0}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]}),e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(ie,{options:["compact","roomy"],value:i,onChange:r=>a(r),labels:It}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]}),e.jsx(At,{})]})}function Pt({cwd:t}){const[s,n]=c.useState(!1),[i,a]=c.useState(!1),[r,l]=c.useState(!1),[p,u]=c.useState(!1);c.useEffect(()=>{var j,o;let b=!1;return n(!1),Promise.resolve((o=(j=window.api.promptSessions)==null?void 0:j.getWorktreeDisabled)==null?void 0:o.call(j,{cwd:t})).then(k=>{b||(a((k==null?void 0:k.disabled)??!1),l((k==null?void 0:k.disabled)??!1),n(!0))},()=>{b||n(!0)}),()=>{b=!0}},[t]);const g=s&&r!==i,m=()=>{var b,j;u(!0),Promise.resolve((j=(b=window.api.promptSessions)==null?void 0:b.setWorktreeDisabled)==null?void 0:j.call(b,{cwd:t,disabled:r})).then(o=>{a((o==null?void 0:o.disabled)??r),l((o==null?void 0:o.disabled)??r)}).catch(o=>ge.error(o instanceof Error?o.message:String(o))).finally(()=>u(!1))},S=()=>l(i);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!s||p,onChange:b=>l(b.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),g&&e.jsx(ve,{dirty:g,busy:p,onSave:m,onRevert:S})]})}const he={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function Ot(){const t=Ue(),s=le(h=>h.tabs),n=le(h=>h.activeTabId),i=s.find(h=>h.id===n)??null,a=(i==null?void 0:i.cwd)??null,r=be(h=>h.navFace),l=c.useRef(!1),p=c.useRef(r),[u,g]=c.useState(()=>r==="project"&&a?"project":"user"),[m,S]=c.useState("effective");c.useEffect(()=>{if(p.current!==r){if(p.current=r,l.current){l.current=!1;return}g(r==="project"&&a?"project":"user")}},[r,a]),c.useEffect(()=>{r==="project"&&(m==="telemetry"||m==="remote"||m==="app")&&S("effective")},[r,m]);const b=h=>{l.current=!0,g(h)},j=We(oe,t,a),o=j[u]??null,k=X(h=>h.files),R=X(h=>h.setDraft),A=X(h=>h.saveJson),y=X(h=>h.revert),[C,E]=c.useState(null),f=c.useMemo(()=>Be(Ge(k,j)),[k,j]),w=(h,T,P)=>{var B;const _=j[P??u];if(!_)return;E(null);const O=((B=k[_])==null?void 0:B.draftRaw)??"";let L={};if(O.trim())try{L=JSON.parse(O)}catch{L={}}const q=Je(L,h,T);R(_,JSON.stringify(q,null,2)+`
|
|
4
|
-
`)};if(!t)return e.jsx(V,{title:"loading…"});const x=o?k[o]:null,v=h=>h!=="user"&&!a;return e.jsx(Ke,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(Xe,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...r==="home"?[{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Phone remote"},{key:"app",label:"Session Manager"}]:[]],active:m,onChange:S}),m!=="telemetry"&&m!=="remote"&&m!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Ve,{scopes:oe.scopes,active:u,onChange:b,annotate:h=>{if(v(h))return{exists:!1};const T=j[h];if(!T)return null;const P=k[T];return{exists:(P==null?void 0:P.exists)??!1,dirty:(P==null?void 0:P.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:m==="effective"?`overrides → ${o??"—"}`:o??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:m!=="telemetry"&&m!=="remote"&&m!=="app"&&o&&x?e.jsx(ve,{dirty:x.dirty,busy:x.busy,parseError:C||x.parseError,lastSavedAt:x.lastSavedAt,leading:x.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{E(null);const h=await A(o);h.ok||E(h.error??"save failed")},onRevert:()=>{E(null),y(o)}}):null,children:m==="telemetry"?e.jsx(vt,{}):m==="remote"?e.jsx(Rt,{}):m==="app"?e.jsx(Tt,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:he[u].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:he[u].body}),o&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:o})]}),u==="project"&&a&&e.jsx(Pt,{cwd:a}),v(u)?e.jsx(V,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):m==="effective"?e.jsx(at,{node:f,targetScope:u,onOverride:w,schema:ce()}):m==="tree"?e.jsx(qe,{node:f,targetScope:u,onOverride:w,schema:ce()}):o&&x?e.jsx(He,{path:o,value:x.draftRaw,onChange:h=>{E(null),R(o,h)}}):e.jsx(V,{title:"resolving…"})]})})}const Jt=c.memo(Ot);export{he as SETTINGS_SCOPE_NOTES,Jt as Settings};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aE as a,b2 as ce,aW as de,b4 as ue,aV as E,aY as d,aZ as fe,ao as s,n as T}from"./index-CTBpf-26.js";import{P as _}from"./Panel-_VZ_uXNg.js";import{L as me}from"./ListDetail-PStOuQAo.js";import{M as pe}from"./MarkdownEditor-DPw-N2-m.js";import{S as he}from"./SaveBar-Dw64FVdM.js";import{S as K}from"./ScopeSwitcher-D-nKDMAE.js";import{T as xe}from"./Toggle-7WpPzcZH.js";import{P as Q}from"./ProvenanceBadge-B1WUknak.js";import{l as ve}from"./listSkills-C1aWKf0T.js";import{S as ge,V as I}from"./Library-DPE1h-1L.js";import{p as ke,r as je,s as be}from"./skillFrontmatter-Dif5JIg7.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-36j3PzYv.js";const Se=250,we=2e3;function ye(m,p){return{user:{skills:`${m}/.claude/skills`,commands:`${m}/.claude/commands`},project:p?{skills:`${p}/.claude/skills`,commands:`${p}/.claude/commands`}:null}}function Ce(){const m=ce(),p=de(),x=(p==null?void 0:p.cwd)??null,v=ue(t=>t.navFace),S=a.useRef(!1),B=a.useRef(v),[u,$]=a.useState(()=>v==="project"&&x?"project":"user"),[f,w]=a.useState([]),[o,D]=a.useState(null),[y,L]=a.useState("installed"),[O,X]=a.useState(""),[q,H]=a.useState([]),[U,F]=a.useState(null),C=a.useMemo(()=>m?ye(m,x):null,[m,x]);a.useEffect(()=>{if(B.current!==v){if(B.current=v,S.current){S.current=!1;return}$(v==="project"&&x?"project":"user")}},[v,x]);const c=a.useMemo(()=>C?u==="user"?C.user:C.project:null,[u,C]),P=a.useRef(0),N=a.useCallback(async()=>{const t=++P.current;if(!c){w([]),H([]);return}const l=[],n=[];try{const e=await ve(c.skills);n.push(...e.errors);for(const r of e.entries)l.push({kind:"skills",scope:u,name:r.name,path:r.path,dir:r.dir,disabled:je(r.text),description:ke(r.text).description??void 0})}catch(e){n.push({path:c.skills,error:e instanceof Error?e.message:String(e)})}try{const e=await window.api.config.listDir(c.commands,{filesOnly:!0});e.ok||n.push({path:c.commands,error:e.error??"failed to list directory"});for(const r of e.entries)r.name.endsWith(".md")&&l.push({kind:"commands",scope:u,name:r.name.replace(/\.md$/,""),path:r.path,dir:null,disabled:!1})}catch(e){n.push({path:c.commands,error:e instanceof Error?e.message:String(e)})}if(P.current===t){for(const e of n)E.error(`Could not read ${e.path}: ${e.error}`);H(n),l.sort((e,r)=>e.kind===r.kind?e.name.localeCompare(r.name):e.kind==="skills"?-1:1),w(l),D(e=>{var r;return l.find(i=>i.path===e)?e:((r=l[0])==null?void 0:r.path)??null})}},[c,u]);a.useEffect(()=>{N()},[N]),a.useEffect(()=>()=>{P.current+=1},[]);const Y=a.useRef(N);Y.current=N;const Z=a.useRef(f);Z.current=f;const z=a.useRef(o);z.current=o;const g=a.useRef(null),W=a.useRef(!1),A=a.useRef(!1),M=a.useCallback(async()=>{if(W.current){A.current=!0;return}W.current=!0;try{await Y.current()}finally{W.current=!1}A.current&&(A.current=!1,M())},[]);a.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const ee=a.useCallback(t=>{var r;const l=z.current,n=l?Z.current.find(i=>i.path===l):null,e=l?(r=d.getState().files[l])==null?void 0:r.lastSavedAt:null;n!=null&&n.dir&&e&&Date.now()-e<we&&(t===n.dir||n.dir.startsWith(`${t}/`))||(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,M()},Se))},[M]);fe(c?[c.skills,c.commands]:[],ee);const b=d(t=>t.files),te=d(t=>t.loadText),se=d(t=>t.setDraft),re=d(t=>t.saveText),ae=d(t=>t.revert),ne=d(t=>t.watchFile),G=d(t=>t.unwatchFile);async function le(t,l){const n=await window.api.config.readText(t.path);if(!n.exists)return;const e=be(n.text,l);if(e===n.text)return;const r=await window.api.config.writeText(t.path,e);if(!r.ok){E.error(r.error??"failed to update skill");return}w(i=>i.map(j=>j.path===t.path?{...j,disabled:l}:j)),d.getState().files[t.path]&&d.getState().loadText(t.path,!0)}async function oe(t){if(!t.dir)return;F(null);const l=await window.api.files.delete(t.dir);if(!l.ok){E.error(l.error??"failed to remove skill");return}E.info(`Removed "${t.name}" — moved to trash`),G(t.path),w(n=>{const e=n.filter(r=>r.path!==t.path);return D(r=>{var i;return r!==t.path?r:((i=e[0])==null?void 0:i.path)??null}),e})}a.useEffect(()=>{if(o)return b[o]||te(o),ne(o),()=>G(o)},[o]);const[ie,R]=a.useState(null);if(!m)return s.jsx(T,{title:"loading…"});if(y==="library")return s.jsx(_,{toolbar:s.jsx(I,{active:y,onChange:L,installedLabel:"Installed",libraryLabel:"Library"}),children:s.jsx(ge,{})});if(u==="project"&&!x)return s.jsx(_,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(I,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(K,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}})]}),children:s.jsx(T,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const h=f.find(t=>t.path===o)??null,k=o?b[o]:null;return s.jsx(_,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(I,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(K,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}}),s.jsxs("span",{className:"ml-3 text-fg-faint",children:[f.length," ",f.length===1?"item":"items"]}),s.jsx("div",{className:"flex-1"}),h&&s.jsx(Q,{scope:h.scope,input:{type:h.kind==="commands"?"command":"skill",name:h.name}}),s.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(h==null?void 0:h.path)??""})]}),footer:o&&k?s.jsx(he,{dirty:k.dirty,busy:k.busy,parseError:ie,lastSavedAt:k.lastSavedAt,onSave:async()=>{R(null);const t=await re(o);t.ok||R(t.error??"save failed")},onRevert:()=>{R(null),ae(o)}}):null,children:s.jsx(me,{sidebar:s.jsxs("div",{className:"py-1",children:[s.jsx("div",{className:"px-2 pb-1",children:s.jsx("input",{value:O,onChange:t=>X(t.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),["skills","commands"].map(t=>{const l=O.toLowerCase(),n=f.filter(e=>e.kind===t&&(!l||e.name.toLowerCase().includes(l)));return s.jsxs("div",{className:"mb-3",children:[s.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:t==="skills"?"Skills":"Slash Commands"}),n.length===0?s.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):n.map(e=>{var i,j,J;const r=e.kind==="skills";return s.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${o===e.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[s.jsxs("button",{onClick:()=>D(e.path),className:"flex-1 min-w-0 text-left",children:[s.jsxs("div",{className:`truncate ${e.disabled?"line-through opacity-50":""}`,title:e.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[e.kind==="commands"?"/":"",e.name]}),e.description&&s.jsx("div",{className:"truncate text-fg-faint",children:e.description})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Q,{interactive:!1,scope:e.scope,input:{type:e.kind==="commands"?"command":"skill",name:e.name}}),((i=b[e.path])==null?void 0:i.dirty)&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),r&&s.jsx("span",{title:(j=b[e.path])!=null&&j.dirty?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(xe,{checked:!e.disabled,disabled:!!((J=b[e.path])!=null&&J.dirty),onChange:V=>void le(e,!V)})}),e.kind==="skills"&&U===e.path&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>void oe(e),title:`Remove ${e.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{onClick:()=>F(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}),e.kind==="skills"&&U!==e.path&&s.jsx("button",{onClick:V=>{V.stopPropagation(),F(e.path)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${e.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},e.path)})]},t)})]}),detail:o&&k?s.jsx("div",{className:"h-full",children:s.jsx(pe,{path:o,value:k.draftRaw,onChange:t=>{R(null),se(o,t)}})}):f.length===0&&q.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(T,{title:"could not list skills or commands",hint:q.map(t=>`${t.path}: ${t.error}`).join(`
|
|
2
|
-
`)})}):s.jsx(T,{title:f.length===0?"no skills or commands":"select an item"})})})}const _e=a.memo(Ce);export{_e as Skills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aE as i,aY as g,ao as e,a0 as R,aV as O,b1 as _,am as V,an as B,aR as I,a5 as $,e as z,h as M,t as D,s as T,l as H,aa as Y,b2 as q,C as G,n as A,a9 as J}from"./index-CTBpf-26.js";import{P}from"./Panel-_VZ_uXNg.js";import{S as K}from"./SaveBar-Dw64FVdM.js";import{f as Q,V as U}from"./Library-DPE1h-1L.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-36j3PzYv.js";import"./listSkills-C1aWKf0T.js";const W=300;function X({activePath:s,selectedPath:o,onSelect:f}){const[l,a]=i.useState([]),h=i.useRef(0),r=i.useRef(f);r.current=f;const y=g(n=>{var d;return s?(d=n.files[s])==null?void 0:d.diskRaw:void 0}),m=i.useRef(null);if(i.useEffect(()=>{r.current(null)},[s]),i.useEffect(()=>{if(h.current+=1,!s){m.current=null,a([]);return}const n=m.current!==s;m.current=s;let d=!1;const u=()=>{h.current+=1;const b=h.current;window.api.config.parseImports(s).then(v=>{d||h.current!==b||(v.ok?a(v.imports):(a([]),O.error(v.error||"failed to parse @-imports")))})},j=n?null:setTimeout(u,W);return n&&u(),()=>{d=!0,j&&clearTimeout(j)}},[s,y]),l.length===0||!s)return null;const x=o===s||o===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",l.length+1]}),e.jsxs("button",{type:"button",onClick:()=>f(null),"aria-current":x,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${x?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:R(s)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:s,children:"this system prompt"})]}),l.map(n=>{const d=!n.ok||!n.exists,u=o===n.path;return e.jsxs("button",{type:"button",onClick:()=>f(n),"aria-current":u,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${u?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:R(n.path)}),d&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:n.path,children:n.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[n.sizeBytes.toLocaleString()," bytes · ~",n.tokenEstimate.toLocaleString()," tokens"]})]},n.path)})]})}function Z({path:s,value:o,onChange:f,onSave:l,readOnly:a,defaultMode:h,headerRight:r,hideStatusBar:y}){const m=_(),x=V(s),n=B(s),d=I(s),[u,j]=i.useState(()=>a&&n?"preview":h??$(s)),[b,v]=i.useState(!0),[w,L]=i.useState(null),E=i.useRef(null),c=i.useRef(null),k=i.useCallback(t=>{E.current=t},[]),S=i.useCallback(()=>E.current,[]),C=a?n?["preview","edit"]:[]:d?["edit","preview","split"]:n?["edit","preview"]:[],p=n?u:"edit",N=e.jsx(z,{path:s,name:R(s),value:o,onChange:f,onSave:()=>l==null?void 0:l(),onReady:k,onCursor:L,readOnly:a});return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"document-editor-pane",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-7 shrink-0 border-b border-line bg-bg-elev",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg truncate",children:R(s)}),a&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-fg-faint border border-line",children:"read-only"}),e.jsx("div",{className:"flex-1"}),r,x&&(p==="preview"||p==="split")&&e.jsx("button",{onClick:()=>v(t=>!t),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${b?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),C.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:C.map(t=>e.jsx("button",{onClick:()=>j(t),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${p===t?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:t},t))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:p==="split"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!a&&e.jsx(D,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(T,{ref:c,text:o,flush:!0,wideMeasure:m.wideMeasure})})]}):p==="preview"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(T,{ref:c,text:o,wideMeasure:m.wideMeasure})})]}):x?e.jsxs("div",{className:"flex flex-col h-full",children:[!a&&e.jsx(D,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}):N}),!y&&e.jsx(H,{text:o,cursor:w,language:Y(s)||void 0})]})}const F={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function ee(){const s=q(),[o,f]=i.useState("installed"),l=i.useMemo(()=>s?G.resolve("user",s,null):null,[s]),[a,h]=i.useState(null),r=(a==null?void 0:a.path)??l,y=!!a&&(!a.ok||!a.exists),m=g(t=>t.files),x=g(t=>t.loadText),n=g(t=>t.setDraft),d=g(t=>t.saveText),u=g(t=>t.revert),j=g(t=>t.watchFile),b=g(t=>t.unwatchFile);i.useEffect(()=>{if(l)return x(l,!0),j(l),()=>{b(l)}},[l]),i.useEffect(()=>{if(!(!r||r===l))return x(r,!0),j(r),()=>{b(r)}},[r,l]);const[v,w]=i.useState(null),L=i.useCallback(t=>{w(null),h(t)},[]);if(!s)return e.jsx(A,{title:"loading…"});if(o==="library")return e.jsx(P,{toolbar:e.jsx(U,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),children:e.jsx(Q,{})});const E=l?m[l]:null,c=r?m[r]:null,k=(c==null?void 0:c.draftRaw)??"",S=J(k),C=k.length,p=y,N=async()=>{if(!r)return;w(null);const t=await d(r);t.ok||w(t.error??"save failed")};return e.jsx(P,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(U,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:r??"—"}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[C.toLocaleString()," chars · ~",S.toLocaleString()," tokens"]})]}),footer:r&&c&&!p?e.jsx(K,{dirty:c.dirty,busy:c.busy,parseError:v,lastSavedAt:c.lastSavedAt,leading:c.exists?a?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:N,onRevert:()=>{w(null),u(r)}}):null,children:l&&E?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:F.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:F.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:l})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(X,{activePath:l,selectedPath:r,onSelect:L}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[p&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),r&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Z,{path:r,value:k,readOnly:p,defaultMode:"split",onChange:t=>{w(null),n(r,t)},onSave:()=>{N()}},r)})]})]})]}):e.jsx(A,{title:"resolving…"})})}const oe=i.memo(ee);export{oe as SystemPrompt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aE as r,V as p,ao as e,n as k,aU as w,aV as b,$ as y}from"./index-CTBpf-26.js";import{P as E}from"./Panel-_VZ_uXNg.js";import{L as P}from"./ListDetail-PStOuQAo.js";import{u as $,a as v,t as N}from"./useAgentsDirWatch-CMpx0d04.js";import"./monaco-editor-BsIlgG7c.js";function S(){const[s,i]=r.useState(p[0].tag),[l,g]=r.useState(null),[h,x]=r.useState(!1),c=r.useRef(!0);r.useEffect(()=>()=>{c.current=!1},[]);const f=r.useRef(0),o=async()=>{const t=++f.current;try{const n=await window.api.agents.listPersonas();c.current&&f.current===t&&g(n)}catch(n){if(!c.current||f.current!==t)return;g([]),b.error(n.message||"failed to load agent personas")}};r.useEffect(()=>{o()},[]),r.useEffect(()=>window.api.agents.onChanged(()=>o()),[]),$(null,()=>o());const m=p.find(t=>t.tag===s)??null,a=async(t,n)=>{try{await window.api.agents.savePersona(v(t,{tags:N([...t.tags,n])})),x(!1),await o()}catch(d){b.error(d.message||"failed to assign tag")}},u=async(t,n)=>{try{await window.api.agents.savePersona(v(t,{tags:N(t.tags.filter(d=>d!==n))})),await o()}catch(d){b.error(d.message||"failed to remove tag")}};return e.jsx(E,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[p.length," tag",p.length===1?"":"s"]}),children:e.jsx(P,{sidebar:e.jsx("div",{className:"py-1",children:p.map(t=>{const n=w(t.tag),d=s===t.tag,j=(l==null?void 0:l.filter(T=>T.tags.includes(t.tag)).length)??0;return e.jsxs("button",{onClick:()=>{i(t.tag),x(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${d?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${n.bg} ${n.text} ${n.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"truncate",children:t.label}),j>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:j})]},t.tag)})}),detail:m?e.jsx(C,{entry:m,personas:l,adding:h,setAdding:x,onAssign:a,onUnassign:u}):e.jsx(k,{title:"select a tag"})})})}const q=r.memo(S);function C({entry:s,personas:i,adding:l,setAdding:g,onAssign:h,onUnassign:x}){const c=w(s.tag),f=y(s.tag),o=(i==null?void 0:i.filter(a=>a.tags.includes(s.tag)))??[],m=(i==null?void 0:i.filter(a=>!a.tags.includes(s.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${c.bg} ${c.text} ${c.border?"border border-current/30":""}`,children:["#",s.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:s.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:s.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),i===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[a.name,e.jsx("button",{onClick:()=>x(a,s.tag),title:"Remove this tag from the agent",className:"text-fg-faint hover:text-fg",children:"×"})]},a.name)),o.length===0&&!l&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."}),l?m.length>0?e.jsxs("select",{autoFocus:!0,defaultValue:"",onChange:a=>{const u=i.find(t=>t.name===a.target.value);u&&h(u,s.tag)},onBlur:()=>g(!1),className:"bg-bg border border-line rounded px-2 py-0.5 text-[11px] text-fg font-mono",children:[e.jsx("option",{value:"",disabled:!0,children:"pick an agent…"}),m.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]}):e.jsx("span",{className:"text-xs text-fg-faint italic",children:"every agent already carries this tag."}):e.jsx("button",{onClick:()=>g(!0),className:"px-2 py-0.5 rounded-full text-[11px] font-mono border border-line text-fg-faint hover:text-fg hover:bg-bg-hi",children:"+ assign agent"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:f.initialPromptTemplate})]})]})}export{q as TagLibrary};
|