fix: 等你允許的卡片第四輪——螢幕電腦照樣跑自己的 Notification hook;新卡重新送到手機有測試

獨立審查(8426638,沒有 P0/P1)提的:
- 第三輪的退步:螢幕電腦不推到手機時,連自己的 Notification hook 也跳過了(remote::notify_about 先叫
  hooks::notification 才推)。hooks 是每台電腦自己的(那台資料夾的 hooks/hooks.json),safety 寫
  「Notification 跟著通知跑」:螢幕電腦現在照樣跑自己的 hook,只有推到手機那一步是大腦的。沒有加測試:
  整段通知只在非示範模式跑(測試用示範的 App),hook 又是在執行緒上跑使用者自己的程式。
- 新測試 a_card_in_anothers_place_is_published_again:同一個 call_0、同樣的字的新卡(和支線的新卡)
  會讓手機畫面的簽章改變、重新送出,手機和螢幕電腦才拿得到新卡的 key(不然每個回答都被擋)。
- verify-approval-routing 的 REPLAY 補上 a_question_in_anothers_place_starts_with_nothing_picked、
  the_answer_after_direct_mode_let_its_card_through_says_nothing 和上面的新測試(共 10 個);「沒有
  放進模型」寫上螢幕電腦照樣跑自己的 hook;對過模型後 rehash(這個 commit 就是新的同步 commit)。
- 功能地圖 chat:換成另一張問題卡(就算編號一樣)就從第一題、什麼都沒選重新開始。

已驗證: 完整 cargo test(env -u 各家金鑰、DOCKER_HOST=unix:///nonexistent、ANYBOT_HF_BASE=http://127.0.0.1:9)649 passed、0 failed,含 featuremap::、layout_audit::、tool_specs_are_locked、approval_decisions_are_characterized(鎖檔沒改);cargo clippy --bin anybot --all-targets -D warnings;deploy/ci/lint-sh.sh;run.sh 先報 brain.new_approval_keyed 改過(結束碼 3),照技能對過(螢幕電腦還是不推到手機,只多跑自己的 hook,模型不變)後 rehash,run.sh --replay:沒有漂移、AllSurfaces 通過(421324 個狀態)、CanAnswer 找到三個地方都答得到、10 個重走測試通過;簽章拿掉主線卡的 key、拿掉支線卡的 key,新測試都抓到,改回後一致
未驗證: 螢幕電腦的 Notification hook 真的跑(要非示範模式的螢幕電腦和一個 hook,沒有實機);手機頁面看得到的行為這一輪沒變,沒有重跑 verify-anybot;--ignored 的實機測試(留給人跑)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
王性驊 2026-11-18 11:45:57 +08:00
parent 84266385f4
commit 755b877d24
6 changed files with 46 additions and 16 deletions

View File

@ -43,7 +43,7 @@ Bot 要做會動到你電腦的事時,大腦放一張卡等你:「允許/
== CanAnswer:違反 SomePlaceCannotAnswer ——預期中:找得到一種走法,手機頁面、通知、螢幕電腦的回答都交得出去 == CanAnswer:違反 SomePlaceCannotAnswer ——預期中:找得到一種走法,手機頁面、通知、螢幕電腦的回答都交得出去
TLC 的步驟(…) TLC 的步驟(…)
== 在真的程式上重走(--replay 才有) == 在真的程式上重走(--replay 才有)
7 個都通過:真的程式也是(跟 AllSurfaces 一致) 10 個都通過:真的程式也是(跟 AllSurfaces 一致)
== 全部跟預期一樣。 == 全部跟預期一樣。
``` ```
@ -81,7 +81,7 @@ Bot 要做會動到你電腦的事時,大腦放一張卡等你:「允許/
- 大腦給螢幕電腦的 `approvals` 帶 `key`;螢幕電腦把它記在 `mir.keys`、拿它當自己這張卡的 key(`new_approval_keyed`),回答時送 `call`;新卡用 key 分辨,不再只看 call id。舊版大腦沒給 key 時照舊(不送 call)。 - 大腦給螢幕電腦的 `approvals` 帶 `key`;螢幕電腦把它記在 `mir.keys`、拿它當自己這張卡的 key(`new_approval_keyed`),回答時送 `call`;新卡用 key 分辨,不再只看 call id。舊版大腦沒給 key 時照舊(不送 call)。
- `Cmd::Answer`:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收。通知送來的(`from: "notice"`)另外要過 `notice_answers`——放通知按鈕和收通知回答用同一條規則——而且只收 once/reject。 - `Cmd::Answer`:key 不是現在在等的那張卡的、或根本沒帶 key(開了很久的舊頁面、舊版螢幕電腦)→ 不收。通知送來的(`from: "notice"`)另外要過 `notice_answers`——放通知按鈕和收通知回答用同一條規則——而且只收 once/reject。
- 不收的時候(有卡在等才說):照它從哪條路來寫該怎麼辦——`api/bots/…/answer`(手機)沒帶 key 是「這個頁面太舊…重新整理再回答;還是不行(帳號伺服器還沒更新),就在電腦上回答」;`api/sync/act`(螢幕電腦,`Cmd::Answer` 的 `screen`)沒帶 key 是「那台電腦的 AnyBot 比這台舊…設定 › 更新」;帶了舊 key 是「那張卡已經不在等了」。支線的卡寫在主線的聊天(`home_of`:支線自己的訊息哪裡都不顯示)。直接操作打開時放行的「可以用電腦嗎」卡(`settled_by_direct`),手機「全部允許,之後直接操作」接著送來的那個回答不寫。 - 不收的時候(有卡在等才說):照它從哪條路來寫該怎麼辦——`api/bots/…/answer`(手機)沒帶 key 是「這個頁面太舊…重新整理再回答;還是不行(帳號伺服器還沒更新),就在電腦上回答」;`api/sync/act`(螢幕電腦,`Cmd::Answer` 的 `screen`)沒帶 key 是「那台電腦的 AnyBot 比這台舊…設定 › 更新」;帶了舊 key 是「那張卡已經不在等了」。支線的卡寫在主線的聊天(`home_of`:支線自己的訊息哪裡都不顯示)。直接操作打開時放行的「可以用電腦嗎」卡(`settled_by_direct`),手機「全部允許,之後直接操作」接著送來的那個回答不寫。
- 回歸測試:`a_phone_card_tapped_after_it_changed_answers_nothing_else`(舊程式會失敗)、`a_phone_answer_without_its_cards_key_answers_nothing`、`a_banner_answers_only_its_own_request`、`a_branch_card_on_the_phone_carries_its_own_key_and_target`、`the_answer_after_direct_mode_let_its_card_through_says_nothing`、`a_screen_answers_only_the_card_it_shows`、`a_screen_keeps_its_cards_key_in_step_with_the_brains`、`a_question_in_anothers_place_starts_with_nothing_picked`(大腦視窗和螢幕電腦的問題卡表單照 key 認)。 - 回歸測試:`a_phone_card_tapped_after_it_changed_answers_nothing_else`(舊程式會失敗)、`a_phone_answer_without_its_cards_key_answers_nothing`、`a_banner_answers_only_its_own_request`、`a_branch_card_on_the_phone_carries_its_own_key_and_target`、`the_answer_after_direct_mode_let_its_card_through_says_nothing`、`a_screen_answers_only_the_card_it_shows`、`a_screen_keeps_its_cards_key_in_step_with_the_brains`、`a_question_in_anothers_place_starts_with_nothing_picked`(大腦視窗和螢幕電腦的問題卡表單照 key 認)、`a_card_in_anothers_place_is_published_again`(同一個 call_0 的新卡、支線的新卡都會重新送到手機和螢幕電腦)。
## 對照表:模型的每個動作 ↔ 程式碼 ## 對照表:模型的每個動作 ↔ 程式碼
@ -129,7 +129,7 @@ Bot 要做會動到你電腦的事時,大腦放一張卡等你:「允許/
- 手機通知什麼時候被別的通知蓋掉(模型讓舊通知一直留著,比真的寬)。 - 手機通知什麼時候被別的通知蓋掉(模型讓舊通知一直留著,比真的寬)。
- 帳號伺服器(`relay/`)自己編進去一份手機頁面:伺服器沒更新前,用帳號登入的手機送不出 key,回答全都不收(安全,但答不了)。這是部署的事,不在模型裡。 - 帳號伺服器(`relay/`)自己編進去一份手機頁面:伺服器沒更新前,用帳號登入的手機送不出 key,回答全都不收(安全,但答不了)。這是部署的事,不在模型裡。
- 舊的帳號伺服器頁面上按通知:舊頁面送 `call = d.ask` 但沒有 `from: "notice"`,大腦把它當手機自己的卡(不過 `Fits`)。今天還是安全的,因為兩件事:通知的 key 只發給 `notice_answers` 的卡(`on_new_approval`),而舊的 sw.js 也只送 once/reject。哪天通知帶 key 的範圍變了,或 sw.js 能送別的回答,這條路要放進模型。 - 舊的帳號伺服器頁面上按通知:舊頁面送 `call = d.ask` 但沒有 `from: "notice"`,大腦把它當手機自己的卡(不過 `Fits`)。今天還是安全的,因為兩件事:通知的 key 只發給 `notice_answers` 的卡(`on_new_approval`),而舊的 sw.js 也只送 once/reject。哪天通知帶 key 的範圍變了,或 sw.js 能送別的回答,這條路要放進模型。
- 螢幕電腦不推通知:`new_approval_keyed` 在 `mir.on` 時只響、只跳 macOS 的通知,不推到手機(`remote::notify_approval`/`notify` 都不叫)。以前會推:帳號伺服器在那則通知蓋上螢幕電腦的 host(`relay/src/main.rs` 的 `relay/host/notify`),手機按了就切到螢幕電腦、把回答送過去,而螢幕電腦不替手機做任何事(`remote_tick` 丟掉 `mir.on` 時的手機指令)、也不給手機畫面,「允許」就不見了。同一張卡由大腦推(同一個「通知」設定,大腦不在前面或閒置 90 秒時;大腦在伺服器上就一定推);大腦那台正在用時,大腦和螢幕電腦都不推。模型的 `YouTapBanner` 只畫大腦推的通知,這一條是照程式讀的,沒有測試(推播只在非示範模式、而且要連帳號伺服器)。 - 螢幕電腦不推通知:`new_approval_keyed` 在 `mir.on` 時只響、只跳 macOS 的通知、只跑這台自己的 Notification hook(`hooks::notification`;hooks 是每台電腦自己的),不推到手機(`remote::notify_approval`/`notify` 都不叫)。以前會推:帳號伺服器在那則通知蓋上螢幕電腦的 host(`relay/src/main.rs` 的 `relay/host/notify`),手機按了就切到螢幕電腦、把回答送過去,而螢幕電腦不替手機做任何事(`remote_tick` 丟掉 `mir.on` 時的手機指令)、也不給手機畫面,「允許」就不見了。同一張卡由大腦推(同一個「通知」設定,大腦不在前面或閒置 90 秒時;大腦在伺服器上就一定推);大腦那台正在用時,大腦和螢幕電腦都不推。模型的 `YouTapBanner` 只畫大腦推的通知,這一條是照程式讀的,沒有測試(推播只在非示範模式、而且要連帳號伺服器)。
- 「沒有用上」寫在哪個聊天、寫什麼字、直接操作放行過的卡不寫(`settled_by_direct`):只影響要不要說一句,不影響哪張卡收到回答;`remote_ui.rs`、`mirror_ui.rs` 的測試管。 - 「沒有用上」寫在哪個聊天、寫什麼字、直接操作放行過的卡不寫(`settled_by_direct`):只影響要不要說一句,不影響哪張卡收到回答;`remote_ui.rs`、`mirror_ui.rs` 的測試管。
## 覆蓋紀錄和同步 commit ## 覆蓋紀錄和同步 commit
@ -154,4 +154,4 @@ Bot 要做會動到你電腦的事時,大腦放一張卡等你:「允許/
- `model/AllSurfaces.cfg`、`model/CanAnswer.cfg`:三條規則;路沒堵死。 - `model/AllSurfaces.cfg`、`model/CanAnswer.cfg`:三條規則;路沒堵死。
- `model/statechart-view.ts`:給 `/pstack:statechart` 的白話標籤。 - `model/statechart-view.ts`:給 `/pstack:statechart` 的白話標籤。
- `run.sh`:唯一要跑的指令。`drift.py`、`coverage.tsv`:程式碼有沒有改過。 - `run.sh`:唯一要跑的指令。`drift.py`、`coverage.tsv`:程式碼有沒有改過。
- 測試(只有測試,不改行為):`src/app/remote_ui.rs` 的 `approval_routing_replay`、`phone_act_tests::a_banner_answers_only_its_own_request`、`phone_act_tests::a_phone_answer_without_its_cards_key_answers_nothing`、`phone_act_tests::a_branch_card_on_the_phone_carries_its_own_key_and_target`、`phone_act_tests::the_answer_after_direct_mode_let_its_card_through_says_nothing`;`src/app/mirror_ui.rs` 的 `tests::a_screen_answers_only_the_card_it_shows`、`tests::a_screen_keeps_its_cards_key_in_step_with_the_brains`;`src/app.rs` 的 `tests::a_question_in_anothers_place_starts_with_nothing_picked`。 - 測試(只有測試,不改行為):`src/app/remote_ui.rs` 的 `approval_routing_replay`、`phone_act_tests::a_banner_answers_only_its_own_request`、`phone_act_tests::a_phone_answer_without_its_cards_key_answers_nothing`、`phone_act_tests::a_branch_card_on_the_phone_carries_its_own_key_and_target`、`phone_act_tests::the_answer_after_direct_mode_let_its_card_through_says_nothing`;`src/app/mirror_ui.rs` 的 `tests::a_screen_answers_only_the_card_it_shows`、`tests::a_screen_keeps_its_cards_key_in_step_with_the_brains`;`src/app.rs` 的 `tests::a_question_in_anothers_place_starts_with_nothing_picked`;`src/app/remote_ui.rs` 的 `phone_act_tests::a_card_in_anothers_place_is_published_again`。

View File

@ -4,7 +4,7 @@ desk.approval_body src/app.rs block ^ fn approval_body\( } fd8c84806d8b8867c0
desk.approval_dock src/app.rs block ^ fn approval_dock\( } cda918bb255c4533d2d116736aaeb10aa2b9477b6c2858f1698b81b6dcef8794 desk.approval_dock src/app.rs block ^ fn approval_dock\( } cda918bb255c4533d2d116736aaeb10aa2b9477b6c2858f1698b81b6dcef8794
brain.need_approval src/app.rs block ^ if let StreamEvent::NeedApproval\(a\) = ev \{ } 5d62c439986d0e2ee6d0f28b3cbaf28fca8688c0c60395d86e77a77a35bd55ec brain.need_approval src/app.rs block ^ if let StreamEvent::NeedApproval\(a\) = ev \{ } 5d62c439986d0e2ee6d0f28b3cbaf28fca8688c0c60395d86e77a77a35bd55ec
brain.on_new_approval src/app.rs block ^ fn on_new_approval\( } c110c0341ae1b8cbcc59d0b4dc1dba7a2b8006885837e515ea6c0ef23a195205 brain.on_new_approval src/app.rs block ^ fn on_new_approval\( } c110c0341ae1b8cbcc59d0b4dc1dba7a2b8006885837e515ea6c0ef23a195205
brain.new_approval_keyed src/app.rs block ^ fn new_approval_keyed\( } 4c3b9db1fea8e8d7db7315b127b78ff93c6c1d529c6aa3aca3b6c15cb15cb6e4 brain.new_approval_keyed src/app.rs block ^ fn new_approval_keyed\( } cfba6b7d4b08bc0a2d46363f5ff27205cf0c49c3a80f0cf4673c9546ab99f34d
brain.notice_answers src/app.rs block ^fn notice_answers\( } a846a5e243978060ff4810ced82a064820da0966634bb9e730a14e6a5b303400 brain.notice_answers src/app.rs block ^fn notice_answers\( } a846a5e243978060ff4810ced82a064820da0966634bb9e730a14e6a5b303400
brain.answer src/app.rs block ^ fn answer\(&mut self, ctx: &egui::Context, bot_id: u64, answer: ApprovalAnswer\) } 192102f8e18c5859f58b3fb89acf5faffcd5339603f7e7ec3ab47aaf94c52cfd brain.answer src/app.rs block ^ fn answer\(&mut self, ctx: &egui::Context, bot_id: u64, answer: ApprovalAnswer\) } 192102f8e18c5859f58b3fb89acf5faffcd5339603f7e7ec3ab47aaf94c52cfd
brain.stop src/app.rs block ^ fn stop\(&mut self, bot_id: u64\) } c7b8144a99b5cd03d37dd34ca1745dca693d4f2f0197a51d29dfb71b3e770f4f brain.stop src/app.rs block ^ fn stop\(&mut self, bot_id: u64\) } c7b8144a99b5cd03d37dd34ca1745dca693d4f2f0197a51d29dfb71b3e770f4f

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -21,7 +21,7 @@ jar="$tools/tla2tools-$TLA_VERSION.jar"
EXPECT="AllSurfaces:pass CanAnswer:fail" EXPECT="AllSurfaces:pass CanAnswer:fail"
# --replay 跑的測試(每一個都要通過;對照 SKILL.md「讀結果」)。 # --replay 跑的測試(每一個都要通過;對照 SKILL.md「讀結果」)。
REPLAY="approval_routing_replay a_banner_answers_only_its_own_request a_phone_answer_without_its_cards_key_answers_nothing a_screen_answers_only_the_card_it_shows a_screen_keeps_its_cards_key_in_step_with_the_brains a_branch_card_on_the_phone_carries_its_own_key_and_target" REPLAY="approval_routing_replay a_banner_answers_only_its_own_request a_phone_answer_without_its_cards_key_answers_nothing a_screen_answers_only_the_card_it_shows a_screen_keeps_its_cards_key_in_step_with_the_brains a_branch_card_on_the_phone_carries_its_own_key_and_target a_card_in_anothers_place_is_published_again a_question_in_anothers_place_starts_with_nothing_picked the_answer_after_direct_mode_let_its_card_through_says_nothing"
say() { printf '%s\n' "$*"; } say() { printf '%s\n' "$*"; }
@ -91,7 +91,7 @@ if [ "${1:-}" = "--replay" ]; then
passed=$(grep -c " \.\.\. ok$" "$out/replay.out") passed=$(grep -c " \.\.\. ok$" "$out/replay.out")
failed=$(grep " \.\.\. FAILED$" "$out/replay.out" | sed 's/^test //; s/ \.\.\. FAILED$//') failed=$(grep " \.\.\. FAILED$" "$out/replay.out" | sed 's/^test //; s/ \.\.\. FAILED$//')
# 真的程式跟模型要說同一件事:AllSurfaces 通過 ↔ 測試都過;違反 ↔ 有測試沒過。 # 真的程式跟模型要說同一件事:AllSurfaces 通過 ↔ 測試都過;違反 ↔ 有測試沒過。
if [ -z "$failed" ] && [ "$passed" -ge 7 ]; then real=pass; else real=fail; fi if [ -z "$failed" ] && [ "$passed" -ge 10 ]; then real=pass; else real=fail; fi
case "$real/$everywhere" in case "$real/$everywhere" in
pass/pass) say " ${passed} 個都通過:真的程式也是(跟 AllSurfaces 一致)" ;; pass/pass) say " ${passed} 個都通過:真的程式也是(跟 AllSurfaces 一致)" ;;
fail/fail) unexpected=1; say " 真的程式也走得出 AllSurfaces 的反例——是真的 bug。沒過的有:"; printf '%s\n' "$failed" | sed 's/^/ /' ;; fail/fail) unexpected=1; say " 真的程式也走得出 AllSurfaces 的反例——是真的 bug。沒過的有:"; printf '%s\n' "$failed" | sed 's/^/ /' ;;

View File

@ -14,7 +14,7 @@
- 附件:「附加檔案」、拖進視窗、⌘V 貼圖。每個檔最多 50 MB,一個文字檔最多讀 20,000 字給模型。 - 附件:「附加檔案」、拖進視窗、⌘V 貼圖。每個檔最多 50 MB,一個文字檔最多讀 20,000 字給模型。
- 長對話:用到「模型可讀長度」的 7 成,先收起舊步驟的長結果,不夠才把舊對話寫成摘要,聊天裡出現「較早的對話已整理成摘要」(「展開摘要」)。 - 長對話:用到「模型可讀長度」的 7 成,先收起舊步驟的長結果,不夠才把舊對話寫成摘要,聊天裡出現「較早的對話已整理成摘要」(「展開摘要」)。
- 卡住偵測:120 秒還沒開始回應,顯示「模型未能及時開始回應。請重試。」;開始後安靜 35 秒,顯示「回應中斷:模型超過 35 秒沒有送出任何內容。」。等你允許、工具在跑時不算。 - 卡住偵測:120 秒還沒開始回應,顯示「模型未能及時開始回應。請重試。」;開始後安靜 35 秒,顯示「回應中斷:模型超過 35 秒沒有送出任何內容。」。等你允許、工具在跑時不算。
- 問題卡:Bot 用 `ask_person` 在聊天最下面(最新一則訊息之後)放一張卡,跟聊天一起上下捲,不會蓋住聊天;卡片出現和換下一題時聊天會自己捲到它,往上捲看完內容再捲回來回答(輸入框上方的臉旁邊寫「等你回答」,按「↓」回到最下面)。一次最多 6 題、每題最多 8 個選項:單選、複選(「可以選好幾個」)或填寫(「輸入回答」)。每題都有「自己回答」的框;按鈕有「下一題」/「送出」「上一題」「略過」。 - 問題卡:Bot 用 `ask_person` 在聊天最下面(最新一則訊息之後)放一張卡,跟聊天一起上下捲,不會蓋住聊天;卡片出現和換下一題時聊天會自己捲到它,往上捲看完內容再捲回來回答(輸入框上方的臉旁邊寫「等你回答」,按「↓」回到最下面)。一次最多 6 題、每題最多 8 個選項:單選、複選(「可以選好幾個」)或填寫(「輸入回答」)。每題都有「自己回答」的框;按鈕有「下一題」/「送出」「上一題」「略過」。換成另一張問題卡(就算編號一樣)就從第一題、什麼都沒選重新開始。
- 生活卡片(`show_card`):航班、地點、天氣、商品、活動,最多顯示 12 列,有網址時多一個「查看來源 ↗」。 - 生活卡片(`show_card`):航班、地點、天氣、商品、活動,最多顯示 12 列,有網址時多一個「查看來源 ↗」。
- 表情:你可以對 Bot 的回答按表情(6 個常用加「更多表情符號」),Bot 下一輪看得到;Bot 用 `react` 在你的訊息上按表情。 - 表情:你可以對 Bot 的回答按表情(6 個常用加「更多表情符號」),Bot 下一輪看得到;Bot 用 `react` 在你的訊息上按表情。
- 重新看圖(`look_image`):較早的圖片在模型那邊只剩一段摘要時,Bot 請看得懂圖的模型,針對一個問題重看其中一張。 - 重新看圖(`look_image`):較早的圖片在模型那邊只剩一段摘要時,Bot 請看得懂圖的模型,針對一個問題重看其中一張。

View File

@ -4509,14 +4509,16 @@ impl App {
// To the phone: not from a screen — its push would open the phone on the // To the phone: not from a screen — its push would open the phone on the
// screen, which runs nothing from a phone and shows it nothing (the 允許 // screen, which runs nothing from a phone and shows it nothing (the 允許
// vanished). The brain pushes its own for this card (the same 通知 setting, // vanished). The brain pushes its own for this card (the same 通知 setting,
// when it is away). 允許/拒絕 on the banner only where notice_answers says so // when it is away). A screen's own Notification hooks still run (hooks are
// (the brain checks the same rule when the answer comes back). // each computer's own, and they 跟著通知跑): only the push is the brain's.
if !self.mir.on { // 允許/拒絕 on the banner only where notice_answers says so (the brain checks
if notice_answers(a) { // the same rule when the answer comes back).
crate::remote::notify_approval(&title, &what, bot_id, &key); if self.mir.on {
} else { crate::hooks::notification(&title, &what, bot_id);
crate::remote::notify(crate::remote::Notice::Need, &title, &what, bot_id); } else if notice_answers(a) {
} crate::remote::notify_approval(&title, &what, bot_id, &key);
} else {
crate::remote::notify(crate::remote::Notice::Need, &title, &what, bot_id);
} }
} }
} }

View File

@ -2018,6 +2018,34 @@ mod phone_act_tests {
assert!(main_rx.try_recv().is_err() && app.approvals.contains_key(&main.id), "the main bot's card still waits"); assert!(main_rx.try_recv().is_err() && app.approvals.contains_key(&main.id), "the main bot's card still waits");
} }
/// A card that takes another's place with the same call id (call_0 every round) and the same
/// words — the same step asking again — is published again (the view's signature changes),
/// so the phone and the screens get the new card's key: with the old one every answer would
/// be refused. A 支線's card the same.
#[test]
fn a_card_in_anothers_place_is_published_again() {
let (_ctx, mut app) = demo();
let main = app.state.bots[0].clone();
let mut br = main.clone();
br.id = 9002;
br.branch_of = main.id;
br.messages.clear();
app.state.branch_bots.push(br);
let card = |app: &mut App, id: u64, key: &str| {
let (tx, _) = std::sync::mpsc::channel();
app.approvals.insert(id, crate::providers::Approval { call_id: "call_0".into(), tool: "shell".into(), reason: "執行指令:rm -rf build".into(), grant: String::new(), reply: tx, kind: ApprovalKind::Action });
app.ask_keys.insert(id, key.into());
};
card(&mut app, main.id, "k1");
let before = app.remote_signature();
card(&mut app, main.id, "k2");
assert_ne!(app.remote_signature(), before, "the main bot's new card is published");
card(&mut app, 9002, "b1");
let before = app.remote_signature();
card(&mut app, 9002, "b2");
assert_ne!(app.remote_signature(), before, "the 支線's new card is published");
}
/// 「全部允許,之後直接操作」 on a "may I use the computer?" card: 直接操作 lets that card /// 「全部允許,之後直接操作」 on a "may I use the computer?" card: 直接操作 lets that card
/// through as it comes on, then the phone's answer for it arrives — maybe after the next card /// through as it comes on, then the phone's answer for it arrives — maybe after the next card
/// is already up. That answer takes nothing, and isn't told as a stale one (the card was done). /// is already up. That answer takes nothing, and isn't told as a stale one (the card was done).