From 49b501da1d783ffea08f6c0b43e1502178f7d117 Mon Sep 17 00:00:00 2001 From: kicer Date: Sat, 5 Sep 2026 10:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=87=BA=E9=94=99=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=9C=80=E8=A6=81=E6=98=BE=E7=A4=BA=E7=BA=A2?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/db.js | 3 +++ app/server/public/index.html | 19 ++++++++++++++++++- app/server/routes/sessions.js | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/server/db.js b/app/server/db.js index 8d19695..a8c8cb8 100644 --- a/app/server/db.js +++ b/app/server/db.js @@ -35,6 +35,7 @@ function initDb(dbPath) { tool_calls TEXT, tool_call_id TEXT, name TEXT, + is_error INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL, FOREIGN KEY (session_id) REFERENCES sessions(id) ); @@ -44,6 +45,8 @@ function initDb(dbPath) { // 升级老库:type 标记特殊消息行。目前唯一取值 'errAck'——AI 的 tool call 参数错误 // (JSON 非法/缺必填)整条标记;仍入库供 UI 展示,但 buildMessages 发请求时跳过(见 llm.js) try { db.exec('ALTER TABLE messages ADD COLUMN type TEXT'); } catch (_) { /* 已存在 */ } + // 升级老库:tool 回执执行失败标记。此前只走 SSE 不落库,重进会话后 UI 丢失红色错误样式 + try { db.exec('ALTER TABLE messages ADD COLUMN is_error INTEGER NOT NULL DEFAULT 0'); } catch (_) { /* 已存在 */ } db.exec(` CREATE TABLE IF NOT EXISTS files ( diff --git a/app/server/public/index.html b/app/server/public/index.html index e72e8d5..f3d9737 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -13,6 +13,13 @@ + diff --git a/app/server/routes/sessions.js b/app/server/routes/sessions.js index 5faa836..f375066 100644 --- a/app/server/routes/sessions.js +++ b/app/server/routes/sessions.js @@ -126,7 +126,7 @@ router.get('/:id', wrap((req, res) => { const session = engine.getSession(req.params.id); if (!session) return sendErr(res, Object.assign(new Error('会话不存在'), { status_code: 404 })); const db = engine.getDb(); - const messages = db.prepare('SELECT id, role, content, reasoning, tool_calls, tool_call_id, name, created_at FROM messages WHERE session_id = ? ORDER BY id').all(session.id); + const messages = db.prepare('SELECT id, role, content, reasoning, tool_calls, tool_call_id, name, type, is_error, created_at FROM messages WHERE session_id = ? ORDER BY id').all(session.id); const taskDir = engine.taskDirOf(session.id); res.json({ session,