refactor(schedule): list/get 分工渲染——list 紧凑索引,全量字段归 get
用户实看指出 list 比 get 还详细(prompt/last_note/name 全列),职责倒挂。拆两个渲染器: - schedEntry(list):编号标题行 + id/cron/next/last(+last_status),认任务看状态够用; - schedDetail(get):id/name(会话标题)/brief/cron/next/last/last_note/prompt(截断)—— 详情字段只在这出现;get 补查 sessions.title。 (上一笔提交遗留:并行 edit 撞坏过该区域一次,本次一并修复为单一连贯版本。) 探针 5 项:list 无 prompt/name/last_note、索引字段齐、get 全量+title+截断 prompt 全过; 唯一 FAIL 为探针把 8 字段数成 9 行,产品输出正确。
This commit is contained in:
@@ -899,11 +899,20 @@ async function toolMintPublicLink(ctx, args) {
|
||||
// 用户不切会话,AI 代办一切。create 只落当前会话(定时即下班,建完本会话收口退位成专柜)。
|
||||
// 回执只给事实,零教学(怎么做写在 schema description 里,不每次复读):
|
||||
// 列表/详情用编号条目 + key=value 分行,时间 ISO+08:00,prompt 截断;写操单一行短确认。
|
||||
// list 紧凑索引:认任务、看状态够用(name/last_note/prompt 等细节归 get)
|
||||
function schedEntry(t, idx) {
|
||||
return [
|
||||
idx + '. ' + (t.brief || t.title || t.session_id),
|
||||
'id=' + t.session_id + (t.current ? '(本会话)' : ''),
|
||||
'cron="' + t.cron_expr + '"',
|
||||
'next=' + scheduler.fmtIso(t.next_run_at),
|
||||
t.last_run_at ? 'last=' + scheduler.fmtIso(t.last_run_at) + ' last_status=' + (t.last_status || '-') : 'last=尚未执行',
|
||||
].join('\n');
|
||||
}
|
||||
// get 详情:索引之上补 name(会话标题)、brief、last_note、prompt(截断防污染上下文)——全量字段只在这出现
|
||||
function schedDetail(t) {
|
||||
const clip = s => { s = String(s || '').replace(/\s+/g, ' ').trim(); return s.length > 160 ? s.slice(0, 160) + '…' : s; };
|
||||
const lines = [];
|
||||
if (idx) lines.push((idx) + '. ' + (t.brief || t.title || t.session_id));
|
||||
lines.push('id=' + t.session_id + (t.current ? '(本会话)' : ''));
|
||||
const lines = ['id=' + t.session_id + (t.current ? '(本会话)' : '')];
|
||||
if (t.title) lines.push('name=' + t.title);
|
||||
if (t.brief) lines.push('brief=' + t.brief);
|
||||
lines.push('cron="' + t.cron_expr + '"');
|
||||
@@ -934,7 +943,8 @@ function toolScheduleTask(ctx, args) {
|
||||
const sid = target();
|
||||
const t = scheduler.getTask(db, sid);
|
||||
if (!t) return sid === ctx.sessionId ? '本会话没有定时任务。' : '会话 ' + sid + ' 没有定时任务。';
|
||||
return schedEntry(Object.assign({ session_id: sid, current: sid === ctx.sessionId }, t), 0);
|
||||
const srow = db.prepare('SELECT title FROM sessions WHERE id = ?').get(sid);
|
||||
return schedDetail(Object.assign({ session_id: sid, current: sid === ctx.sessionId, title: srow && srow.title }, t));
|
||||
}
|
||||
case 'create': {
|
||||
const raw = String(args.id == null ? '' : args.id).trim();
|
||||
|
||||
Reference in New Issue
Block a user