feat: 問題卡搬進聊天裡,跟訊息一起上下捲,不再蓋住聊天

問題卡(ask_person、/plan 的「照這個計畫做嗎?」)原本固定在輸入框上方、高度封在視窗的 45%,
選項一多就蓋住大半聊天,按鈕還被切在卡片裡面要再捲。
- 電腦:卡片是聊天最下面的一則,照內容多高就多高;出現和換下一題時聊天捲到它一次
  (比視窗高時對齊卡片上緣,先看到題目),之後往上捲不會被拉回來。
- 手機:一樣放進聊天的捲動區(#askq)。
- 允許請求的黃色卡片不動,還是固定在輸入框上方。
- 功能地圖(chat、plan)和 FEATURES.md 一起改。
- 模式圖示的 id 從 Id::new 改成 Id::unique(上一個 commit 留下的過時用法警告)。
- 獨立審查沒有 P0/P1;修了它提的 4 個 P2(手機改成捲動區自己捲、同一個 call_id 的下一張卡
  也會捲到、太高的卡對齊上緣、搜尋跳到訊息時不搶捲動)。

已驗證: cargo test 全綠(613,含 featuremap::、layout_audit::);截圖模式(示範資料、深色、760x560)
  看過問題卡在聊天裡的樣子;mobile/index.html 的 script 解析得過。
未驗證: 「往上捲開再回來」沒有實際操作(截圖模式只有一張圖);手機網頁沒有在手機或瀏覽器上點過;
  功能地圖 chat「驗證:」那一行要真的模型用問題卡問三件事,這次沒跑;大腦的螢幕(mirror)沒試。

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
王性驊 2026-11-17 15:17:51 +08:00
parent 6a5fd2d53e
commit d64766e953
5 changed files with 53 additions and 35 deletions

View File

@ -380,7 +380,8 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
### 問題卡(原版的 question card;2026-11-12)
- Bot 需要你做決定或補資料時,用 `ask_person` 在輸入框上方放一張黃色卡片問你,不再把一串問題寫成文字。這一回合會停下來等你。
- Bot 需要你做決定或補資料時,用 `ask_person` 放一張黃色卡片問你,不再把一串問題寫成文字。這一回合會停下來等你。
- 卡片在聊天最下面(最新一則訊息之後),跟聊天同一層、一起上下捲,照內容有多高就多高(以前固定在輸入框上方,選項一多就蓋住大半聊天、按鈕還要在卡片裡捲)。卡片出現和換下一題時聊天自己捲到它;往上捲看前面的內容不會被拉回來,按「↓」回到卡片。電腦和手機一樣。允許請求的黃色卡片(短)還是固定在輸入框上方。
- 一次最多 6 題,卡片一題一題走,左上寫「(Bot) 問你 · 2/3」。每題可以是:
- **單選**:最多 8 個選項,點一下就選好並跳到下一題;最後一題點了就送出。
- **複選**(標「可以選好幾個」):打勾幾個都行,再按「下一題」或「送出」。
@ -391,7 +392,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
- 不按卡片、直接在輸入框打字送出:卡片收起來、算沒回答,Bot 照你打的做。
- Bot 收到的結果是「使用者的回答:1. (題目) → (答案)…」;聊天裡這一步顯示「問你 (第一題)(共 N 題)」,點開看得到答案。
- 側邊欄和面板在等的時候寫「等你回答」,輸入框上方那張臉旁邊也是;不在 App 前面時的通知標題是「(Bot) 問你」。
- 手機版有同一張卡片(選項可點、可填寫、上一題、略過);打到一半畫面更新不會把字清掉。連到別台大腦的電腦上回答,答案會送回大腦。
- 手機版有同一張卡片,也在聊天裡跟著捲(選項可點、可填寫、上一題、略過);打到一半畫面更新不會把字清掉。連到別台大腦的電腦上回答,答案會送回大腦。
- 密碼、卡號、驗證碼不走這張卡(Bot 被交代用保險庫或請你接手電腦)。訊息管道(Slack、Telegram…)和例行任務裡沒有人在 App 前面,Bot 被交代改用文字問。
- 打開「直接操作」不會替你回答問題卡或「需要處理」的卡片(以前會把「需要處理」當成「我完成了」)。
- 同一張問題卡問第二次、你給一樣的答案,不算「同一步重複」(那個檢查只管 Bot 自己重複做同樣的事)。
@ -1620,7 +1621,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- **用法**:「/plan 要做的事」開始(Bot 正在做事時不行,先等它做完或按停止);「/plan」看計畫和進度;「/plan clear」取消(stop、取消…也可以)。電腦、大腦的螢幕、手機打的都算,由大腦處理;團隊的管理員也能用,成員和訊息管道打的不算指令。群組聊天還不能用;最多 4000 字。
- **計畫模式(還沒核准)**:Bot 只能看——讀檔、列資料夾、搜尋、讀網頁(web_fetch、瀏覽器打開/讀取/捲動)、截圖、查記憶和技能、查功能地圖。執行指令、改檔案、點擊、打字、送出、改設定在執行那一層就被擋下,回給 Bot「計畫還沒核准」(不是只靠提示詞,跟 Claude Code、Codex、Gemini CLI 一樣)。它先自己查清楚現況,查得到的不問;有你才能決定的取捨,用問題卡一次問完(最多 3 題、建議的放第一個),你略過就用建議的並寫成假設。
- **計畫卡**:Bot 用 submit_plan 交出計畫,聊天裡是一張「計畫」卡:一兩句摘要、照順序的步驟(通常 3 到 7 步,每步是一個看得到的結果,最後一步是驗證)、「怎麼確認做對了」、「注意」(假設、風險、花錢、對外送出、不能復原的)。只寫它建議的那一個做法。研究顯示錯的計畫比沒有計畫更糟,所以要求它根據查到的事實、寧可短而對。
- **核准**:輸入框上方的問題卡「照這個計畫做嗎?」:「開始照計畫做」、「先不要」,或直接打字寫要改哪裡(它改完再交一張新卡,舊卡變「已修改,見下面新版」)。在卡片外傳訊息也算要修改;只有按「開始照計畫做」才算核准,不會等太久自己核准。按「先不要」或略過,計畫就取消,什麼都沒做。
- **核准**:聊天最下面的問題卡「照這個計畫做嗎?」(跟聊天一起捲):「開始照計畫做」、「先不要」,或直接打字寫要改哪裡(它改完再交一張新卡,舊卡變「已修改,見下面新版」)。在卡片外傳訊息也算要修改;只有按「開始照計畫做」才算核准,不會等太久自己核准。按「先不要」或略過,計畫就取消,什麼都沒做。
- **照計畫做**:核准後同一輪接著做(不用再傳訊息),所有工具打開,第 1 步自動標成進行中;它每做完一步用 update_plan 更新一次(整份清單、同時只有一步進行中;不用每個小動作都更新——Manus 發現打勾佔了三分之一的動作)。計畫和實際不符就改清單並在訊息裡說為什麼,大改先問。卡上的步驟跟著打勾(✓ 做完、▸ 進行中、– 略過),輸入框上方臉的同一行右邊一個計畫圖示,旁邊寫「2/5」,滑過去看「照計畫做 · 2/5 · 現在這一步」和整份清單,點一下有「取消計畫」。全部做完那一輪結束時留一行「計畫完成:5 步都做完了。」,計畫清掉。
- **只管你自己的訊息**:例行任務、訊息管道和團隊成員的訊息照平常做,不受計畫模式限制。照計畫做的期間每一輪都帶著這份計畫(像 Claude Code 把核准的計畫交回給模型),所以聊別的事前先取消。清除聊天記錄、開始新對話會連計畫一起清掉;分享 Bot 的檔案不含計畫。重開 AnyBot 計畫還在;還沒核准時重開,傳一句話它就接著規劃。
- 手機一樣:計畫卡、問題卡都有;目標和計畫在輸入框上方是一排小圖示(計畫旁邊寫「2/5」),點一下展開那一行和「清除目標」/「取消計畫」。

View File

@ -14,7 +14,7 @@
- 附件:「附加檔案」、拖進視窗、⌘V 貼圖。每個檔最多 50 MB,一個文字檔最多讀 20,000 字給模型。
- 長對話:用到「模型可讀長度」的 7 成,先收起舊步驟的長結果,不夠才把舊對話寫成摘要,聊天裡出現「較早的對話已整理成摘要」(「展開摘要」)。
- 卡住偵測:120 秒還沒開始回應,顯示「模型未能及時開始回應。請重試。」;開始後安靜 35 秒,顯示「回應中斷:模型超過 35 秒沒有送出任何內容。」。等你允許、工具在跑時不算。
- 問題卡:Bot 用 `ask_person` 在輸入框上方放一張卡,一次最多 6 題、每題最多 8 個選項:單選、複選(「可以選好幾個」)或填寫(「輸入回答」)。每題都有「自己回答」的框;按鈕有「下一題」/「送出」「上一題」「略過」。
- 問題卡:Bot 用 `ask_person` 在聊天最下面(最新一則訊息之後)放一張卡,跟聊天一起上下捲,不會蓋住聊天;卡片出現和換下一題時聊天會自己捲到它,往上捲看完內容再捲回來回答(輸入框上方的臉旁邊寫「等你回答」,按「↓」回到最下面)。一次最多 6 題、每題最多 8 個選項:單選、複選(「可以選好幾個」)或填寫(「輸入回答」)。每題都有「自己回答」的框;按鈕有「下一題」/「送出」「上一題」「略過」。
- 生活卡片(`show_card`):航班、地點、天氣、商品、活動,最多顯示 12 列,有網址時多一個「查看來源 ↗」。
- 表情:你可以對 Bot 的回答按表情(6 個常用加「更多表情符號」),Bot 下一輪看得到;Bot 用 `react` 在你的訊息上按表情。
- 重新看圖(`look_image`):較早的圖片在模型那邊只剩一段摘要時,Bot 請看得懂圖的模型,針對一個問題重看其中一張。
@ -29,7 +29,7 @@
## 怎麼操作
- Bot:要使用者做決定或補資料時用 `ask_person`(questions:question、options、multiple、default;已經知道的先填進 default),不要把一串問題寫成文字;查到航班、店家、天氣這類就用 `show_card`(kind、title、subtitle、rows、link);適合時用 `react`(emoji)按個表情;舊圖的摘要不夠(小字、精確數字)時用 `look_image`(index:0 是最新一張,附圖和截圖一起往回數;question 要具體)。
- 驗證:送一則要用工具的訊息,工作中再送一句,要看到「已排入…」,Bot 在同一輪回應那句;按停止,送出鈕變回來、Bot 不再動作;在最後一則回答的 ⋯ 按「重新產生」,再按「還原上一個答案」,舊答案要回來;請 Bot「用問題卡問我三件事」,卡片要一題一題走,按「略過」後 Bot 照自己的判斷繼續。自動測試:`cargo test agent::`、`cargo test ask::`、`cargo test app::chat_ui::`、`cargo test attach::`、`cargo test app::tests::`、`cargo test layout_audit::`(最窄的視窗裡允許卡片的按鈕會換行、「已排入…」和輸入框的提示不會被切掉)。
- 驗證:送一則要用工具的訊息,工作中再送一句,要看到「已排入…」,Bot 在同一輪回應那句;按停止,送出鈕變回來、Bot 不再動作;在最後一則回答的 ⋯ 按「重新產生」,再按「還原上一個答案」,舊答案要回來;請 Bot「用問題卡問我三件事」,卡片要出現在聊天最下面、能跟著聊天往上捲開,一題一題走,按「略過」後 Bot 照自己的判斷繼續。自動測試:`cargo test agent::`、`cargo test ask::`、`cargo test app::chat_ui::`、`cargo test attach::`、`cargo test app::tests::`、`cargo test layout_audit::`(最窄的視窗裡允許卡片的按鈕會換行、「已排入…」和輸入框的提示不會被切掉)。
## 陷阱

View File

@ -7,7 +7,7 @@
- 開始:「/plan 要做的事」(最多 4,000 字)。「/plan」看目前的計畫,「/plan clear」(或 stop、取消)取消。
- 計畫模式(還沒核准):只能看——讀檔、列資料夾、搜尋、`web_fetch`、瀏覽器的打開/讀取/捲動、截圖、查記憶和技能、`anybot_guide`。執行指令、改檔案、點擊、打字、送出、改設定都會被擋下(擋在執行那一層,不是只靠提醒)。有使用者才能決定的取捨,用問題卡一次問完(最多 3 題,建議的選項在第一個);略過的話 Bot 用建議的那個,寫成假設。
- 計畫卡:Bot 用 `submit_plan` 交出計畫,聊天裡出現一張「計畫」卡:一兩句摘要、照順序的步驟(通常 3 到 7 步,最後一步是驗證)、「怎麼確認做對了」、「注意」(假設、風險、會花錢或對外送出的地方)。卡右上角寫狀態:等你決定、照著做 · 2/5、已核准、已修改(見下面新版)、沒有採用;修改過或沒採用的只剩摘要。
- 核准:輸入框上方的問題卡「照這個計畫做嗎?」:「開始照計畫做」、「先不要」,或直接打字寫要改哪裡(Bot 改完再交一張新卡)。在卡片之外傳訊息也算要修改;只有按「開始照計畫做」才算核准,不會自己過期核准。
- 核准:聊天最下面的問題卡「照這個計畫做嗎?」(跟聊天一起捲):「開始照計畫做」、「先不要」,或直接打字寫要改哪裡(Bot 改完再交一張新卡)。在卡片之外傳訊息也算要修改;只有按「開始照計畫做」才算核准,不會自己過期核准。
- 照計畫做:核准後同一輪接著做,工具全部打開,第 1 步自動標成進行中。Bot 每做完一步用 `update_plan` 更新一次(整份清單,同時只有一步進行中);計畫和實際不符就改清單並說為什麼,大改先問。計畫卡上的步驟跟著打勾(✓ 做完、▸ 進行中、– 略過)。
- 完成:全部步驟做完(或略過)那一輪結束時,聊天裡留一行「計畫完成:5 步都做完了。」,計畫清掉。

View File

@ -288,6 +288,9 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.mode::after{content:"";position:absolute;inset:-8px -2px}
.mode.on .ic{color:var(--accent)}
.mode.open{box-shadow:inset 0 0 0 1px var(--text3)}
/* 問題卡: in the chat, after the newest message (it scrolls with it), as tall as its content. */
#askq{padding:0 14px}
#askq .ask{max-height:none;overflow:visible;margin:4px auto 14px}
.goalbar{max-width:560px;margin:0 auto 6px;display:flex;align-items:center;gap:8px;font-size:var(--fs-small);color:var(--text2);background:var(--hover);border-radius:var(--r-m);padding:5px 6px 5px 11px}
.goalbar .t{flex:1;min-width:0;display:flex;align-items:center;gap:6px}
.goalbar .t span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@ -611,7 +614,7 @@ button,.row,.ib,.island,.opt,.chip,.tab,label.sw,[role="button"]{-webkit-user-se
<button class="ib" id="b-newchat" title="開始新對話"></button>
<button class="ib" id="b-chatmore" title="更多"></button>
</div>
<div class="scroll" id="scroller"><div class="msgs" id="msgs"></div></div>
<div class="scroll" id="scroller"><div class="msgs" id="msgs"></div><div id="askq"></div></div>
<button class="down" id="b-down" title="到最新的訊息"></button>
<div class="dock">
<div id="ask"></div>
@ -1568,8 +1571,9 @@ function renderDock() {
const b = bot(S.open) || {};
const a = S.approvals.find((x) => x.bot === S.open);
clearInterval(thumbTimer);
if (a && a.kind === "question" && owner()) { renderQuestion(a); renderDockRest(b); return; }
if (a && a.kind === "question" && owner()) { $("ask").innerHTML = ""; renderQuestion(a); renderDockRest(b); return; }
ASKF = null;
$("askq").innerHTML = "";
if (!a) $("ask").innerHTML = "";
else if (!owner()) $("ask").innerHTML = `<div class="ask"><div class="q">${esc(a.title)}</div><div class="why">等擁有者或管理員決定</div></div>`;
else if (a.kind === "handoff") {
@ -1608,12 +1612,18 @@ function renderQuestion(a, force) {
ASKF = {id: a.call_id, step: 0, drawn: -1, picks: qs.map((q) => { const k = (q.options || []).indexOf(q.default); return k >= 0 && q.default ? [k] : []; }), typed: qs.map((q) => (q.options || []).length ? "" : (q.default || ""))};
}
// Drawn already: leave it, or what is being typed would be lost on every refresh.
if (!force && ASKF.drawn === ASKF.step && $("ask").querySelector(".own")) return;
if (!force && ASKF.drawn === ASKF.step && $("askq").querySelector(".own")) return;
const i = ASKF.step, q = qs[i], opts = q.options || [], last = i + 1 === qs.length;
ASKF.drawn = i;
const own = !!(ASKF.typed[i] || "").trim();
$("ask").innerHTML = `<div class="ask"><div class="asknum">${esc(a.title)}${qs.length > 1 ? ` · ${i + 1}/${qs.length}` : ""}</div><div class="q">${esc(q.question)}</div><div class="why">${q.multiple ? "可以選好幾個" : ""}</div>${opts.map((o, k) => `<button class="opt ${q.multiple ? "many" : ""} ${ASKF.picks[i].includes(k) && (q.multiple || !own) ? "on" : ""}" data-k="${k}"><i></i><span>${esc(o)}</span></button>`).join("")}<input class="own" enterkeyhint="${last ? "send" : "next"}" placeholder="${opts.length ? "自己回答" : "輸入回答"}" value="${esc(ASKF.typed[i])}"><div class="btns"><button class="btn main" data-go="next">${last ? "送出" : "下一題"}</button>${i > 0 ? `<button class="btn" data-go="back">上一題</button>` : ""}<button class="btn" data-go="skip">略過</button></div></div>`;
const box = $("ask"), field = box.querySelector(".own"), go = box.querySelector('[data-go="next"]');
$("askq").innerHTML = `<div class="ask"><div class="asknum">${esc(a.title)}${qs.length > 1 ? ` · ${i + 1}/${qs.length}` : ""}</div><div class="q">${esc(q.question)}</div><div class="why">${q.multiple ? "可以選好幾個" : ""}</div>${opts.map((o, k) => `<button class="opt ${q.multiple ? "many" : ""} ${ASKF.picks[i].includes(k) && (q.multiple || !own) ? "on" : ""}" data-k="${k}"><i></i><span>${esc(o)}</span></button>`).join("")}<input class="own" enterkeyhint="${last ? "send" : "next"}" placeholder="${opts.length ? "自己回答" : "輸入回答"}" value="${esc(ASKF.typed[i])}"><div class="btns"><button class="btn main" data-go="next">${last ? "送出" : "下一題"}</button>${i > 0 ? `<button class="btn" data-go="back">上一題</button>` : ""}<button class="btn" data-go="skip">略過</button></div></div>`;
const box = $("askq"), field = box.querySelector(".own"), go = box.querySelector('[data-go="next"]');
// The chat comes to the card when it appears and at each next question.
// (Once laid out; a card taller than the screen shows its question, not its buttons.)
requestAnimationFrame(() => {
const sc = $("scroller"), top = box.getBoundingClientRect().top - sc.getBoundingClientRect().top + sc.scrollTop;
sc.scrollTo({top: box.offsetHeight > sc.clientHeight ? top : sc.scrollHeight, behavior: "smooth"});
});
const ready = () => { go.disabled = !askAnswer(q, i); };
ready();
const send = async (body) => { ASKF = null; box.innerHTML = ""; try { await api(base() + `api/bots/${(a && a.target) || S.open}/answer`, {json: body}); } catch (e) { toast(e.message); } };

View File

@ -2711,7 +2711,7 @@ impl App {
}
// (An id of its own: the popup stays open while cards come and go above.)
let (rect, _) = at.allocate_exact_size(vec2(26.0, 26.0), egui::Sense::hover());
let r = at.interact(rect, egui::Id::new(("mode", bot.id, m.end)), egui::Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand);
let r = at.interact(rect, egui::Id::unique(("mode", bot.id, m.end)), egui::Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand);
if r.hovered() {
at.painter().rect_filled(rect, 7.0, p.hover);
}
@ -3706,7 +3706,8 @@ impl App {
}
self.sending_bubbles(ui, &bot);
// (What it is doing, and a request, sit above the input: see composer.
// A hand-off keeps its card here, with the live screen.)
// A hand-off keeps its card here, with the live screen; so does a
// question — it scrolls with the chat instead of covering it.)
self.approval_card(ui, ctx, &bot);
ui.add_space(16.0);
// Last in the content, so no code block's own scroll area takes it.
@ -3917,8 +3918,11 @@ impl App {
fn approval_card(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
let p = self.pal;
let _ = p;
if self.approvals.get(&bot.id).map(|a| a.kind) == Some(ApprovalKind::Handoff) {
self.handoff_card(ui, ctx, bot);
match self.approvals.get(&bot.id).map(|a| a.kind) {
Some(ApprovalKind::Handoff) => self.handoff_card(ui, ctx, bot),
Some(ApprovalKind::Question) => self.question_card(ui, ctx, bot),
// (The next card comes into view again, even one with the same id.)
_ => ui.data_mut(|d| d.remove::<(String, usize)>(egui::Id::unique(("ask-seen", bot.id)))),
}
}
@ -3930,8 +3934,8 @@ impl App {
/// `enter`: the composer took a plain Enter that is this card's (the box is empty).
fn approval_dock(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot, draft_empty: bool, typing: bool, enter: bool) {
let p = self.pal;
// (A question's card is in the chat: see question_card.)
if self.approvals.get(&bot.id).is_some_and(|a| a.kind == ApprovalKind::Question) {
self.question_dock(ui, ctx, bot);
return;
}
self.ask_forms.remove(&bot.id);
@ -3991,11 +3995,13 @@ impl App {
self.mark();
}
/// 問題卡, docked above the input like a request: one question at a time. A choice is one
/// click (it moves on, and on the last question sends); several choices and typed answers
/// have 下一題/送出. 「自己回答」 is always there, and so is writing a message instead, which
/// leaves the card unanswered.
fn question_dock(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
/// 問題卡, the last thing in the chat (it used to be docked above the input, where a card
/// with several choices covered most of what the bot had just said): it scrolls with the
/// messages, as tall as its content, and the chat comes to it when it appears or moves to
/// the next question. One question at a time. A choice is one click (it moves on, and on
/// the last question sends); several choices and typed answers have 下一題/送出. 「自己回答」
/// is always there, and so is writing a message instead, which leaves the card unanswered.
fn question_card(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
let p = self.pal;
let Some(a) = self.approvals.get(&bot.id) else { return };
let call_id = a.call_id.clone();
@ -4013,12 +4019,11 @@ impl App {
Skip,
}
let mut act = None;
// (選項再多也不許把輸入框頂出螢幕:卡面照內容估高、照視窗高度封頂,裡面在卡面裡往下捲。)
let cap = (ui.ctx().content_rect().height() * 0.45).max(160.0);
let body = ask_card_height(q, ui.available_width(), cap);
ui.add_space(10.0);
let top = ui.cursor().top();
needs_you_card(ui, p, |ui| {
ui.set_width(ui.available_width());
egui::ScrollArea::vertical().id_salt(("ask-dock", bot.id, call_id.clone())).max_height(body).min_scrolled_height(body).auto_shrink([false, false]).show(ui, |ui| {
ui.vertical(|ui| {
if qs.len() > 1 {
ui.label(RichText::new(format!("{} 問你 · {}/{}", bot.name, step + 1, qs.len())).size(FONT_SM).color(p.text2));
} else {
@ -4089,6 +4094,18 @@ impl App {
});
});
});
// The chat comes to the card once for each question (after that the person scrolls as
// they like: up to read what it is about, back down to answer).
let seen_id = egui::Id::unique(("ask-seen", bot.id));
let now_at = (call_id.clone(), step);
// (Not while a search is taking the chat to a message: the card's turn comes after.)
if self.goto.is_none() && ui.data(|d| d.get_temp::<(String, usize)>(seen_id)).as_ref() != Some(&now_at) {
ui.data_mut(|d| d.insert_temp(seen_id, now_at));
let card = egui::Rect::from_min_max(egui::pos2(ui.min_rect().left(), top), egui::pos2(ui.min_rect().right(), ui.cursor().top() + 16.0));
// A card taller than the window shows its question, not its buttons.
let tall = card.height() > ui.clip_rect().height();
ui.scroll_to_rect(card, Some(if tall { Align::TOP } else { Align::BOTTOM }));
}
ui.add_space(6.0);
match act {
Some(Act::Skip) => self.answer(ctx, bot.id, ApprovalAnswer::Reject),
@ -7324,12 +7341,6 @@ fn ask_dock_height(reason: &str, width: f32, cap: f32) -> f32 {
(wrapped_lines(detail, (width - 92.0).max(120.0), cw) * 17.0 + 168.0).min(cap)
}
/// The question card's content height: header + question + option rows + field + buttons.
fn ask_card_height(q: &crate::ask::Question, width: f32, cap: f32) -> f32 {
let q_lines = wrapped_lines(&q.question, (width - 64.0).max(120.0), 16.0);
(26.0 + q_lines * 21.0 + q.options.len() as f32 * 44.0 + 122.0).min(cap)
}
fn composer_box_h(text_h: f32, max_h: f32) -> f32 {
(text_h + COMPOSER_TOP + 3.0).clamp(28.0, max_h.max(28.0))
}
@ -9062,10 +9073,6 @@ mod tests {
assert!((1.0..=cap + 0.01).contains(&short), "short {short} cap {cap} w {width}");
assert!((1.0..=cap + 0.01).contains(&long), "long {long} cap {cap} w {width}");
assert!(long >= short, "a longer reason got a shorter card at w {width}");
let q = |n: usize| crate::ask::Question { question: "請選一個要彙整的資料夾".into(), options: (0..n).map(|i| format!("選項 {i}")).collect(), multiple: false, default: String::new() };
let (few, many) = (ask_card_height(&q(2), width, cap), ask_card_height(&q(8), width, cap));
assert!((1.0..=cap + 0.01).contains(&few) && (1.0..=cap + 0.01).contains(&many), "question card over the cap at w {width}");
assert!(many >= few, "more options made the card shorter at w {width}");
}
}
// The composer's box: at least one row, never past its own cap.