Skip to content

feat(chat): configurable interactive answer timeout (fork of #362 with blocking fixes) - #386

Open
devil233-ui wants to merge 7 commits into
Stack-Cairn:mainfrom
devil233-ui:fix/interactive-timeout-persistence-and-setoverflow
Open

feat(chat): configurable interactive answer timeout (fork of #362 with blocking fixes)#386
devil233-ui wants to merge 7 commits into
Stack-Cairn:mainfrom
devil233-ui:fix/interactive-timeout-persistence-and-setoverflow

Conversation

@devil233-ui

@devil233-ui devil233-ui commented Aug 6, 2026

Copy link
Copy Markdown

背景

接手原 #362(作者暂时没空继续)。本 PR 在 #362 的 3 个 commit 基础上,修复了三个阻塞问题,使其真正可用。

修复内容

1. 🐛 设置持久化:interactiveTimeoutMinutes 进 Rust 保存白名单

#362 只改了前端,该键不在 save_system 白名单里,落库时被丢弃 → 重启即回默认 3 分钟,功能等于没生效(实测确认)。

  • 补入 system.rs 保存白名单 + normalize_interactive_timeout_minutes_value(正数保留、上限钳 99999、非正/非法回默认 3,与前端归一化同口径)
  • 更新 row_count 断言 9→10、key 列表,新增 round-trip 测试覆盖 7 个归一化用例

2. 🔧 setTimeout 32 位溢出:分段续期

99999 分钟 ≈ 5.99e9 ms 超过 setTimeout 的 IDL long 上限(2^31-1),裸调用 ToInt32 回绕:99999 被截成约 19.7 天,35792~200000 分钟区间回绕成负数被钳为 0 → 「永不超时」瞬间立刻超时

  • 新增 scheduleAtDeadline:单跳最多 2^31-1 ms,到点按剩余续排,回调恒异步
  • 替换 AskUserQuestion 与工具审批的裸 setTimeout
  • 补最大档回归(用真实 99999 分钟) + scheduleAtDeadline 语义测试。原 feat(chat): configurable interactive answer timeout #362 的测试用 1 小时窗口,在安全范围内,测不出此 bug

3. 🧹 卡片 deadline 上界:由"取消"改为"最大可配置窗口"

#362 取消上界校验,远端时钟偏移会显示荒谬倒计时,且把回归写进断言。现上界取 INTERACTIVE_TIMEOUT_MAX_MINUTES(99999 分钟):长窗口仍被采信,超出视为时钟不可比回退挂载近似。补超上限不采信测试。

附带:biome 格式化(CI 修复)

两端 SystemToolsSection.tsxbiome check --writepnpm lint 从红转绿(原 #362 会在 CI 挂掉)。

验证

  • agent-gui 前端:1422 pass(原 1418 + 新增 4)
  • gateway web:493 pass
  • Rust settings::tests:42 pass(含新增 round-trip)
  • 两端 tsc --noEmit clean
  • 两端 biome check clean
  • mirror check:119 文件一致

已知限制(沿用原 #362 设计,未扩大范围)

  • WebUI 滑块为纯装饰:值同步到桌面端,注入仅在 GUI 生效
  • 已挂起的交互不应用新窗口,只对新发起的生效

Screenshots / preview

交互式应答超时滑块配置为 99999 分钟(≈永不超时)时,AskUserQuestion 卡片挂起并显示超长倒计时(约 99998 分钟剩余),不会如修复前那样瞬间超时落定。

interactive-timeout-99999

截图取自实机 dev 版(含本 PR 全部修复):滑块已调至 99999 档,卡片正常挂起、倒计时显示超长窗口。

关联 issue

Closes #354

FlowerRealm and others added 6 commits August 2, 2026 01:15
Make the answer window shared by the AskUserQuestion card and the tool
approval bar configurable via settings.system.interactiveTimeoutMinutes
(minutes, default 3, preserving current behavior). A very large value
(e.g. 99999) approximates never timing out. The window is injected into
both tools at runtime; every deadline stays a finite timestamp, so the
countdown logic needs no special never-handling.

Refs Stack-Cairn#354 (timeout configurability).
… a fine-grained slider

Move the interactive answer timeout off its standalone input card and into
the AskUserQuestion tool row, replacing the fixed read-only 'allow' label
with a stop-based slider. The stop table keeps 1-60 minutes fine-grained
(1,2,3,4,5,6,8,10,12,15,20,25,30,40,50,60) and jumps straight to 99999
past one hour, so the slider reads as a plain duration without exposing
any internal 'never' semantics. The tool detail copy no longer hardcodes
'3 minutes'; it now points at the adjustable slider.
Keep a single one-line comment on the stop table and drop the duplicate
block inside the render body; both mirrored files stay byte-identical.
…list

前端改完滑块重启即回默认值:该键此前不在 save_system 白名单里,
落库时被丢弃。补入白名单 + normalize_interactive_timeout_minutes_value
(正数保留、上限钳 99999、非正/非法回默认 3,与前端归一化同口径),
并更新 row_count 断言(9→10)与 key 列表,新增 round-trip 测试覆盖
7 个归一化用例。
99999 分钟换算成毫秒(≈5.99e9)超过 setTimeout 的 IDL long 上限
(2^31-1),裸调用会被 ToInt32 回绕:99999 被截成约 19.7 天,
而 35792~200000 分钟区间回绕成负数被钳为 0 → 「永不超时」瞬间
立刻超时。新增 scheduleAtDeadline 分段续期(单跳最多 2^31-1 ms,
到点按剩余时间续排,回调恒异步),替换 AskUserQuestion 与工具审批
的裸 setTimeout;补最大档回归 + scheduleAtDeadline 语义测试。
两端镜像,tsc/lint/mirror 均过。
原 PR 把 deadline 上界校验整个取消,远端浏览器时钟偏移时会显示
荒谬长倒计时,且把回归写进断言。上界改为最大可配置窗口
(99999 分钟):长窗口仍被采信,超出视为时钟不可比回退挂载近似。
同时两端 SystemToolsSection 过 biome 格式化(lint 从红转绿,
CI 不再失败)。补超上限不采信测试。
@StackCairn
StackCairn marked this pull request as draft August 6, 2026 04:18
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR governance checks passed. Awaiting human review.

@devil233-ui

Copy link
Copy Markdown
Author

Screenshot for PR #386 - configurable interactive timeout (99999 min ≈ never timeout)

@devil233-ui
devil233-ui marked this pull request as ready for review August 6, 2026 05:12
@FlowerRealm

Copy link
Copy Markdown
Contributor

代码太长了, 前端写的拖动条根本没必要min, max, 请优化一下代码质量

@FlowerRealm

Copy link
Copy Markdown
Contributor

前端传回的值是确定的, 无需后端过多检验

@devil233-ui

Copy link
Copy Markdown
Author

v4f还是太菜了hhh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 交互式提问默认不超时并支持配置超时时间

2 participants