claude-opencode-viewer 2.6.32 → 2.6.33
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/index-pc.html +1 -1
- package/index.html +1 -1
- package/package.json +1 -1
- package/server.js +45 -14
package/index-pc.html
CHANGED
|
@@ -961,7 +961,7 @@
|
|
|
961
961
|
var isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
962
962
|
var MOBILE_COLS = 60;
|
|
963
963
|
var fontSize = isMobile ? 11 : 13;
|
|
964
|
-
var currentMode = '
|
|
964
|
+
var currentMode = 'claude';
|
|
965
965
|
var isTransitioning = false;
|
|
966
966
|
var isBufferReplay = true; // 初始缓冲区回放中,不弹 toast
|
|
967
967
|
|
package/index.html
CHANGED
|
@@ -1050,7 +1050,7 @@
|
|
|
1050
1050
|
var isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
1051
1051
|
var MOBILE_COLS = 60;
|
|
1052
1052
|
var fontSize = isMobile ? 11 : 13;
|
|
1053
|
-
var currentMode = '
|
|
1053
|
+
var currentMode = 'claude';
|
|
1054
1054
|
var isTransitioning = false;
|
|
1055
1055
|
|
|
1056
1056
|
var term = new Terminal({
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -102,7 +102,7 @@ let sessionStartTime = 0; // 新会话启动时间,用于限制查询范围
|
|
|
102
102
|
let previousSessionId = null; // 用于判断新会话是否已写入 DB
|
|
103
103
|
const clientSizes = new Map();
|
|
104
104
|
const mobileClients = new Set();
|
|
105
|
-
let currentMode = '
|
|
105
|
+
let currentMode = 'claude';
|
|
106
106
|
let isSwitching = false; // 模式切换/恢复会话中,忽略旧进程退出事件
|
|
107
107
|
|
|
108
108
|
function getMobileSize() {
|
|
@@ -1298,21 +1298,52 @@ function startServer() {
|
|
|
1298
1298
|
cleanupOrphanProcesses();
|
|
1299
1299
|
|
|
1300
1300
|
// 尝试恢复最近的会话,如果没有则新建
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1301
|
+
if (currentMode === 'opencode') {
|
|
1302
|
+
let lastSessionId = null;
|
|
1303
|
+
try {
|
|
1304
|
+
const db = new Database(OPENCODE_DB_PATH, { readonly: true });
|
|
1305
|
+
const row = db.prepare(
|
|
1306
|
+
`SELECT id FROM session WHERE parent_id IS NULL AND time_archived IS NULL ORDER BY time_updated DESC LIMIT 1`
|
|
1307
|
+
).get();
|
|
1308
|
+
db.close();
|
|
1309
|
+
if (row) lastSessionId = row.id;
|
|
1310
|
+
} catch (e) {}
|
|
1310
1311
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1312
|
+
if (lastSessionId) {
|
|
1313
|
+
LOG(`[startup] 恢复最近会话: ${lastSessionId}`);
|
|
1314
|
+
await spawnProcess('opencode', lastSessionId);
|
|
1315
|
+
} else {
|
|
1316
|
+
await spawnProcess('opencode');
|
|
1317
|
+
}
|
|
1314
1318
|
} else {
|
|
1315
|
-
|
|
1319
|
+
// Claude 模式:找最近的会话恢复
|
|
1320
|
+
let lastClaudeSession = null;
|
|
1321
|
+
try {
|
|
1322
|
+
const projectsDir = join(CLAUDE_HOME, 'projects');
|
|
1323
|
+
if (existsSync(projectsDir)) {
|
|
1324
|
+
let newest = 0;
|
|
1325
|
+
for (const projDir of readdirSync(projectsDir, { withFileTypes: true })) {
|
|
1326
|
+
if (!projDir.isDirectory()) continue;
|
|
1327
|
+
const projPath = join(projectsDir, projDir.name);
|
|
1328
|
+
for (const f of readdirSync(projPath)) {
|
|
1329
|
+
if (!f.endsWith('.jsonl')) continue;
|
|
1330
|
+
try {
|
|
1331
|
+
const st = statSync(join(projPath, f));
|
|
1332
|
+
if (st.mtimeMs > newest) {
|
|
1333
|
+
newest = st.mtimeMs;
|
|
1334
|
+
lastClaudeSession = f.replace('.jsonl', '');
|
|
1335
|
+
}
|
|
1336
|
+
} catch {}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
} catch {}
|
|
1341
|
+
if (lastClaudeSession) {
|
|
1342
|
+
LOG(`[startup] 恢复最近Claude会话: ${lastClaudeSession}`);
|
|
1343
|
+
await spawnProcess('claude', lastClaudeSession);
|
|
1344
|
+
} else {
|
|
1345
|
+
await spawnProcess('claude');
|
|
1346
|
+
}
|
|
1316
1347
|
}
|
|
1317
1348
|
|
|
1318
1349
|
// 启动首次连接超时检测(3分钟无人连接则退出)
|