Repository navigation
feat: 定时任务按需提醒,并可配置应用内与社交平台提醒 - #1736
Merged
Merged
Conversation
Schedules gain notify_policy (important by default, also for existing schedules) and contact_via_channels (on by default). attention_kind gains update, and schedule run sessions become eligible for unread attention. Refs MEMOH-256
notify_user registers only in a schedule fire whose schedule tells its owner on request, and raises an update once per fire. A scheduled run that completes without it raises no reply under the important policy; failures and decisions still reach the owner. Turning channel contact off adds one note to the trigger prompt; with it on the prompt reads as before. Refs MEMOH-256
Refs MEMOH-256
…lls you The schedule form gains a Notifications section: notify in Memoh only when the run needs you (default) or after every run, and whether the bot may reach you on its configured platforms, with the platforms it is on and a link to set them up. Needs you folds one schedule's unread runs into a row with their count; schedule cards count unread runs and run rows carry the unread dot. update attention reads as Update, and notify_user shows as Notified you in the transcript. The bot channel list query moves into useBotChannels so the Platforms tab, the overview and the form share it. Refs MEMOH-256
The attention stream built its frames field by field and left out schedule_id, so a run that raised attention while the page was open arrived without its schedule and got a Needs you row of its own; only a reload folded it into its schedule's row. Live frames now carry schedule_id like the unread summary. Refs MEMOH-256
The down migration rewrote update attention to reply on bot_sessions, which is under FORCE row level security keyed on memoh.team_id that a migration connection never sets, so rolling back past 0173 failed. Lift the policy for the data step and restore it after, as 0165 does. Refs MEMOH-256
A bot creating a watch task picked every_run so the user would see test runs, and a run that found what the user asked about replied in its conversation without calling notify_user. create_schedule now says when to pick important and every_run and to state in the command when the user should be told; the schedule usage says notify_user exists only inside important runs; notify_user says a reply alone does not notify. Refs MEMOH-256
QA found a daily digest created with every_run whose command said to send the summary with notify_user. Its runs have no notify_user, so each one searched for it, tried send, and reported it could not reach the user although every run did notify them. create_schedule now says that every_run runs have no notify_user and must not mention it, that notify_user carries no text, and that every_run is not a way to watch test runs. An every_run trigger also says the run's reply is what the user reads; schedules with default settings still read as before. Refs MEMOH-256
Opening a schedule's notification switches the sidebar to Schedules, expands that schedule's card and scrolls to the run's row; an update also scrolls the transcript to the notice notify_user left there, which now breaks out of the tool group as a standalone card. Inbox rows a schedule raised carry a clock on the avatar, and a schedule card's menu can read all of its unread runs at once. Refs MEMOH-256
chen-ran
force-pushed
the
feat/memoh-256-schedule-attention
branch
from
November 6, 2026 22:33
2260e7e to
2f19485
Compare
chen-ran
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author
Type
Summary
定时任务现在可以区分「这次运行需要你关注」和「这次没什么事」,不打开任务就能看出来。默认不打扰你,只在有必要时提醒。
之前的问题
chat/acp_agent)。这个 PR 的行为
0173_schedule_notify):notify_policy:important(默认)表示只在需要你关注时,在 Memoh 中提醒;every_run表示每次运行都提醒。contact_via_channels:默认打开,表示「有更新时,通过已配置的平台主动联系我」。notify_user:important的定时任务运行中注册。原生运行时和外部 Agent 运行时都可用,判断方式一致:按会话找到正在进行的那次运行,读取它所属任务的设置。update,界面显示为「有更新」。每次运行最多记一次。important的运行,正常完成且没有调用notify_user时,不再记「已回复」。挂在已有会话上的任务也一样:只跳过定时任务那一轮,你自己在这个会话里发的消息照常提醒。every_run每次正常完成都记「已回复」。send目标,或者 Bot 运行时用get_contacts自己查。所以以后接入新平台,行为也不会变。create_schedule/update_schedule增加notify_policy和contact_via_channels两个参数。工具描述写明了默认值和推荐值,并说明除非用户要求,否则不要修改。notify_user不再收在工具组里,而是单独显示为一张「已提醒你」卡片。useBotChannels。原来「平台」tab 和「概览」各写了一份相同的查询,现在和表单共用这一份。数据与接口
0173_schedule_notify:schedule表新增notify_policy(CHECK 约束)和contact_via_channels;bot_sessions.attention_kind的 CHECK 加入update;idx_schedule_logs_session,供未读汇总按会话查找所属任务。update改回reply,再恢复旧约束。0001_init快照已同步。MarkSessionAttention/MarkSessionsUnread/ListUnreadSessionsForUser放行type = 'schedule'。未读汇总和session_attention事件新增schedule_id。Related Issues
Validation
2026-11-07 rebase 后复测(Agent QA)
API rate limit exceeded for installation,remaining=0,日志 reset 为 2026-11-07 06:50:02 Asia/Shanghai);尚不能认定 CI 全绿。Go CI 与迁移作业仍在运行,Pgvector bootstrap 已通过。6 张新增图片均已回读验证为 GitHub attachment URL,HTTP 200 / image/jpeg。main的b8eaa9eb795410af4b06c1270ebe47c030885488,当前 head2f19485382015d0b0c29da03c72ef82bac69df8b。保留 main 的 actor 授权接口,移除 PR 新增测试替身的旧 JWT 参数与字段;三语冲突同时保留浏览器通知与日程未读词条,保留中文已有标点规范。memoh-pr1736,使用仓库开发服务定义及入口脚本,前端宿主 Vitehttp://127.0.0.1:19182,Server:19080、Channel:19081。Server/Channel/PostgreSQL/pgvector/Connect-It 容器健康,挂载本次 worktree;第二次 rebase 后已重启 Server/Channel 并重新运行真实模型用例。Bot 关闭记忆,未接入社交平台。QA-有更新,默认important/contact_via_channels=true,每分钟执行、最多 3 次,数据库确认设置已保存。其余场景通过 API 准备,再通过真实 UI 与 PostgreSQL 运行记录交叉验证。important无变化 →ok且无 attention;every_run→ok/reply;调用notify_user→ok/update;固定会话调用notify_user→ok/update;专用不可达 Provider 用例在重试耗尽后 →error/failed(agent.provider_unreachable)。前四项使用真实 MiMo;失败项为受控连接故障,不是模型服务实测。06:28:40,06:31 调用notify_user后才更新。普通 UI 聊天正常回复。Notified you卡片;打开运行扣减未读;每次运行任务的“全部标为已读”移除 3 条,点击 Undo 恢复 3 条;固定会话任务菜单没有“全部标为已读”,点击任务直接打开原会话;失败运行显示红色标记。所有测试任务达到次数上限后自动停用。mise run sqlc-generate(无生成差异);mise run lint(0 error,保留既有 warnings);Web typecheck;8 个相关 Web Vitest 文件、63 个测试;Desktop attention 测试 3 个;Go chat/application/tool/native/schedule/handlers/channel-inbound 相关包测试。migrate up → down → up通过,版本173、dirty=false;-tags=integration -count=1的internal/chat/attention、internal/db、internal/chat/message、internal/chat/checkpoint、internal/chat/thread、internal/agent/view全部通过。迁移与前端检查在第二次 rebase 前完成;第二次 rebase 只新增 main 的后端 fork 快照/渠道回放改动,相关 Go 测试和全量 lint 已重跑。自动检查
./internal/chat/attention/、./internal/agent/application/、./internal/agent/tool/...(含 schema golden,本次有意更新了schedule.json,并新增notify.json)、./internal/agent/runtime/native/、./internal/schedule/、./internal/chat/...、./internal/handlers/全部通过。vue-tsctypecheck、ESLint(改动文件没有 error)、scripts/check-ui-contract.mjs通过。ui-icon-contract、chat-user-input-form、panel-preview、useMediaGallery、keyboard-bindings外全部通过;这 5 个在干净的origin/main上同样失败,和本 PR 无关。全量运行时markdown/index、markdown-dollar.render偶尔超时,单独运行通过。notify_user只在important的定时任务运行中注册;notice、schedule),以及桌面端主进程对这两个参数的校验;开发环境实测(Agent 自测,不算 Human QA)
memoh-256(server :18280),宿主机 vite 地址 http://127.0.0.1:25100,空数据库。迁移版本为173,dirty=false。[notify]时调用notify_user,[quiet]时只回复,[fail]时返回 500。假模型的模型配置需要打开tool_call;没打开时,运行中不会提供任何工具(send也没有)。important/true。另外通过 API 建了 5 个任务,全部设为每分钟运行,跑了两三轮。数据库和假模型日志的结果如下:[notify]+important:模型能看到notify_user,调用后会话记为update。[quiet]+important(特殊天气提醒、不走平台):没有任何 attention。[quiet]+every_run(工作区备份检查):每轮都记reply,模型一次也没有看到notify_user。[fail]:记failed。[quiet]的几轮运行都没有改动这个对话的 attention,它仍是我自己那条消息的reply(08:52:08)。改成[notify]后,变成update(09:03:00)。Human QA 期间发现并修复的问题
schedule_id;汇总接口带着这个字段,所以刷新后正常。现在实时帧也带上schedule_id,并补了服务端和前端 store 的测试。在真实模型的环境里,页面一直不刷新,同一行从「有更新」依次变成「2 条未读」……「5 条未读」。0173的 down 迁移在bot_sessions上执行UPDATE,这张表是 FORCE RLS,而迁移连接不会设置memoh.team_id。按 0165 的做法,在数据步骤前后先解除再恢复 RLS。本地按 CI 的步骤(migrate up → down → up,再跑go test -tags=integration)验证通过。origin/main。冲突只在三个 locale 文件,保留 main 规范化后的文案,再加上本分支的词条;中文单句说明按 main 的新规范去掉了末尾句号。origin/main上同样失败:除之前列出的 4 个外,新增的src/lib/keyboard-bindings.test.ts(encloseCurrentWorkspaceTab缺少 label)也来自 main。提示词改进(Human QA 中发现:Bot 建监控任务时误选
every_run,命中后也没调用notify_user)important之后,每次运行都提供了notify_user(运行上下文快照context_lifecycles可以证实),工具注册没有 bug。问题有两处:建任务时 Bot 不知道important是怎么提醒用户的,所以为了「让用户看到效果」选了every_run;运行时它把「在会话里回复」当成了已经提醒。create_schedule的描述现在讲清important和every_run怎么选,即使测试时把间隔设得很短,也应选important;在 command 里写清什么时候该告诉用户,不要写「只回复本会话」之类。notify_policy工作,notify_user只存在于important的运行里,聊天回合里没有。notify_user的描述增加:在会话里回复不等于提醒了用户。mode_schedule.md、send的描述等)都没有改,社交平台行为保持不变。补充了 3 条测试,固定这几句关键文字。deepseek-flash)在 UI 里端到端复测:我让 Coder「每分钟看当前时间,偶数分钟告诉我,先每分钟跑一次看看效果」,这正是上次导致误选的那种说法。这次 Bot 选了important。14:26、14:28、14:30(偶数)三次运行都调用了notify_user,记为「有更新」;14:27、14:29(奇数)两次保持安静,没有任何提醒。every_run与notify_user的引导冲突(subagent 多场景实测中发现)every_run,但 command 里写了「通过 notify_user 发送」。every_run的运行本来就没有这个工具,于是每轮都在找它,又去试send(7 次都报unsupported channel type: local),最后回复「无法送达用户」。实际上每次运行都已经提醒了用户。create_schedule的描述补充三点:every_run的运行结束本身就会通知用户,运行里没有notify_user,command 里不要提它;notify_user没有参数、不带内容,只是把运行标成「有更新」,用户读到的是运行的回复;every_run不是为了测试时看效果。every_run的运行,触发提示末尾追加一句「The user is notified when this run finishes; your final reply is what they read.」。默认设置的任务提示词仍与改动前逐字一致。notify_user。6 轮运行都带有新说明,0 次send,没有一轮声称送达失败,回复都是摘要本身,每轮记「已回复」。every_run任务,跑了 2 轮。Bot 的推理是「the run has no notify_user tool — the final reply is what the user reads」,没有调用send,直接回复结果,每轮记「已回复」。create_schedule新加的文字,以及runSchedule会把这两个设置传给运行。提醒跳转与「全部标为已读」(Agent 自测,不算 Human QA)
every_run):从 Gamer 跳到 Coder,侧边栏切到「日程」,这个任务的卡片展开,最新一次运行被选中。没有验证的
update。Screenshots / Recordings
2026-11-07 最终 head 的真实 UI 截图
新建任务默认提醒设置:

真实运行的实时聚合、失败提醒和固定会话更新:

点击提醒后定位到运行及通知卡片:

批量已读与撤销后的计数恢复:


固定会话中先静默完成,后调用 notify_user:

任务表单里的「提醒」区,显示默认值;这个 Bot 没有平台,所以显示空状态和「配置平台」:
「需要你」把同一个任务的未读合并成一行,并显示数字;挂在对话上的任务显示「有更新」:
日程卡片显示未读数,展开后运行行有未读点:
打开一次运行:聊天记录里显示「已提醒你」,这一行变为已读,计数从 4 降到 3:
用真实模型新建监控任务:Bot 选择
important,并说明只有调用notify_user的运行才会提醒:偶数分钟(14:30)的运行调用了
notify_user并提醒;运行行只在偶数分钟带未读点:奇数分钟(14:29)的运行保持安静,没有任何提醒:
页面不刷新时,同一个任务新冒出来的运行实时合并成一行(5 条未读):
every_run旧写法任务(command 写着「通过 notify_user 发送」)的运行:直接给出结果,说明「运行结束后系统会推送」,没有尝试send,也没有声称送达失败:「需要你」里由定时任务产生的行,头像角上有时钟:
点开「每日科技新闻摘要」的合并提醒:侧边栏切到「日程」,展开任务卡片,选中这次运行:
点开「有更新」的提醒:卡片翻到第二页,滚动到 15:11 这次运行;聊天记录停在「已提醒你」卡片上:
任务卡片「…」菜单里的「全部标为已读」:
全部标为已读后,计数和未读点消失,提示可以撤销:
Human QA