调用出错的工具需要显示红色
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192.png">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<style>
|
||||
/* 每条消息的「删除本条」X:仅在 config.yml 的 log_level: debug 时才显示
|
||||
(debug 之外的等级一律隐藏;切换需重启服务生效,与其他配置一致)。
|
||||
放在 link 之后以保证同优先级下能压住 style.css 里 .msg-actions .act { display:flex }。 */
|
||||
body .msg-actions .act-del { display: none; }
|
||||
body.log-debug .msg-actions .act-del { display: flex; }
|
||||
</style>
|
||||
<script>
|
||||
// 注册 Service Worker(PWA / 离线缓存)
|
||||
if ('serviceWorker' in navigator) {
|
||||
@@ -626,7 +633,7 @@
|
||||
const node = msgNode(m);
|
||||
if (node) box.insertAdjacentHTML('beforeend', node);
|
||||
if (m.role === 'assistant') appendToolCardsFromAssistant(m, box);
|
||||
else if (m.role === 'tool' && m.tool_call_id) fillToolResult(m.tool_call_id, m.content, false, undefined, m.id);
|
||||
else if (m.role === 'tool' && m.tool_call_id) fillToolResult(m.tool_call_id, m.content, !!m.is_error, undefined, m.id);
|
||||
}
|
||||
if (!(detail.messages || []).length) {
|
||||
box.innerHTML = '<div class="drawer-empty">描述你的需求,AI 会和你讨论并直接干活。</div>';
|
||||
@@ -2987,12 +2994,22 @@
|
||||
mToggleEnable: toggleModelEnable,
|
||||
};
|
||||
|
||||
// 启动时拉一次 config,根据 log_level 决定是否给 body 加 log-debug 类;
|
||||
// 配项改后需重启服务,这里只在首屏拉一次即可(失败静默,默认隐藏删除 X)
|
||||
async function applyDebugDeleteFlag() {
|
||||
try {
|
||||
const cg = await req('GET', '/api/config');
|
||||
document.body.classList.toggle('log-debug', (cg && cg.effective && cg.effective.log_level) === 'debug');
|
||||
} catch (_) { /* 未登录/失败时保持默认隐藏 */ }
|
||||
}
|
||||
|
||||
// ---------- 初始化 ----------
|
||||
bindChatScroll(); // 聊天区滚动跟随/右下角回底按钮(只绑一次)
|
||||
selectMode('secretary'); // 默认选中【文秘助理】
|
||||
setView('welcome');
|
||||
loadSessionList();
|
||||
loadDrawerUser(); // 侧边栏底部展示真实登录用户(未启用认证时静默回退默认占位)
|
||||
applyDebugDeleteFlag(); // 仅 log_level: debug 才在每条消息后显示删除 X
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user