Repository navigation
feat: 延迟监控支持拖拽排序,公开页图表跟随 - #43
Merged
Merged
Conversation
面板的「延迟」页此前按创建顺序列出监控,没有调整顺序的入口。ping_task 加 sort 列(schema v7),重排走独立的 PUT /api/ping-tasks/order,编辑监控不改动顺序。 顺序同时是 agent 运行监控的顺序,公开页延迟图表的系列、配色和图例也由采样行的 到达顺序决定,所以重排要把新列表推给已连接的 agent,ping_records 也要按面板顺序 发行,否则三处各自要等到下次重连或刷新才一致。 迁移把既有行一律置 0,读侧回落 id,升级上来的库顺序不变。 面板的拖拽逻辑原本内联在节点列表里,这次抽成两个表格共用的一份。 Closes #40
两处都是既有问题,与拖拽排序这次功能无关,是实现过程中撞见的。 视图过渡:animate() 不等 startViewTransition 返回的 promise。一次拖拽会在指针 越过的每一行上重排,松手时再重排一次,后一个过渡会跳过前一个,而被跳过的 promise 以 AbortError 拒绝——没人接,于是每次拖拽都在控制台留下一条未处理错误。 行的推移本来就是对的,只是白白报错。给 ready 和 finished 挂上 catch 即可,行为 不变。 历史查询闸门:HISTORY_GATE 是进程级 static,而 history_queries_past_the_gate_are_ refused_rather_than_queued 必须故意占满全部许可并跨 await 持有,才能观察到 503。 libtest 默认并行跑测试,于是 an_anonymous_history_window_stops_at_a_week 也被拒, 它把 503 的纯文本正文当 JSON 解析,报的是 "expected ident",既没提闸门,也没提 真正抢走许可的那个测试。两个测试共用一把锁串行化即可;用 tokio 的 Mutex 而非标准 库的,因为标准库的 guard 跨 await 会被 clippy::await_holding_lock 拦下。 RELAY_GATE 与 PASSWORD_GATE 是同样的写法,但走它们 handler 的测试不存在,没有 这个碰撞。 验证:cargo test 默认并行连跑 8 次全绿(修复前三次里失败一到两次);真实浏览器里 一次拖拽的 console 错误由 1 条降到 0 条,拖拽排序的 11 项端到端检查仍全部通过。
login 的分支各自都有测试——Throttle 的锁定生命周期、verify_password、client_ip、 会话 cookie、密码闸门——但它把这些串起来的顺序没有:先查锁定再验密码、拒绝记账、 成功清账、发出的会话能开。 计数用 Throttle::record_failure 直接堆,而不是多派几次登录:计数是 throttle 自己 的事且上面已经测过,而每次真正走到 verify_password 都要花掉 argon2 半秒(debug 构建下),十几次登录能把套件拖长一倍。 顺带把两个测试串行化:这个测试和 auth.rs 里那个持满闸门许可的 flood 测试都走 login/PASSWORD_GATE,并行跑时登录会被 429 掉、挂在与它无关的地方。flood 测试因此 从 #[test] 变成 #[tokio::test],锁用 tokio 的而非标准库的(标准库的 guard 跨 await 会被 clippy::await_holding_lock 拦下),与 api.rs 里的 HISTORY_TESTS 同一写法。 验证:三个变异分别被抓——去掉成功后的 clear、去掉登录前的 locked 检查、去掉错误 密码的 record_failure,各自挂在对应的断言上。默认并行连跑 8 次全绿。
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Adds persistent drag-and-drop ordering for latency monitors across the admin panel, connected agents, and public charts.
Changes:
- Adds schema migration, ordering persistence, and reorder API.
- Synchronizes ordering with agents and chart output.
- Extracts reusable drag-and-keyboard ordering UI.
- Expands ordering, migration, synchronization, and authentication tests.
| File | Description |
|---|---|
web-admin/src/lib/api.ts |
Adds monitor ordering data and move helper. |
web-admin/src/lib/api.test.ts |
Tests move behavior and bounds. |
web-admin/src/components/Admin.tsx |
Adds shared drag-and-keyboard ordering UI. |
src/main.rs |
Registers the reorder endpoint. |
src/db.rs |
Adds ordering persistence, migration, queries, and tests. |
src/auth.rs |
Serializes authentication tests and adds sign-in coverage. |
src/api.rs |
Implements reorder handling, agent pushes, and related tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
# Conflicts: # src/api.rs # src/db.rs # web-admin/src/components/Admin.tsx # web-admin/src/lib/api.test.ts # web-admin/src/lib/api.ts
- 重排不再推给 agent:agent 的列表按 id 下发,与面板顺序无关,保持不变也就不必推送 - 公开页的延迟行改为逐个探测输出:主题按探测首次出现的顺序定系列与配色,按桶输出时, 窗口开头那个不完整的桶里谁先有数据谁就排在前面,跟不上面板顺序 - 节点与延迟监控共用一份 reorder,报错改为面板能直接显示的中文 - 视图过渡只接住被跳过时 ready 的 AbortError,update 回调里的真实错误照常抛出 - 视图过渡期间 Chrome 把拖拽事件都打到根元素上,此时松手会被当成拖到表外而整次回滚, 两张表同时修正 - 两个历史查询测试共用一把锁,免得并行时互相抢闸门 - 移除与 #40 无关的登录端点测试
- 换位与接受落点都改在文档上按指针位置判断:视图过渡期间拖拽事件都命中根元素, 行上的处理会漏掉这段时间跨过的行;表格外松手仍然还原 - 移动基于最后一次请求的顺序,按住方向键或快速拖动不再丢步;过时的过渡不再覆盖新的顺序 - 保存逐个发出,两次连续排序按先后到达 hub;被拒绝时回到 hub 的列表 - hub 列出与本地相同的顺序后放弃本地覆盖,其他标签页的排序能显示出来,不会被下一次拖动覆盖 - 不再接受外部拖入的内容 - 延迟行的排序在释放数据库连接之后进行,未在排序里的探测排在最后
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.
Closes #40
延迟页可以像节点列表一样拖动排序,公开页延迟图的图例和配色跟随这个顺序。
ping_task加sort列(schema v9):已有监控升级后顺序不变,新建的排在末尾,编辑监控不改动顺序PUT /api/ping-tasks/order,与节点共用同一份校验:列表必须恰好包含全部监控,否则整体拒绝useDragOrder与DragHandle,键盘 ↑↓ 同样可用AbortError;两个历史查询测试共用一把锁,避免并行时互相抢占闸门测试:
cargo test125 项、前端 lint / test / build 通过;浏览器中验证了键盘连按、快速拖动(上下两个方向)、动画期间与表格外松手、保存被拒、多标签页,以及两个主题的图例顺序。文档:monitor-probe/monitor-document#25