Chat actionbar ask placement

From ai-shifu/ai-shifu · View interactive version

Chat actionbar ask placement is an AI agent skill from the GitHub repository ai-shifu/ai-shifu. Use when changing chat action bars, follow-up entry points, or AskBlock anchors. Keep content and actions synchronized and prevent duplicate inputs, empty menus, or misplaced controls.

How to use this skill

Skill file

操作栏与追问锚点

核心规则

工作流

  1. toggleAskExpanded 先执行同父级 ASK 去重,再切换展开态。
  2. 移除按钮时同步移除对应数据注入,避免空白操作栏。
  3. 移动端长按菜单在“无可展示动作”时不弹空菜单。
  4. 对 sys_lesson_feedback_score 这类隐藏正文的 interaction,同步隐藏操作栏。
  5. 给 slide 场景接追问时,优先复用现有 ask_list/parent_element_bid 映射,不要再额外复制一套问答状态。

备注

Current state contract and verification

useAskStateStore owns messages under lessonScopeKey + anchor element_bid.

Hydrate history through hydrateAskList / hydrateAskListMap. Their guards

skip identical lists, shorter incoming lists (including empty lists replacing

nonempty history), and equal-length incoming lists while the previous list

still contains a streaming message. They do not compare versions or freshness:

a different equal-length list can replace a finalized answer. Do not assume

protection against every stale snapshot.

setAskList rejects a mismatched lesson only when the caller supplies its

optional expectedLessonScopeKey; unscoped callers such as AskBlock do not

get that guard automatically. AskBlock, reading mode, and listen mode consume

the shared store. Do not reintroduce parent override maps, local message copies,

or token-by-token writes into useLessonConversation.items.

LessonConversation calls projectReadModeItems in chat-ui-mode-projection.ts to derive

missing ASK containers. buildReadModeItemsWithAskState in read-mode-items.ts

has no runtime caller and is not the owner of that live projection. The same

module exports normalizeReadModeDisplayItem, which projectReadModeItems

imports and calls for the active reading projection. Finalize controls action-row eligibility; avoid

adding a second completion gate or forcing ASK on interaction-only content.

Inspect use-ask-state-store.test.ts for the optional lesson-scope write guard,

LessonConversation.test.tsx for imported reading-projection helpers,

chat-ui-mode-projection.test.ts for listening projections, and

AskBlock.test.tsx for panel behavior in

src/app/c/[[...id]]/components/chat/. Run them with

npm test -- --runInBand --runTestsByPath from src/web; quote paths containing

brackets in a shell. The store suite does not cover the hydration guards, and the current projection

fixtures do not cover inserting a missing ASK container from stored messages.

Add focused cases when changing those paths. A stronger freshness guarantee

needs a separate state contract and regression coverage; these tests do not

establish one.

Mounted listen-mode follow-up panels

For an existing selected anchor, closing a listen-mode follow-up panel must

keep AskBlock mounted and pass the closed state through isExpanded. Hide

the host panel instead of conditionally removing AskBlock; this lets its

collapse cleanup and unfinished streaming answer retain the same lifecycle.

Do not reset the anchor or answer state merely because the user closes the

panel. This does not forbid a legitimate lesson/anchor change from replacing

its scoped instance.

The ListenModeSlideRenderer.test.tsx case

keeps the mobile ask block mounted and collapsed after closing the listen panel

in src/app/c/[[...id]]/components/chat/ verifies a mounted, collapsed block

with the same anchor after closure. The streaming Skill

also describes hidden in-flight typewriter behavior and terminal cleanup.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.