@tom2012/cc-web 2026.5.15-g → 2026.5.16-a
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/README.md +1 -1
- package/backend/dist/tracks/__tests__/verify-track-cancel.d.ts +23 -0
- package/backend/dist/tracks/__tests__/verify-track-cancel.d.ts.map +1 -0
- package/backend/dist/tracks/__tests__/verify-track-cancel.js +153 -0
- package/backend/dist/tracks/__tests__/verify-track-cancel.js.map +1 -0
- package/backend/dist/tracks/registry.d.ts.map +1 -1
- package/backend/dist/tracks/registry.js +47 -1
- package/backend/dist/tracks/registry.js.map +1 -1
- package/backend/dist/tracks/track-runner.d.ts +7 -0
- package/backend/dist/tracks/track-runner.d.ts.map +1 -1
- package/backend/dist/tracks/track-runner.js +25 -1
- package/backend/dist/tracks/track-runner.js.map +1 -1
- package/frontend/dist/assets/{ChatOverlay-BigXori6.js → ChatOverlay-DxpbRiER.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-BkPky-TI.js → GraphPreview-DRLMf3Nh.js} +1 -1
- package/frontend/dist/assets/{MobilePage-IGjtsg4k.js → MobilePage-CokExUMn.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-k40TguA5.js → OfficePreview-CyzAoUZx.js} +2 -2
- package/frontend/dist/assets/{PdfPreview-Cf8-GCtH.js → PdfPreview-C8QLFGii.js} +1 -1
- package/frontend/dist/assets/{ProjectPage-BfRSuGNi.js → ProjectPage-BPXSttKO.js} +4 -4
- package/frontend/dist/assets/{SettingsPage-CVZcaQ3R.js → SettingsPage-BsGVZ7QV.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-BpRh93-z.js → SkillHubPage-DcT0Bqhf.js} +1 -1
- package/frontend/dist/assets/{TrackEditor-BxTMmmLm.js → TrackEditor-DOTXUGor.js} +3 -3
- package/frontend/dist/assets/{chevron-down-Dys4vcAs.js → chevron-down-BqO_s8Lw.js} +1 -1
- package/frontend/dist/assets/{cssMode-BELivHMu.js → cssMode-DzbSJSBr.js} +1 -1
- package/frontend/dist/assets/{editor.main-CKVebMR9.js → editor.main-DC8nTgWW.js} +7 -7
- package/frontend/dist/assets/{freemarker2-TNJanLhm.js → freemarker2-BXB8PQ7I.js} +1 -1
- package/frontend/dist/assets/{handlebars-B3v55Vhh.js → handlebars-I7ch77qF.js} +1 -1
- package/frontend/dist/assets/{html-BQpZAffq.js → html-Do_yHKxU.js} +1 -1
- package/frontend/dist/assets/{htmlMode-CdyV2SNL.js → htmlMode-BPR1scxz.js} +1 -1
- package/frontend/dist/assets/{index-CRx61OUk.js → index-B8JeGt0F.js} +1 -1
- package/frontend/dist/assets/{index-BXSNl9gW.js → index-CN701B8t.js} +1 -1
- package/frontend/dist/assets/{index-y1WxRtWz.js → index-OYFfhZJK.js} +1 -1
- package/frontend/dist/assets/{index-Dyb7Lej-.js → index-P75DiJki.js} +2 -2
- package/frontend/dist/assets/{javascript-fg8xZnXs.js → javascript-BNXRKlsL.js} +1 -1
- package/frontend/dist/assets/{jsonMode-Bnr3fl29.js → jsonMode-DtjdCBU0.js} +1 -1
- package/frontend/dist/assets/{jszip.min-CW5dbhJE.js → jszip.min-CUjeMA7z.js} +1 -1
- package/frontend/dist/assets/{liquid-cd7iiptp.js → liquid-BpL1MpJR.js} +1 -1
- package/frontend/dist/assets/{mdx-Bi-AeiES.js → mdx-tEcPj6CQ.js} +1 -1
- package/frontend/dist/assets/{python-CwYGkoEx.js → python-niOtt1WT.js} +1 -1
- package/frontend/dist/assets/{razor-BxDZcept.js → razor-D_eSXSai.js} +1 -1
- package/frontend/dist/assets/{select-Bm9XoR-Q.js → select-BkQpRbP5.js} +1 -1
- package/frontend/dist/assets/{tsMode-CGypMWLJ.js → tsMode-Cxpc0mXx.js} +1 -1
- package/frontend/dist/assets/{typescript-BPBAfhzM.js → typescript-B9YDFBes.js} +1 -1
- package/frontend/dist/assets/{user-Bg3xPKf3.js → user-Da5oNB1i.js} +1 -1
- package/frontend/dist/assets/{xml-BsI1h9KH.js → xml-ozjuWHxB.js} +1 -1
- package/frontend/dist/assets/{yaml-DXaWyEXz.js → yaml-QQs8YH67.js} +1 -1
- package/frontend/dist/index.html +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A self-hosted web application (distributed as npm package) that provides a browser-based interface for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI sessions. Create projects, each with a persistent terminal running Claude Code, and interact with them through a real-time terminal UI.
|
|
4
4
|
|
|
5
|
-
**Current version**: v2026.5.
|
|
5
|
+
**Current version**: v2026.5.16-a | [GitHub](https://github.com/zbc0315/cc-web) | MIT License
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression test for the v-15-f/g daemon-crash bug:
|
|
3
|
+
*
|
|
4
|
+
* POST /tracks/abort while a track is suspended in __ccweb_ask_user
|
|
5
|
+
* used to bubble the reject up through bridge.requestInput →
|
|
6
|
+
* builtin → train.runFile → runner.run → registry.start's `void
|
|
7
|
+
* runner.run(...).then(...)`. Because that .then had no .catch, the
|
|
8
|
+
* rejection escaped as `unhandledRejection`, and the global fatal
|
|
9
|
+
* handler in logger.ts called process.exit(1) — ccweb daemon died.
|
|
10
|
+
*
|
|
11
|
+
* This script:
|
|
12
|
+
* 1. Installs an unhandledRejection listener that flips a flag.
|
|
13
|
+
* 2. Starts a registry-driven track that blocks on __ccweb_ask_user.
|
|
14
|
+
* 3. Calls registry.abort() once the ask_user push fires.
|
|
15
|
+
* 4. Verifies:
|
|
16
|
+
* - flag stays false (no escaping promise)
|
|
17
|
+
* - registry.getState() reports status === 'cancelled'
|
|
18
|
+
* - track_run_complete broadcast has ok=false, errorType=UserCancelError
|
|
19
|
+
*
|
|
20
|
+
* Run: cd backend && npx ts-node src/tracks/__tests__/verify-track-cancel.ts
|
|
21
|
+
*/
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=verify-track-cancel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-track-cancel.d.ts","sourceRoot":"","sources":["../../../src/tracks/__tests__/verify-track-cancel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Regression test for the v-15-f/g daemon-crash bug:
|
|
4
|
+
*
|
|
5
|
+
* POST /tracks/abort while a track is suspended in __ccweb_ask_user
|
|
6
|
+
* used to bubble the reject up through bridge.requestInput →
|
|
7
|
+
* builtin → train.runFile → runner.run → registry.start's `void
|
|
8
|
+
* runner.run(...).then(...)`. Because that .then had no .catch, the
|
|
9
|
+
* rejection escaped as `unhandledRejection`, and the global fatal
|
|
10
|
+
* handler in logger.ts called process.exit(1) — ccweb daemon died.
|
|
11
|
+
*
|
|
12
|
+
* This script:
|
|
13
|
+
* 1. Installs an unhandledRejection listener that flips a flag.
|
|
14
|
+
* 2. Starts a registry-driven track that blocks on __ccweb_ask_user.
|
|
15
|
+
* 3. Calls registry.abort() once the ask_user push fires.
|
|
16
|
+
* 4. Verifies:
|
|
17
|
+
* - flag stays false (no escaping promise)
|
|
18
|
+
* - registry.getState() reports status === 'cancelled'
|
|
19
|
+
* - track_run_complete broadcast has ok=false, errorType=UserCancelError
|
|
20
|
+
*
|
|
21
|
+
* Run: cd backend && npx ts-node src/tracks/__tests__/verify-track-cancel.ts
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
const fs = __importStar(require("fs/promises"));
|
|
58
|
+
const os = __importStar(require("os"));
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const __1 = require("..");
|
|
61
|
+
let failed = 0;
|
|
62
|
+
function check(name, cond, msg) {
|
|
63
|
+
if (cond) {
|
|
64
|
+
console.log(` ✓ ${name}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
failed++;
|
|
68
|
+
console.error(` ✗ ${name}${msg ? ': ' + msg : ''}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function writeWf(p, w) {
|
|
72
|
+
await fs.writeFile(p, JSON.stringify(w, null, 2), 'utf8');
|
|
73
|
+
}
|
|
74
|
+
async function testAbortDuringAskUser() {
|
|
75
|
+
console.log('\n=== abort during pending ask_user (regression v-15-f/g) ===');
|
|
76
|
+
let unhandled = null;
|
|
77
|
+
const onUnhandled = (reason) => {
|
|
78
|
+
unhandled = reason;
|
|
79
|
+
};
|
|
80
|
+
process.on('unhandledRejection', onUnhandled);
|
|
81
|
+
try {
|
|
82
|
+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'ccweb-cancel-'));
|
|
83
|
+
const projectDir = path.join(tmpDir, 'proj');
|
|
84
|
+
await fs.mkdir(path.join(projectDir, '.ccweb'), { recursive: true });
|
|
85
|
+
const wfPath = path.join(projectDir, '.ccweb', 'workflow_data.json');
|
|
86
|
+
await writeWf(wfPath, { constants: {}, variables: {}, task_progress: [] });
|
|
87
|
+
(0, __1.saveTrack)(projectDir, 'pause.tr', `func main() -> any {
|
|
88
|
+
let r = __ccweb_ask_user({
|
|
89
|
+
fields: [
|
|
90
|
+
{ key: "decision", label: "go?", type: "enum", variants: ["yes","no"] }
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
return r.decision
|
|
94
|
+
}
|
|
95
|
+
export main
|
|
96
|
+
`);
|
|
97
|
+
const trackAbs = path.join(projectDir, '.ccweb', 'tracks', 'pause.tr');
|
|
98
|
+
const broadcastEvents = [];
|
|
99
|
+
const registry = (0, __1.createTrackRegistry)({
|
|
100
|
+
getProjectFolder: (id) => (id === 'proj' ? projectDir : null),
|
|
101
|
+
injectIntoPty: () => { },
|
|
102
|
+
broadcast: (_projectId, msg) => {
|
|
103
|
+
broadcastEvents.push({ msg });
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
const start = await registry.start('proj', trackAbs, 'pause.tr', []);
|
|
107
|
+
check('registry.start ok', start.ok);
|
|
108
|
+
// Wait until the bridge actually pushed the ask_user event — that's
|
|
109
|
+
// the signal that bridge.requestInput is parked on the Promise and
|
|
110
|
+
// the abort path will trip the signalHandler reject.
|
|
111
|
+
const startTs = Date.now();
|
|
112
|
+
while (broadcastEvents.find((e) => e.msg.type === 'track_ask_user') === undefined &&
|
|
113
|
+
Date.now() - startTs < 8000) {
|
|
114
|
+
await new Promise((r) => setTimeout(r, 20));
|
|
115
|
+
}
|
|
116
|
+
check('track_ask_user broadcast fired before abort', broadcastEvents.find((e) => e.msg.type === 'track_ask_user') !== undefined);
|
|
117
|
+
check('ask_user is pending before abort', registry.getPendingAskUser('proj') !== null);
|
|
118
|
+
// The actual abort — this is what used to crash ccweb.
|
|
119
|
+
const aborted = registry.abort('proj');
|
|
120
|
+
check('registry.abort returned true', aborted);
|
|
121
|
+
// Give the promise chain enough ticks to settle and the fatal
|
|
122
|
+
// handler enough chance to fire if it would have.
|
|
123
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
124
|
+
check('no unhandledRejection escaped (would have killed ccweb)', unhandled === null, unhandled instanceof Error ? unhandled.message : String(unhandled));
|
|
125
|
+
const finalState = registry.getState('proj');
|
|
126
|
+
check('final state non-null', finalState !== null);
|
|
127
|
+
check('final status is cancelled (not failed/running)', finalState?.status === 'cancelled', `got: ${finalState?.status}`);
|
|
128
|
+
check('final error.errorType is UserCancelError', finalState?.error?.errorType === 'UserCancelError', `got: ${finalState?.error?.errorType}`);
|
|
129
|
+
check('isRunning false after abort', !registry.isRunning('proj'));
|
|
130
|
+
const completes = broadcastEvents.filter((e) => e.msg.type === 'track_run_complete');
|
|
131
|
+
check('exactly one track_run_complete broadcast', completes.length === 1, `got ${completes.length}`);
|
|
132
|
+
if (completes.length === 1) {
|
|
133
|
+
const c = completes[0].msg;
|
|
134
|
+
check('track_run_complete ok=false', c.ok === false);
|
|
135
|
+
check('track_run_complete errorType=UserCancelError', c.error?.errorType === 'UserCancelError', `got: ${c.error?.errorType}`);
|
|
136
|
+
}
|
|
137
|
+
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
process.off('unhandledRejection', onUnhandled);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function main() {
|
|
144
|
+
console.log('=== verify-track-cancel ===');
|
|
145
|
+
await testAbortDuringAskUser();
|
|
146
|
+
console.log(`\n${failed === 0 ? '✅ ALL CANCEL CHECKS PASSED' : `❌ ${failed} CHECK(S) FAILED`}`);
|
|
147
|
+
process.exit(failed === 0 ? 0 : 1);
|
|
148
|
+
}
|
|
149
|
+
main().catch((e) => {
|
|
150
|
+
console.error('verify-track-cancel crashed:', e);
|
|
151
|
+
process.exit(2);
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=verify-track-cancel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-track-cancel.js","sourceRoot":"","sources":["../../../src/tracks/__tests__/verify-track-cancel.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAiC;AACjC,uCAAwB;AACxB,2CAA4B;AAE5B,0BAAmD;AAGnD,IAAI,MAAM,GAAG,CAAC,CAAA;AACd,SAAS,KAAK,CAAC,IAAY,EAAE,IAAa,EAAE,GAAY;IACtD,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;IAC5B,CAAC;SAAM,CAAC;QACN,MAAM,EAAE,CAAA;QACR,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACtD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,CAAS,EAAE,CAAe;IAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,C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TrackRegistry(deps) {
|
|
|
77
77
|
watcher,
|
|
78
78
|
logger: deps.logger,
|
|
79
79
|
askUserBridge: bridge,
|
|
80
|
+
// Pin the runner's runId to the one registry hands out, so
|
|
81
|
+
// bridge.pending keys, registry.entry.runId, the runId returned
|
|
82
|
+
// to the route, and state.runId all match. Pre-fix mismatch
|
|
83
|
+
// made getPendingAskUser/submitInput/cancelAllForRun no-ops
|
|
84
|
+
// since they looked up the wrong key.
|
|
85
|
+
runId,
|
|
80
86
|
onState: (state) => {
|
|
81
87
|
// Ignore late callbacks from a previous run — only the run
|
|
82
88
|
// whose runId matches the entry's current runId is allowed
|
|
@@ -101,7 +107,17 @@ function createTrackRegistry(deps) {
|
|
|
101
107
|
};
|
|
102
108
|
projects.set(projectId, entry);
|
|
103
109
|
// Fire and forget — the run resolves later; route returns immediately.
|
|
104
|
-
|
|
110
|
+
//
|
|
111
|
+
// The .catch is defense-in-depth: track-runner converts its own
|
|
112
|
+
// exceptions to TrackRunResult, so .then's callback handles every
|
|
113
|
+
// expected outcome. But if track-runner ever throws (host bug, OOM,
|
|
114
|
+
// future refactor), there's no .catch to break a rejected promise
|
|
115
|
+
// chain — it escapes to logger.ts's unhandledRejection handler
|
|
116
|
+
// which process.exit(1)s the entire daemon. The .catch keeps that
|
|
117
|
+
// class of bug from killing ccweb.
|
|
118
|
+
void runner
|
|
119
|
+
.run(absTrackPath, args)
|
|
120
|
+
.then((result) => {
|
|
105
121
|
const e = projects.get(projectId);
|
|
106
122
|
if (e && e.runId === runId) {
|
|
107
123
|
e.inFlight = false;
|
|
@@ -112,6 +128,36 @@ function createTrackRegistry(deps) {
|
|
|
112
128
|
value: result.value,
|
|
113
129
|
error: result.error,
|
|
114
130
|
});
|
|
131
|
+
})
|
|
132
|
+
.catch((err) => {
|
|
133
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
134
|
+
deps.logger?.error?.({ projectId, runId, err: message }, '[TrackRegistry] run threw — converted to failed event');
|
|
135
|
+
// Synthesize a terminal state so isRunning() returns false and
|
|
136
|
+
// the frontend's track_status_change consumers see a definite
|
|
137
|
+
// end-of-run, not a stuck 'running'. Without this, runner-level
|
|
138
|
+
// bugs that future-broke runner's NEVER-THROW contract would
|
|
139
|
+
// leave the project stuck (entry.lastState would stay null/running).
|
|
140
|
+
const e = projects.get(projectId);
|
|
141
|
+
const failedState = {
|
|
142
|
+
runId,
|
|
143
|
+
trackFilename: e?.trackFilename ?? '',
|
|
144
|
+
startedAt: e?.lastState?.startedAt ?? Date.now(),
|
|
145
|
+
status: 'failed',
|
|
146
|
+
endedAt: Date.now(),
|
|
147
|
+
error: { errorType: 'RunnerThrew', message },
|
|
148
|
+
};
|
|
149
|
+
if (e && e.runId === runId) {
|
|
150
|
+
e.inFlight = false;
|
|
151
|
+
e.lastState = failedState;
|
|
152
|
+
}
|
|
153
|
+
emit(projectId, 'track_status_change', {
|
|
154
|
+
state: failedState,
|
|
155
|
+
});
|
|
156
|
+
emit(projectId, 'track_run_complete', {
|
|
157
|
+
ok: false,
|
|
158
|
+
value: null,
|
|
159
|
+
error: { errorType: 'RunnerThrew', message },
|
|
160
|
+
});
|
|
115
161
|
});
|
|
116
162
|
return { ok: true, runId };
|
|
117
163
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tracks/registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFH,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tracks/registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFH,kDAoKC;AArPD,2CAA4B;AAE5B,iDAAoE;AACpE,mEAAmE;AACnE,uDAAkG;AA6ElG,SAAgB,mBAAmB,CAAC,IAAuB;IACzD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAA;IAEhD,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AA;QACxF,CAAC;QAED,QAAQ,CAAC,SAAS;YAChB,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,SAAS,IAAI,IAAI,CAAA;QACnD,CAAC;QAED,SAAS,CAAC,SAAS;YACjB,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACrC,IAAI,CAAC,KAAK;gBAAE,OAAO,KAAK,CAAA;YACxB,0DAA0D;YAC1D,uEAAuE;YACvE,IAAI,KAAK,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAA;YAC/B,MAAM,OAAO,GAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;YACvD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAC3E,CAAC;QAED,iBAAiB,CAAC,SAAS;YACzB,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YACrC,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAA;YACvB,OAAO,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC7C,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -40,6 +40,13 @@ export interface TrackRunnerDeps {
|
|
|
40
40
|
* "Undefined identifier '__ccweb_ask_user'".
|
|
41
41
|
*/
|
|
42
42
|
askUserBridge?: AskUserBridge;
|
|
43
|
+
/**
|
|
44
|
+
* Pre-allocated runId. The caller (registry) needs to know the runId
|
|
45
|
+
* synchronously before run() awaits, so it can route submitInput /
|
|
46
|
+
* getPendingAskUser to the right bridge entry. If omitted, runner
|
|
47
|
+
* generates one. Used so registry.entry.runId === bridge pending key.
|
|
48
|
+
*/
|
|
49
|
+
runId?: string;
|
|
43
50
|
}
|
|
44
51
|
export interface TrackRunResult {
|
|
45
52
|
ok: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track-runner.d.ts","sourceRoot":"","sources":["../../src/tracks/track-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IACtC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,qBAAqB;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACnC,qDAAqD;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACxC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"track-runner.d.ts","sourceRoot":"","sources":["../../src/tracks/track-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IACtC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,qBAAqB;IACrB,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IACnC,qDAAqD;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IACxC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAA;IACX,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC9D;AAyBD,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IACpE,+BAA+B;IAC/B,MAAM,IAAI,IAAI,CAAA;IACd,8BAA8B;IAC9B,QAAQ,IAAI,aAAa,GAAG,IAAI,CAAA;CACjC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CA4IpE"}
|
|
@@ -43,7 +43,7 @@ function createTrackRunner(deps) {
|
|
|
43
43
|
return {
|
|
44
44
|
async run(absTrackPath, args = []) {
|
|
45
45
|
const train = await loadTrain();
|
|
46
|
-
const runId = `track-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
46
|
+
const runId = deps.runId ?? `track-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
47
47
|
state = {
|
|
48
48
|
runId,
|
|
49
49
|
trackFilename: absTrackPath.split('/').pop() ?? absTrackPath,
|
|
@@ -111,6 +111,30 @@ function createTrackRunner(deps) {
|
|
|
111
111
|
});
|
|
112
112
|
return { ok: true, value: result.value };
|
|
113
113
|
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
// NEVER-THROW contract: runFile / builtin / adapter throws (incl.
|
|
116
|
+
// ask_user reject during abort) MUST be converted into TrackRunResult.
|
|
117
|
+
// Without this catch the throw escapes runner.run, registry.ts's
|
|
118
|
+
// `void runner.run(...).then(...)` has no .catch, and the global
|
|
119
|
+
// unhandledRejection handler (logger.ts) calls process.exit(1).
|
|
120
|
+
// → entire ccweb daemon dies whenever a track with pending ask_user
|
|
121
|
+
// is aborted. (Repro: v-15-f / v-15-g logs, 2026-05-16 07:35 / 07:36.)
|
|
122
|
+
const aborted = abortController?.signal.aborted ?? false;
|
|
123
|
+
const e = err;
|
|
124
|
+
const errObj = aborted
|
|
125
|
+
? {
|
|
126
|
+
errorType: 'UserCancelError',
|
|
127
|
+
message: e?.message ?? 'cancelled',
|
|
128
|
+
}
|
|
129
|
+
: {
|
|
130
|
+
errorType: e?.errorType ?? 'RuntimeError',
|
|
131
|
+
message: e?.message ?? String(err),
|
|
132
|
+
code: e?.code,
|
|
133
|
+
};
|
|
134
|
+
const finalStatus = aborted ? 'cancelled' : 'failed';
|
|
135
|
+
updateState({ status: finalStatus, endedAt: Date.now(), error: errObj });
|
|
136
|
+
return { ok: false, value: null, error: errObj };
|
|
137
|
+
}
|
|
114
138
|
finally {
|
|
115
139
|
deps.watcher.stop();
|
|
116
140
|
if (deps.askUserBridge && state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"track-runner.js","sourceRoot":"","sources":["../../src/tracks/track-runner.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;
|
|
1
|
+
{"version":3,"file":"track-run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AE,WAAW,CAAC,CAAA;gBAC9D,CAAC;gBACD,eAAe,GAAG,IAAI,CAAA;YACxB,CAAC;QACH,CAAC;QAED,MAAM;YACJ,IAAI,eAAe,EAAE,CAAC;gBACpB,eAAe,CAAC,KAAK,EAAE,CAAA;gBACvB,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,gCAAgC,CAAC,CAAA;YACvD,CAAC;QACH,CAAC;QAED,QAAQ;YACN,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bA as e,bB as t,r as n,bC as r,c as a,h as i,bD as o,bE as s,j as l,W as c,d as u,aE as d,bF as p,t as m,A as g,p as h,aY as f,bG as b,a as y,a0 as E,a2 as v,Z as S,Y as w,a1 as k,V as x,bf as T,aG as A,bu as _,bv as I,i as N,bH as R,bI as C,s as O,bJ as L,bK as D,bw as M,bL as P,by as F,S as B,l as U,o as z}from"./index-
|
|
1
|
+
import{bA as e,bB as t,r as n,bC as r,c as a,h as i,bD as o,bE as s,j as l,W as c,d as u,aE as d,bF as p,t as m,A as g,p as h,aY as f,bG as b,a as y,a0 as E,a2 as v,Z as S,Y as w,a1 as k,V as x,bf as T,aG as A,bu as _,bv as I,i as N,bH as R,bI as C,s as O,bJ as L,bK as D,bw as M,bL as P,by as F,S as B,l as U,o as z}from"./index-P75DiJki.js";import{C as $}from"./chevron-down-BqO_s8Lw.js";import{a as G,C as j,u as H,c as q}from"./index-OYFfhZJK.js";function V(){!e.current&&t();const[a]=n.useState(r.current);return a}
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,r as t,b as n,j as i,aE as r,B as o,R as a}from"./index-
|
|
1
|
+
import{c as e,r as t,b as n,j as i,aE as r,B as o,R as a}from"./index-P75DiJki.js";import{Z as l,a as s}from"./ProjectPage-BPXSttKO.js";import"./purify.es-CgRAQgUo.js";import"./ChatOverlay-DxpbRiER.js";import"./chevron-down-BqO_s8Lw.js";import"./index-OYFfhZJK.js";import"./select-BkQpRbP5.js";import"./user-Da5oNB1i.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OfficePreview-
|
|
2
|
-
import{c as e,aH as t,bm as s,aJ as a,r as n,bn as r,bo as l,j as o,bp as c,R as i,d,bq as u,br as x,bs as m,bt as h,bu as p,bv as f,ac as g,ab as b,bw as j,bx as v,t as y,aa as N,aK as w,aE as k,by as C,a as S,b as I,g as P,D as z,h as M,W as U,_ as T,l as $,X as R,o as D,aV as E,bz as A,C as L,A as H,p as O}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OfficePreview-CyzAoUZx.js","assets/index-P75DiJki.js","assets/index-BmPb0Wl1.css","assets/purify.es-CgRAQgUo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as e,aH as t,bm as s,aJ as a,r as n,bn as r,bo as l,j as o,bp as c,R as i,d,bq as u,br as x,bs as m,bt as h,bu as p,bv as f,ac as g,ab as b,bw as j,bx as v,t as y,aa as N,aK as w,aE as k,by as C,a as S,b as I,g as P,D as z,h as M,W as U,_ as T,l as $,X as R,o as D,aV as E,bz as A,C as L,A as H,p as O}from"./index-P75DiJki.js";import{A as _,i as q,T as F,j as W,k as B,G as V,M as K,r as J,a as G,b as Q,c as X,e as Y,h as Z,o as ee,d as te,I as se,F as ae}from"./ChatOverlay-DxpbRiER.js";import{a as ne}from"./index-OYFfhZJK.js";import{C as re}from"./chevron-down-BqO_s8Lw.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.309.0 - ISC
|
|
5
5
|
*
|
|
@@ -11,4 +11,4 @@ import{c as e,aH as t,bm as s,aJ as a,r as n,bn as r,bo as l,j as o,bp as c,R as
|
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/function ue({onSelectProject:e}){const h=t(),p=s(e=>e.clearToken),{projects:f,fetchProjects:g,hasFetched:b,loading:j}=a(),v=n.useCallback(()=>{a.getState().setProjects([]),p(),h("/login")},[p,h]),[y,N]=n.useState(new Map),[w,k]=n.useState(new Set),[C,S]=n.useState(!1);n.useEffect(()=>{g()},[g]);const I=n.useCallback(e=>{e.status&&N(t=>{const s=new Map(t);return s.set(e.projectId,e.status),s}),void 0!==e.active&&k(t=>{const s=new Set(t);return e.active?s.add(e.projectId):s.delete(e.projectId),s})},[]);r({onActivityUpdate:I});const{applyOrder:P}=l(),z=P(f.filter(e=>!e.archived));return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 h-12 border-b border-border shrink-0",children:[o.jsx("span",{className:"font-semibold text-base flex-1",children:"CC Web"}),o.jsx(c,{}),o.jsx("button",{onClick:()=>{(async()=>{S(!0);try{await g()}finally{S(!1)}})()},className:"text-muted-foreground active:text-foreground",disabled:C,"aria-label":"Refresh",children:o.jsx(i,{className:d("h-4 w-4",C&&"animate-spin")})}),o.jsx("button",{onClick:()=>h("/settings"),className:"text-muted-foreground active:text-foreground","aria-label":"Settings",children:o.jsx(u,{className:"h-4 w-4"})}),o.jsx("button",{onClick:v,className:"text-muted-foreground active:text-foreground","aria-label":"Logout",children:o.jsx(x,{className:"h-4 w-4"})}),!de&&o.jsx("button",{onClick:()=>h("/"),className:"text-muted-foreground active:text-foreground","aria-label":"Desktop mode",children:o.jsx(m,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[j&&!b&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"加载中..."}),b&&0===z.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"暂无项目"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:z.map(t=>{var s;const a="running"===(s=t,y.get(s.id)??s.status??"stopped"),n=w.has(t.id),r=o.jsxs("button",{onClick:()=>e(t.id),className:d("w-full text-left rounded-xl border bg-card p-2.5 active:bg-accent transition-colors",n?"border-transparent":"border-border"),children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",a?"bg-green-500":"bg-zinc-400")}),o.jsx("span",{className:"font-medium text-sm truncate flex-1",children:t.name})]}),o.jsx("div",{className:"text-[10px] text-muted-foreground font-mono truncate",children:t.cliTool??"claude"})]});return o.jsx("div",{className:n?"card-active-glow rounded-xl":void 0,children:r},t.id)})})]})]})}function xe(e){if(!e.phase)return null;if("thinking"===e.phase)return"思考中";if("tool_result"===e.phase)return"处理结果";if("tool_use"===e.phase){const t=(e.detail||"").toLowerCase();return"bash"===t?"执行命令":"read"===t?"读取文件":"edit"===t||"multiedit"===t?"编辑文件":"write"===t?"写入文件":"grep"===t?"搜索内容":"glob"===t?"匹配文件":"webfetch"===t||"websearch"===t?"访问网络":"task"===t?"调度子任务":"todowrite"===t?"更新任务列表":"notebookedit"===t?"编辑 Notebook":e.detail?`调用 ${e.detail}`:"调用工具"}return null}function me({project:e,onBack:t,onOpenPanel:s,onContextUpdate:a}){const[r,l]=n.useState(""),c=n.useRef(null),i=n.useRef(null),[u,x]=n.useState([]),m=n.useCallback(e=>{x(t=>{const s=[...t,e];return s.length>200?s.slice(-200):s})},[]),S=n.useRef(null),I=n.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),[P,z]=n.useState([]),M=n.useRef(new Set),U=n.useCallback(e=>{M.current.has(e.toolUseId)||z(t=>t.some(t=>t.toolUseId===e.toolUseId)?t:[...t,{projectId:e.projectId,toolUseId:e.toolUseId,toolName:e.toolName,toolInput:e.toolInput,sessionId:e.sessionId,createdAt:e.createdAt}])},[]),T=n.useCallback(e=>{M.current.add(e.toolUseId),z(t=>t.filter(t=>t.toolUseId!==e.toolUseId))},[]),$=n.useCallback(e=>{M.current.add(e),z(t=>t.filter(t=>t.toolUseId!==e))},[]),[R,D]=n.useState(null),E=n.useRef(0),A=n.useCallback(e=>{var t,s,a;if(!e.active)return void D(null);if("text"===(null==(t=e.semantic)?void 0:t.phase))return void D(null);const n=null==(s=e.semantic)?void 0:s.phase,r=null==(a=e.semantic)?void 0:a.detail;D(e=>e?e.phase===n&&e.detail===r?e:{...e,phase:n,detail:r}:{id:"mab"+ ++E.current,phase:n,detail:r})},[]),{sendInput:L,connected:H}=h({projectId:e.id,enabled:!0,onChatMessage:m,onStatusChange:I,onContextUpdate:a,onApprovalRequest:U,onApprovalResolved:T,onSemanticUpdate:A});n.useEffect(()=>{if(!H)return;if("claude"!==e.cliTool)return;let t=!1;return p(e.id).then(e=>{if(t)return;const s=e.pending.filter(e=>!M.current.has(e.toolUseId));z(e=>{const t=new Map;for(const a of s)t.set(a.toolUseId,a);for(const s of e)t.has(s.toolUseId)||M.current.has(s.toolUseId)||t.set(s.toolUseId,s);return[...t.values()]})}).catch(()=>{}),()=>{t=!0}},[e.id,e.cliTool,H]);const{state:O,setState:K,messages:J,hasMoreHistory:G,loadMoreHistory:Q,sendMessage:X,isWaking:Y}=f({project:e,liveMessages:u,ws:{send:L,connected:H},historyLimit:20});S.current=K;const Z=n.useRef(H);n.useEffect(()=>{!Z.current&&H&&x([]),Z.current=H},[H]);const ee=(()=>{for(let e=J.length-1;e>=0;e--)if("assistant"===J[e].role)return e;return-1})(),[te,se]=n.useState([]),[ae,oe]=n.useState([]),[ce,de]=n.useState(null),[ue,me]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{g().then(se).catch(()=>{}),b(e.id).then(oe).catch(()=>{})},[e.id]);const pe=n.useCallback(e=>{const t=i.current;if(!t)return void l(t=>t+e);const s=t.selectionStart??r.length,a=t.selectionEnd??r.length,n=r.slice(0,s)+e+r.slice(a);l(n),requestAnimationFrame(()=>{t.focus();const a=s+e.length;t.setSelectionRange(a,a),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"})},[r]),fe=n.useCallback(e=>{de(null),pe(e+" ")},[pe]),ge=n.useCallback(t=>{const s=e.folderPath;let a=t;s&&(t===s||t.startsWith(s+"/")||t.startsWith(s+"\\"))&&(a=t.slice(s.length).replace(/^[/\\]+/,"")),de(null),pe(`@${a} `)},[e.folderPath,pe]),be=n.useCallback(async()=>{if("skills"!==ce){if(!he.current){he.current=!0;try{const t=await j(e.cliTool??"claude",e.id);me(t)}catch{me({builtin:[],custom:[],plugins:[],mcp:[]})}finally{he.current=!1}}de("skills")}else de(null)},[ce,e.cliTool,e.id]),je=n.useCallback(async()=>{const e=c.current,t=(null==e?void 0:e.scrollHeight)??0;await Q(),requestAnimationFrame(()=>{e&&(e.scrollTop+=e.scrollHeight-t)})},[Q]),ve=n.useRef(0);n.useEffect(()=>{const e=c.current;if(!e)return;const t=J.length>ve.current,s=0===ve.current&&J.length>0;ve.current=J.length,s?e.scrollTo({top:e.scrollHeight}):t&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[J,P.length]);const[ye,Ne]=n.useState(!1),we=n.useCallback(async()=>{const e=r.trim();if(!e||ye)return;Ne(!0);const t=await X(e);Ne(!1),"delivered"===t&&(l(""),i.current&&(i.current.style.height="auto"))},[r,ye,X]),ke=v(we,"shift"),Ce=n.useCallback(async(t,s)=>{de(null);try{"failed"===await X(t.command)?y.error("快捷命令未送达,请重试或检查会话"):"project"===s&&N(e.id,t.id,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})}catch(a){console.error("Shortcut send error:",a),y.error("快捷命令发送失败")}},[X,e.id]),Se="live"===O;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[o.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",Se?"bg-green-500":Y?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),o.jsx("button",{onClick:s,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(ie,{className:"h-5 w-5"})})]}),o.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 min-h-0",children:[G&&o.jsx("div",{className:"flex justify-center pb-1",children:o.jsxs("button",{onClick:()=>{je()},className:"flex items-center gap-1 px-3 py-1.5 rounded-full text-xs text-muted-foreground border border-border active:bg-accent transition-colors",children:[o.jsx(ne,{className:"h-3 w-3"}),"加载更早消息"]})}),J.map((e,t)=>{const s="user"===e.role;return o.jsx("div",{className:d("flex",s?"justify-end":"justify-start"),children:o.jsx("div",{className:d("max-w-[85%] rounded-xl px-3 py-2 break-words text-sm leading-relaxed",s?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm whitespace-pre-wrap":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:s?e.content:o.jsx(_,{content:e.content,blocks:e.blocks,isLatest:t===ee})})},e.id)}),P.map(e=>o.jsx(q,{approval:e,onResolved:$},e.toolUseId)),R&&0===P.length&&o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"rounded-2xl rounded-bl-md px-3 py-1.5 bg-black/5 dark:bg-white/10 border border-black/10 dark:border-white/15 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(F,{}),xe(R)&&o.jsx("span",{children:xe(R)})]})},R.id),0===J.length&&0===P.length&&!R&&"stopped"===O&&o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-sm",children:"暂无对话记录"}),Y&&o.jsx("div",{className:"flex items-center justify-center py-4 text-yellow-400 text-sm animate-pulse",children:"启动中..."})]}),"global"===ce||"project"===ce?o.jsx("div",{className:"border-t border-border max-h-48 overflow-y-auto shrink-0",children:o.jsxs("div",{className:"px-3 py-2 space-y-1",children:[("global"===ce?te:ae).map(e=>o.jsxs("button",{onClick:()=>Ce(e,ce),disabled:Y,className:d("w-full text-left rounded-md px-2.5 py-2 text-sm active:bg-accent transition-colors border border-border/50",Y&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:"font-medium text-xs",children:e.label}),o.jsx("div",{className:"text-[11px] text-muted-foreground font-mono truncate",children:e.command})]},e.id)),0===("global"===ce?te:ae).length&&o.jsx("div",{className:"text-center text-muted-foreground text-xs py-3",children:"暂无快捷 Prompts"})]})}):"skills"===ce&&ue?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(W,{data:ue,onCommand:fe})}):"files"===ce&&e.folderPath?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(B,{projectPath:e.folderPath,onSelect:ge})}):null,o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-t border-border shrink-0",children:[o.jsx("button",{onClick:()=>{be()},title:"斜杠命令",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","skills"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:"/"}),o.jsx("button",{onClick:()=>de(e=>"files"===e?null:"files"),disabled:!e.folderPath,title:"引用文件",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","files"===ce?"bg-accent text-foreground font-medium":e.folderPath?"text-muted-foreground active:bg-accent":"text-muted-foreground/30 cursor-not-allowed"),children:"@"}),te.length>0&&o.jsxs("button",{onClick:()=>de(e=>"global"===e?null:"global"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","global"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(V,{className:"h-3 w-3"}),"全局","global"===ce&&o.jsx(re,{className:"h-3 w-3"})]}),ae.length>0&&o.jsxs("button",{onClick:()=>de(e=>"project"===e?null:"project"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","project"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(le,{className:"h-3 w-3"}),"项目","project"===ce&&o.jsx(re,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"border-t border-border px-3 py-2 shrink-0",style:{paddingBottom:"max(0.5rem, env(safe-area-inset-bottom))"},children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{ref:i,value:r,onChange:e=>l(e.target.value),onKeyDown:ke,disabled:Y||ye,placeholder:Y?"启动中...":ye?"发送中…":"stopped"===O?"输入消息(自动启动)...":"输入消息...",rows:1,className:d("flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none","focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50","max-h-32 overflow-y-auto",(Y||ye)&&"opacity-50 cursor-not-allowed"),style:{minHeight:"2.5rem"},onInput:e=>{const t=e.currentTarget;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"}}),o.jsx("button",{onClick:we,disabled:Y||ye||!r.trim(),className:d("shrink-0 p-2 rounded-md transition-colors",r.trim()&&!ye?"text-blue-500 active:bg-blue-500/10":"text-muted-foreground/30"),children:ye?o.jsx(k,{className:"h-5 w-5 animate-spin"}):o.jsx(C,{className:"h-5 w-5"})})]})})]})}const he=U.lazy(()=>T(()=>import("./OfficePreview-k40TguA5.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.OfficePreview}))),pe=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),fe=new Set(["docx","xlsx","xls","pptx"]),ge={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function be(e){return e.split("/").pop()??e}function je({filePath:e,onBack:t}){const[s,a]=n.useState(null),[r,l]=n.useState(!0),[c,i]=n.useState(null),{resolved:d}=S(),u=function(e){const t=e.split("/").pop()??"",s=t.toLowerCase();if("dockerfile"===s)return"dockerfile";if("makefile"===s)return"makefile";const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}(e),x=pe.has(u),m=fe.has(u),h=ge[u],p="dark"===d;n.useEffect(()=>{x||m?l(!1):(l(!0),i(null),I(e).then(a).catch(e=>i(e instanceof Error?e.message:"Failed to load")).finally(()=>l(!1)))},[e,x,m]);const f=M(e),g=n.useMemo(()=>{const e=P();return e?`${f}&token=${encodeURIComponent(e)}`:f},[f]),b=n.useMemo(()=>x?`${g}&t=${Date.now()}`:"",[g,x]);return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:be(e)}),o.jsx("a",{href:g,download:!0,className:"text-muted-foreground active:text-foreground p-1",onClick:e=>e.stopPropagation(),children:o.jsx(z,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[r&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&o.jsx("div",{className:"text-center text-destructive text-sm py-12 px-4",children:c}),x&&o.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:o.jsx("img",{src:b,alt:be(e),className:"max-w-full max-h-full object-contain rounded",style:{touchAction:"pinch-zoom"}})}),m&&o.jsx(n.Suspense,{fallback:o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),children:o.jsx(he,{filePath:e,ext:u,zoom:100})}),s&&(s.binary||s.tooLarge)&&o.jsxs("div",{className:"text-center py-12 px-4 space-y-3",children:[o.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.binary?"二进制文件":"文件过大",s.size>0&&` (${j=s.size,j<1024?`${j} B`:j<1048576?`${(j/1024).toFixed(1)} KB`:`${(j/1048576).toFixed(1)} MB`})`]}),o.jsxs("a",{href:g,download:!0,className:"inline-flex items-center gap-1.5 text-sm text-blue-500 active:text-blue-400",children:[o.jsx(z,{className:"h-4 w-4"}),"下载文件"]})]}),s&&!s.binary&&!s.tooLarge&&null!=s.content&&o.jsxs(o.Fragment,{children:["md"===u&&o.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3",children:o.jsx(K,{remarkPlugins:[G,Q],rehypePlugins:[J],urlTransform:(e,t,s)=>"src"===t&&"img"===s.tagName?e:Y(e),components:{img:({src:t,alt:s,...a})=>o.jsx("img",{...a,src:X(e,t,P()),alt:s??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:s.content})}),"md"!==u&&h&&o.jsx(Z,{language:h,style:p?ee:te,customStyle:{margin:0,fontSize:"12px",borderRadius:0},showLineNumbers:!0,children:s.content}),"md"!==u&&!h&&o.jsx("pre",{className:"p-4 text-xs font-mono whitespace-pre-wrap break-words",children:s.content})]})]})]});var j}const ve=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),ye=new Set(["js","jsx","ts","tsx","py","rb","go","rs","java","c","cpp","h","swift","kt","cs","php","sh","bash","zsh","r","lua","dart","zig","css","scss","less","html","htm","xml","sql"]),Ne=new Set(["json","yaml","yml","toml","csv","tsv"]);function we({entry:e}){if("dir"===e.type)return o.jsx(D,{className:"h-8 w-8 text-blue-400"});const t=function(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}(e.name);return ve.has(t)?o.jsx(se,{className:"h-8 w-8 text-emerald-400"}):ye.has(t)?o.jsx(oe,{className:"h-8 w-8 text-orange-400"}):Ne.has(t)?o.jsx(ce,{className:"h-8 w-8 text-yellow-400"}):"md"===t?o.jsx(ae,{className:"h-8 w-8 text-sky-400"}):o.jsx(E,{className:"h-8 w-8 text-muted-foreground"})}function ke({rootPath:e,onClose:t}){const[s,a]=n.useState(e),[r,l]=n.useState([]),[c,i]=n.useState(!0),[d,u]=n.useState(null),x=n.useCallback(async e=>{i(!0);try{const t=[...(await $(e)).entries].sort((e,t)=>e.type!==t.type?"dir"===e.type?-1:1:e.name.localeCompare(t.name));l(t),a(e)}catch{l([])}finally{i(!1)}},[]);n.useEffect(()=>{x(e)},[e,x]);const m=s!==e,h=s.startsWith(e)?s.slice(e.length)||"/":s;return d?o.jsx(je,{filePath:d,onBack:()=>u(null)}):o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(R,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0 text-sm",children:[m&&o.jsx("button",{onClick:()=>{if(s===e)return;const t=s.replace(/\/[^/]+$/,"")||"/";t.startsWith(e)&&x(t)},className:"text-muted-foreground active:text-foreground p-0.5 shrink-0",children:o.jsx(w,{className:"h-4 w-4"})}),o.jsx("span",{className:"truncate text-muted-foreground font-mono text-xs",children:h})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!c&&0===r.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"空目录"}),!c&&o.jsx("div",{className:"grid grid-cols-3 gap-1",children:r.map(e=>o.jsxs("button",{onClick:()=>(e=>{"dir"===e.type?x(e.path):u(e.path)})(e),className:"flex flex-col items-center gap-1 p-2 rounded-md active:bg-accent transition-colors",children:[o.jsx(we,{entry:e}),o.jsx("span",{className:"text-[11px] text-center leading-tight w-full line-clamp-2 break-all",children:e.name})]},e.path))})]})]})}function Ce(e){return e<50?"text-green-400":e<80?"text-yellow-400":"text-red-400"}function Se(e){return e<50?"bg-green-500":e<80?"bg-yellow-500":"bg-red-500"}function Ie({projectName:e,cliTool:t,folderPath:s,contextData:a,onClose:r}){const[l,c]=n.useState(new Set(["context","usage","files"])),[u,x]=n.useState(null),[m,h]=n.useState(!1),p=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};n.useEffect(()=>{h(!0),A(t).then(x).catch(()=>x(null)).finally(()=>h(!1))},[t]);const f=a?Math.round(a.usedPercentage):null;return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:r,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(R,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 font-medium text-sm truncate",children:e})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsxs("button",{onClick:()=>p("context"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("context")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"上下文"}),null!==f&&o.jsxs("span",{className:d("text-xs font-mono ml-auto",Ce(f)),children:[f,"%"]})]}),l.has("context")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:null!==f&&a?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-2 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full transition-all",Se(f)),style:{width:`${Math.min(f,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-10 text-right",Ce(f)),children:[f,"%"]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsx("span",{children:"窗口大小"}),o.jsx("span",{className:"text-right font-mono",children:a.contextWindowSize>=1e6?`${(a.contextWindowSize/1e6).toFixed(1)}M`:`${Math.round(a.contextWindowSize/1e3)}K`}),o.jsx("span",{children:"输入 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.inputTokens.toLocaleString()}),o.jsx("span",{children:"输出 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.outputTokens.toLocaleString()})]})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:"暂无数据"})}),o.jsxs("div",{className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 cursor-pointer",role:"button",tabIndex:0,onClick:()=>p("usage"),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||p("usage")},children:[l.has("usage")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"用量"}),o.jsx("button",{onClick:e=>{e.stopPropagation(),(async()=>{h(!0);try{const{refreshUsage:e}=await T(async()=>{const{refreshUsage:e}=await import("./index-Dyb7Lej-.js").then(e=>e.bO);return{refreshUsage:e}},__vite__mapDeps([1,2]));x(await e(t))}catch{}finally{h(!1)}})()},className:"ml-auto text-muted-foreground active:text-foreground",children:o.jsx(i,{className:d("h-3 w-3",m&&"animate-spin")})})]}),l.has("usage")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:u?o.jsxs("div",{className:"space-y-2",children:[u.planName&&o.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Plan: ",o.jsx("span",{className:"font-medium text-foreground",children:u.planName})]}),o.jsx(Pe,{label:"5h",bucket:u.fiveHour}),o.jsx(Pe,{label:"7d",bucket:u.sevenDay}),u.sevenDaySonnet&&o.jsx(Pe,{label:"7d Sonnet",bucket:u.sevenDaySonnet}),u.sevenDayOpus&&o.jsx(Pe,{label:"7d Opus",bucket:u.sevenDayOpus}),!u.fiveHour&&!u.sevenDay&&o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center",children:"暂无数据"})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:m?"加载中...":"暂无数据"})}),o.jsxs("button",{onClick:()=>p("files"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("files")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"文件"})]}),l.has("files")&&o.jsx("div",{className:"h-[60vh]",children:o.jsx(ke,{rootPath:s,onClose:()=>p("files")})})]})]})}function Pe({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const s=t.utilization,a=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}h${a}m`:`${a}m`}(t.resetAt);return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground w-16",children:e}),o.jsx("div",{className:"flex-1 h-1.5 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full",Se(s)),style:{width:`${Math.min(s,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-8 text-right",Ce(s)),children:[s,"%"]}),a&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:a})]})}function ze(){n.useEffect(()=>{const e=document.querySelector('meta[name="viewport"]');if(!e)return;const t=e.getAttribute("content")??"";return e.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),()=>{e.setAttribute("content",t)}},[]);const[e,t]=n.useState({screen:"list"}),[s,r]=n.useState(null),l=a(e=>e.projects),c=n.useCallback(e=>{t({screen:"chat",projectId:e}),r(null)},[]),i=n.useCallback(e=>{t({screen:"panel",projectId:e})},[]),d=n.useCallback(()=>{t(e=>"panel"===e.screen?{screen:"chat",projectId:e.projectId}:{screen:"list"})},[]),u="list"!==e.screen?l.find(t=>t.id===e.projectId):void 0;return o.jsxs("div",{className:"fixed inset-0 bg-background overflow-hidden",children:[o.jsxs(H,{mode:"wait",children:["list"===e.screen&&o.jsx(O.div,{className:"absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{x:"-30%",opacity:0},transition:{duration:.2},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(ue,{onSelectProject:c})},"list"),"chat"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(me,{project:u,onBack:d,onOpenPanel:()=>i(e.projectId),onContextUpdate:r})},`chat-${e.projectId}`)]}),o.jsx(H,{children:"panel"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0 z-50 bg-background",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(Ie,{projectName:u.name,cliTool:u.cliTool??"claude",folderPath:u.folderPath,contextData:s,onClose:d})},"panel")})]})}export{ze as MobilePage};
|
|
14
|
+
*/function ue({onSelectProject:e}){const h=t(),p=s(e=>e.clearToken),{projects:f,fetchProjects:g,hasFetched:b,loading:j}=a(),v=n.useCallback(()=>{a.getState().setProjects([]),p(),h("/login")},[p,h]),[y,N]=n.useState(new Map),[w,k]=n.useState(new Set),[C,S]=n.useState(!1);n.useEffect(()=>{g()},[g]);const I=n.useCallback(e=>{e.status&&N(t=>{const s=new Map(t);return s.set(e.projectId,e.status),s}),void 0!==e.active&&k(t=>{const s=new Set(t);return e.active?s.add(e.projectId):s.delete(e.projectId),s})},[]);r({onActivityUpdate:I});const{applyOrder:P}=l(),z=P(f.filter(e=>!e.archived));return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 h-12 border-b border-border shrink-0",children:[o.jsx("span",{className:"font-semibold text-base flex-1",children:"CC Web"}),o.jsx(c,{}),o.jsx("button",{onClick:()=>{(async()=>{S(!0);try{await g()}finally{S(!1)}})()},className:"text-muted-foreground active:text-foreground",disabled:C,"aria-label":"Refresh",children:o.jsx(i,{className:d("h-4 w-4",C&&"animate-spin")})}),o.jsx("button",{onClick:()=>h("/settings"),className:"text-muted-foreground active:text-foreground","aria-label":"Settings",children:o.jsx(u,{className:"h-4 w-4"})}),o.jsx("button",{onClick:v,className:"text-muted-foreground active:text-foreground","aria-label":"Logout",children:o.jsx(x,{className:"h-4 w-4"})}),!de&&o.jsx("button",{onClick:()=>h("/"),className:"text-muted-foreground active:text-foreground","aria-label":"Desktop mode",children:o.jsx(m,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[j&&!b&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"加载中..."}),b&&0===z.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"暂无项目"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:z.map(t=>{var s;const a="running"===(s=t,y.get(s.id)??s.status??"stopped"),n=w.has(t.id),r=o.jsxs("button",{onClick:()=>e(t.id),className:d("w-full text-left rounded-xl border bg-card p-2.5 active:bg-accent transition-colors",n?"border-transparent":"border-border"),children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",a?"bg-green-500":"bg-zinc-400")}),o.jsx("span",{className:"font-medium text-sm truncate flex-1",children:t.name})]}),o.jsx("div",{className:"text-[10px] text-muted-foreground font-mono truncate",children:t.cliTool??"claude"})]});return o.jsx("div",{className:n?"card-active-glow rounded-xl":void 0,children:r},t.id)})})]})]})}function xe(e){if(!e.phase)return null;if("thinking"===e.phase)return"思考中";if("tool_result"===e.phase)return"处理结果";if("tool_use"===e.phase){const t=(e.detail||"").toLowerCase();return"bash"===t?"执行命令":"read"===t?"读取文件":"edit"===t||"multiedit"===t?"编辑文件":"write"===t?"写入文件":"grep"===t?"搜索内容":"glob"===t?"匹配文件":"webfetch"===t||"websearch"===t?"访问网络":"task"===t?"调度子任务":"todowrite"===t?"更新任务列表":"notebookedit"===t?"编辑 Notebook":e.detail?`调用 ${e.detail}`:"调用工具"}return null}function me({project:e,onBack:t,onOpenPanel:s,onContextUpdate:a}){const[r,l]=n.useState(""),c=n.useRef(null),i=n.useRef(null),[u,x]=n.useState([]),m=n.useCallback(e=>{x(t=>{const s=[...t,e];return s.length>200?s.slice(-200):s})},[]),S=n.useRef(null),I=n.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),[P,z]=n.useState([]),M=n.useRef(new Set),U=n.useCallback(e=>{M.current.has(e.toolUseId)||z(t=>t.some(t=>t.toolUseId===e.toolUseId)?t:[...t,{projectId:e.projectId,toolUseId:e.toolUseId,toolName:e.toolName,toolInput:e.toolInput,sessionId:e.sessionId,createdAt:e.createdAt}])},[]),T=n.useCallback(e=>{M.current.add(e.toolUseId),z(t=>t.filter(t=>t.toolUseId!==e.toolUseId))},[]),$=n.useCallback(e=>{M.current.add(e),z(t=>t.filter(t=>t.toolUseId!==e))},[]),[R,D]=n.useState(null),E=n.useRef(0),A=n.useCallback(e=>{var t,s,a;if(!e.active)return void D(null);if("text"===(null==(t=e.semantic)?void 0:t.phase))return void D(null);const n=null==(s=e.semantic)?void 0:s.phase,r=null==(a=e.semantic)?void 0:a.detail;D(e=>e?e.phase===n&&e.detail===r?e:{...e,phase:n,detail:r}:{id:"mab"+ ++E.current,phase:n,detail:r})},[]),{sendInput:L,connected:H}=h({projectId:e.id,enabled:!0,onChatMessage:m,onStatusChange:I,onContextUpdate:a,onApprovalRequest:U,onApprovalResolved:T,onSemanticUpdate:A});n.useEffect(()=>{if(!H)return;if("claude"!==e.cliTool)return;let t=!1;return p(e.id).then(e=>{if(t)return;const s=e.pending.filter(e=>!M.current.has(e.toolUseId));z(e=>{const t=new Map;for(const a of s)t.set(a.toolUseId,a);for(const s of e)t.has(s.toolUseId)||M.current.has(s.toolUseId)||t.set(s.toolUseId,s);return[...t.values()]})}).catch(()=>{}),()=>{t=!0}},[e.id,e.cliTool,H]);const{state:O,setState:K,messages:J,hasMoreHistory:G,loadMoreHistory:Q,sendMessage:X,isWaking:Y}=f({project:e,liveMessages:u,ws:{send:L,connected:H},historyLimit:20});S.current=K;const Z=n.useRef(H);n.useEffect(()=>{!Z.current&&H&&x([]),Z.current=H},[H]);const ee=(()=>{for(let e=J.length-1;e>=0;e--)if("assistant"===J[e].role)return e;return-1})(),[te,se]=n.useState([]),[ae,oe]=n.useState([]),[ce,de]=n.useState(null),[ue,me]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{g().then(se).catch(()=>{}),b(e.id).then(oe).catch(()=>{})},[e.id]);const pe=n.useCallback(e=>{const t=i.current;if(!t)return void l(t=>t+e);const s=t.selectionStart??r.length,a=t.selectionEnd??r.length,n=r.slice(0,s)+e+r.slice(a);l(n),requestAnimationFrame(()=>{t.focus();const a=s+e.length;t.setSelectionRange(a,a),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"})},[r]),fe=n.useCallback(e=>{de(null),pe(e+" ")},[pe]),ge=n.useCallback(t=>{const s=e.folderPath;let a=t;s&&(t===s||t.startsWith(s+"/")||t.startsWith(s+"\\"))&&(a=t.slice(s.length).replace(/^[/\\]+/,"")),de(null),pe(`@${a} `)},[e.folderPath,pe]),be=n.useCallback(async()=>{if("skills"!==ce){if(!he.current){he.current=!0;try{const t=await j(e.cliTool??"claude",e.id);me(t)}catch{me({builtin:[],custom:[],plugins:[],mcp:[]})}finally{he.current=!1}}de("skills")}else de(null)},[ce,e.cliTool,e.id]),je=n.useCallback(async()=>{const e=c.current,t=(null==e?void 0:e.scrollHeight)??0;await Q(),requestAnimationFrame(()=>{e&&(e.scrollTop+=e.scrollHeight-t)})},[Q]),ve=n.useRef(0);n.useEffect(()=>{const e=c.current;if(!e)return;const t=J.length>ve.current,s=0===ve.current&&J.length>0;ve.current=J.length,s?e.scrollTo({top:e.scrollHeight}):t&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[J,P.length]);const[ye,Ne]=n.useState(!1),we=n.useCallback(async()=>{const e=r.trim();if(!e||ye)return;Ne(!0);const t=await X(e);Ne(!1),"delivered"===t&&(l(""),i.current&&(i.current.style.height="auto"))},[r,ye,X]),ke=v(we,"shift"),Ce=n.useCallback(async(t,s)=>{de(null);try{"failed"===await X(t.command)?y.error("快捷命令未送达,请重试或检查会话"):"project"===s&&N(e.id,t.id,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})}catch(a){console.error("Shortcut send error:",a),y.error("快捷命令发送失败")}},[X,e.id]),Se="live"===O;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[o.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",Se?"bg-green-500":Y?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),o.jsx("button",{onClick:s,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(ie,{className:"h-5 w-5"})})]}),o.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 min-h-0",children:[G&&o.jsx("div",{className:"flex justify-center pb-1",children:o.jsxs("button",{onClick:()=>{je()},className:"flex items-center gap-1 px-3 py-1.5 rounded-full text-xs text-muted-foreground border border-border active:bg-accent transition-colors",children:[o.jsx(ne,{className:"h-3 w-3"}),"加载更早消息"]})}),J.map((e,t)=>{const s="user"===e.role;return o.jsx("div",{className:d("flex",s?"justify-end":"justify-start"),children:o.jsx("div",{className:d("max-w-[85%] rounded-xl px-3 py-2 break-words text-sm leading-relaxed",s?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm whitespace-pre-wrap":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:s?e.content:o.jsx(_,{content:e.content,blocks:e.blocks,isLatest:t===ee})})},e.id)}),P.map(e=>o.jsx(q,{approval:e,onResolved:$},e.toolUseId)),R&&0===P.length&&o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"rounded-2xl rounded-bl-md px-3 py-1.5 bg-black/5 dark:bg-white/10 border border-black/10 dark:border-white/15 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(F,{}),xe(R)&&o.jsx("span",{children:xe(R)})]})},R.id),0===J.length&&0===P.length&&!R&&"stopped"===O&&o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-sm",children:"暂无对话记录"}),Y&&o.jsx("div",{className:"flex items-center justify-center py-4 text-yellow-400 text-sm animate-pulse",children:"启动中..."})]}),"global"===ce||"project"===ce?o.jsx("div",{className:"border-t border-border max-h-48 overflow-y-auto shrink-0",children:o.jsxs("div",{className:"px-3 py-2 space-y-1",children:[("global"===ce?te:ae).map(e=>o.jsxs("button",{onClick:()=>Ce(e,ce),disabled:Y,className:d("w-full text-left rounded-md px-2.5 py-2 text-sm active:bg-accent transition-colors border border-border/50",Y&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:"font-medium text-xs",children:e.label}),o.jsx("div",{className:"text-[11px] text-muted-foreground font-mono truncate",children:e.command})]},e.id)),0===("global"===ce?te:ae).length&&o.jsx("div",{className:"text-center text-muted-foreground text-xs py-3",children:"暂无快捷 Prompts"})]})}):"skills"===ce&&ue?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(W,{data:ue,onCommand:fe})}):"files"===ce&&e.folderPath?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(B,{projectPath:e.folderPath,onSelect:ge})}):null,o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-t border-border shrink-0",children:[o.jsx("button",{onClick:()=>{be()},title:"斜杠命令",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","skills"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:"/"}),o.jsx("button",{onClick:()=>de(e=>"files"===e?null:"files"),disabled:!e.folderPath,title:"引用文件",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","files"===ce?"bg-accent text-foreground font-medium":e.folderPath?"text-muted-foreground active:bg-accent":"text-muted-foreground/30 cursor-not-allowed"),children:"@"}),te.length>0&&o.jsxs("button",{onClick:()=>de(e=>"global"===e?null:"global"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","global"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(V,{className:"h-3 w-3"}),"全局","global"===ce&&o.jsx(re,{className:"h-3 w-3"})]}),ae.length>0&&o.jsxs("button",{onClick:()=>de(e=>"project"===e?null:"project"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","project"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(le,{className:"h-3 w-3"}),"项目","project"===ce&&o.jsx(re,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"border-t border-border px-3 py-2 shrink-0",style:{paddingBottom:"max(0.5rem, env(safe-area-inset-bottom))"},children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{ref:i,value:r,onChange:e=>l(e.target.value),onKeyDown:ke,disabled:Y||ye,placeholder:Y?"启动中...":ye?"发送中…":"stopped"===O?"输入消息(自动启动)...":"输入消息...",rows:1,className:d("flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none","focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50","max-h-32 overflow-y-auto",(Y||ye)&&"opacity-50 cursor-not-allowed"),style:{minHeight:"2.5rem"},onInput:e=>{const t=e.currentTarget;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"}}),o.jsx("button",{onClick:we,disabled:Y||ye||!r.trim(),className:d("shrink-0 p-2 rounded-md transition-colors",r.trim()&&!ye?"text-blue-500 active:bg-blue-500/10":"text-muted-foreground/30"),children:ye?o.jsx(k,{className:"h-5 w-5 animate-spin"}):o.jsx(C,{className:"h-5 w-5"})})]})})]})}const he=U.lazy(()=>T(()=>import("./OfficePreview-CyzAoUZx.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.OfficePreview}))),pe=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),fe=new Set(["docx","xlsx","xls","pptx"]),ge={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function be(e){return e.split("/").pop()??e}function je({filePath:e,onBack:t}){const[s,a]=n.useState(null),[r,l]=n.useState(!0),[c,i]=n.useState(null),{resolved:d}=S(),u=function(e){const t=e.split("/").pop()??"",s=t.toLowerCase();if("dockerfile"===s)return"dockerfile";if("makefile"===s)return"makefile";const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}(e),x=pe.has(u),m=fe.has(u),h=ge[u],p="dark"===d;n.useEffect(()=>{x||m?l(!1):(l(!0),i(null),I(e).then(a).catch(e=>i(e instanceof Error?e.message:"Failed to load")).finally(()=>l(!1)))},[e,x,m]);const f=M(e),g=n.useMemo(()=>{const e=P();return e?`${f}&token=${encodeURIComponent(e)}`:f},[f]),b=n.useMemo(()=>x?`${g}&t=${Date.now()}`:"",[g,x]);return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:be(e)}),o.jsx("a",{href:g,download:!0,className:"text-muted-foreground active:text-foreground p-1",onClick:e=>e.stopPropagation(),children:o.jsx(z,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[r&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&o.jsx("div",{className:"text-center text-destructive text-sm py-12 px-4",children:c}),x&&o.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:o.jsx("img",{src:b,alt:be(e),className:"max-w-full max-h-full object-contain rounded",style:{touchAction:"pinch-zoom"}})}),m&&o.jsx(n.Suspense,{fallback:o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),children:o.jsx(he,{filePath:e,ext:u,zoom:100})}),s&&(s.binary||s.tooLarge)&&o.jsxs("div",{className:"text-center py-12 px-4 space-y-3",children:[o.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.binary?"二进制文件":"文件过大",s.size>0&&` (${j=s.size,j<1024?`${j} B`:j<1048576?`${(j/1024).toFixed(1)} KB`:`${(j/1048576).toFixed(1)} MB`})`]}),o.jsxs("a",{href:g,download:!0,className:"inline-flex items-center gap-1.5 text-sm text-blue-500 active:text-blue-400",children:[o.jsx(z,{className:"h-4 w-4"}),"下载文件"]})]}),s&&!s.binary&&!s.tooLarge&&null!=s.content&&o.jsxs(o.Fragment,{children:["md"===u&&o.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3",children:o.jsx(K,{remarkPlugins:[G,Q],rehypePlugins:[J],urlTransform:(e,t,s)=>"src"===t&&"img"===s.tagName?e:Y(e),components:{img:({src:t,alt:s,...a})=>o.jsx("img",{...a,src:X(e,t,P()),alt:s??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:s.content})}),"md"!==u&&h&&o.jsx(Z,{language:h,style:p?ee:te,customStyle:{margin:0,fontSize:"12px",borderRadius:0},showLineNumbers:!0,children:s.content}),"md"!==u&&!h&&o.jsx("pre",{className:"p-4 text-xs font-mono whitespace-pre-wrap break-words",children:s.content})]})]})]});var j}const ve=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),ye=new Set(["js","jsx","ts","tsx","py","rb","go","rs","java","c","cpp","h","swift","kt","cs","php","sh","bash","zsh","r","lua","dart","zig","css","scss","less","html","htm","xml","sql"]),Ne=new Set(["json","yaml","yml","toml","csv","tsv"]);function we({entry:e}){if("dir"===e.type)return o.jsx(D,{className:"h-8 w-8 text-blue-400"});const t=function(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}(e.name);return ve.has(t)?o.jsx(se,{className:"h-8 w-8 text-emerald-400"}):ye.has(t)?o.jsx(oe,{className:"h-8 w-8 text-orange-400"}):Ne.has(t)?o.jsx(ce,{className:"h-8 w-8 text-yellow-400"}):"md"===t?o.jsx(ae,{className:"h-8 w-8 text-sky-400"}):o.jsx(E,{className:"h-8 w-8 text-muted-foreground"})}function ke({rootPath:e,onClose:t}){const[s,a]=n.useState(e),[r,l]=n.useState([]),[c,i]=n.useState(!0),[d,u]=n.useState(null),x=n.useCallback(async e=>{i(!0);try{const t=[...(await $(e)).entries].sort((e,t)=>e.type!==t.type?"dir"===e.type?-1:1:e.name.localeCompare(t.name));l(t),a(e)}catch{l([])}finally{i(!1)}},[]);n.useEffect(()=>{x(e)},[e,x]);const m=s!==e,h=s.startsWith(e)?s.slice(e.length)||"/":s;return d?o.jsx(je,{filePath:d,onBack:()=>u(null)}):o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(R,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0 text-sm",children:[m&&o.jsx("button",{onClick:()=>{if(s===e)return;const t=s.replace(/\/[^/]+$/,"")||"/";t.startsWith(e)&&x(t)},className:"text-muted-foreground active:text-foreground p-0.5 shrink-0",children:o.jsx(w,{className:"h-4 w-4"})}),o.jsx("span",{className:"truncate text-muted-foreground font-mono text-xs",children:h})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!c&&0===r.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"空目录"}),!c&&o.jsx("div",{className:"grid grid-cols-3 gap-1",children:r.map(e=>o.jsxs("button",{onClick:()=>(e=>{"dir"===e.type?x(e.path):u(e.path)})(e),className:"flex flex-col items-center gap-1 p-2 rounded-md active:bg-accent transition-colors",children:[o.jsx(we,{entry:e}),o.jsx("span",{className:"text-[11px] text-center leading-tight w-full line-clamp-2 break-all",children:e.name})]},e.path))})]})]})}function Ce(e){return e<50?"text-green-400":e<80?"text-yellow-400":"text-red-400"}function Se(e){return e<50?"bg-green-500":e<80?"bg-yellow-500":"bg-red-500"}function Ie({projectName:e,cliTool:t,folderPath:s,contextData:a,onClose:r}){const[l,c]=n.useState(new Set(["context","usage","files"])),[u,x]=n.useState(null),[m,h]=n.useState(!1),p=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};n.useEffect(()=>{h(!0),A(t).then(x).catch(()=>x(null)).finally(()=>h(!1))},[t]);const f=a?Math.round(a.usedPercentage):null;return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:r,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(R,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 font-medium text-sm truncate",children:e})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsxs("button",{onClick:()=>p("context"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("context")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"上下文"}),null!==f&&o.jsxs("span",{className:d("text-xs font-mono ml-auto",Ce(f)),children:[f,"%"]})]}),l.has("context")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:null!==f&&a?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-2 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full transition-all",Se(f)),style:{width:`${Math.min(f,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-10 text-right",Ce(f)),children:[f,"%"]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsx("span",{children:"窗口大小"}),o.jsx("span",{className:"text-right font-mono",children:a.contextWindowSize>=1e6?`${(a.contextWindowSize/1e6).toFixed(1)}M`:`${Math.round(a.contextWindowSize/1e3)}K`}),o.jsx("span",{children:"输入 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.inputTokens.toLocaleString()}),o.jsx("span",{children:"输出 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.outputTokens.toLocaleString()})]})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:"暂无数据"})}),o.jsxs("div",{className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 cursor-pointer",role:"button",tabIndex:0,onClick:()=>p("usage"),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||p("usage")},children:[l.has("usage")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"用量"}),o.jsx("button",{onClick:e=>{e.stopPropagation(),(async()=>{h(!0);try{const{refreshUsage:e}=await T(async()=>{const{refreshUsage:e}=await import("./index-P75DiJki.js").then(e=>e.bO);return{refreshUsage:e}},__vite__mapDeps([1,2]));x(await e(t))}catch{}finally{h(!1)}})()},className:"ml-auto text-muted-foreground active:text-foreground",children:o.jsx(i,{className:d("h-3 w-3",m&&"animate-spin")})})]}),l.has("usage")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:u?o.jsxs("div",{className:"space-y-2",children:[u.planName&&o.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Plan: ",o.jsx("span",{className:"font-medium text-foreground",children:u.planName})]}),o.jsx(Pe,{label:"5h",bucket:u.fiveHour}),o.jsx(Pe,{label:"7d",bucket:u.sevenDay}),u.sevenDaySonnet&&o.jsx(Pe,{label:"7d Sonnet",bucket:u.sevenDaySonnet}),u.sevenDayOpus&&o.jsx(Pe,{label:"7d Opus",bucket:u.sevenDayOpus}),!u.fiveHour&&!u.sevenDay&&o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center",children:"暂无数据"})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:m?"加载中...":"暂无数据"})}),o.jsxs("button",{onClick:()=>p("files"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("files")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"文件"})]}),l.has("files")&&o.jsx("div",{className:"h-[60vh]",children:o.jsx(ke,{rootPath:s,onClose:()=>p("files")})})]})]})}function Pe({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const s=t.utilization,a=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}h${a}m`:`${a}m`}(t.resetAt);return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground w-16",children:e}),o.jsx("div",{className:"flex-1 h-1.5 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full",Se(s)),style:{width:`${Math.min(s,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-8 text-right",Ce(s)),children:[s,"%"]}),a&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:a})]})}function ze(){n.useEffect(()=>{const e=document.querySelector('meta[name="viewport"]');if(!e)return;const t=e.getAttribute("content")??"";return e.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),()=>{e.setAttribute("content",t)}},[]);const[e,t]=n.useState({screen:"list"}),[s,r]=n.useState(null),l=a(e=>e.projects),c=n.useCallback(e=>{t({screen:"chat",projectId:e}),r(null)},[]),i=n.useCallback(e=>{t({screen:"panel",projectId:e})},[]),d=n.useCallback(()=>{t(e=>"panel"===e.screen?{screen:"chat",projectId:e.projectId}:{screen:"list"})},[]),u="list"!==e.screen?l.find(t=>t.id===e.projectId):void 0;return o.jsxs("div",{className:"fixed inset-0 bg-background overflow-hidden",children:[o.jsxs(H,{mode:"wait",children:["list"===e.screen&&o.jsx(O.div,{className:"absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{x:"-30%",opacity:0},transition:{duration:.2},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(ue,{onSelectProject:c})},"list"),"chat"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(me,{project:u,onBack:d,onOpenPanel:()=>i(e.projectId),onContextUpdate:r})},`chat-${e.projectId}`)]}),o.jsx(H,{children:"panel"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0 z-50 bg-background",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(Ie,{projectName:u.name,cliTool:u.cliTool??"claude",folderPath:u.folderPath,contextData:s,onClose:d})},"panel")})]})}export{ze as MobilePage};
|