修正Agent聊天滚动与折叠布局

恢复开发聊天页整页纵向滚动
为Runtime恢复确认区保留独立布局行
修复展开折叠后Runtime与聊天内容重叠
补充确认区结构回归测试并修正文档
This commit is contained in:
AIGameCreator App
2026-07-11 18:00:36 +08:00
parent 50004d579c
commit 47ad28623a
5 changed files with 52 additions and 73 deletions
+27 -23
View File
@@ -5058,9 +5058,11 @@ export function WorkspaceLauncher({
</div>
</aside>
<section
className={`launcher-main${
launcherNotifications.length > 0 ? ' launcher-main-with-promo' : ''
}${launcherView === 'agent-chat' ? ' launcher-main-agent-chat' : ''}`}
className={
launcherNotifications.length > 0
? 'launcher-main launcher-main-with-promo'
: 'launcher-main'
}
>
{launcherNotifications.length > 0 ? (
<header className="launcher-promo" aria-label="通知">
@@ -5659,26 +5661,28 @@ export function WorkspaceLauncher({
}
/>
</section>
{agentChatResumeConfirmation ? (
<div className="pending-command" role="status">
<span>
agent.resume
<small>{agentChatResumeConfirmation.detail}</small>
</span>
<button
type="button"
onClick={cancelAgentChatRuntimeResume}
>
</button>
<button
type="button"
onClick={() => void confirmAgentChatRuntimeResume()}
>
</button>
</div>
) : null}
<div className="launcher-agent-resume-slot">
{agentChatResumeConfirmation ? (
<div className="pending-command" role="status">
<span>
agent.resume
<small>{agentChatResumeConfirmation.detail}</small>
</span>
<button
type="button"
onClick={cancelAgentChatRuntimeResume}
>
</button>
<button
type="button"
onClick={() => void confirmAgentChatRuntimeResume()}
>
</button>
</div>
) : null}
</div>
<div className="launcher-agent-chat-messages" aria-label="Agent 聊天记录">
{agentChatMessages.length > 0 ? (
agentChatMessages.map((message, index) => (
+7 -48
View File
@@ -295,12 +295,6 @@ textarea {
overflow: hidden;
}
.launcher-main-agent-chat {
height: 100vh;
min-height: 0;
padding-bottom: 0;
}
.launcher-promo {
display: flex;
align-items: center;
@@ -1043,13 +1037,7 @@ textarea {
}
.launcher-agent-chat-page {
grid-template-rows: auto minmax(0, 1fr);
box-sizing: border-box;
height: 100vh;
max-height: 100vh;
padding-top: 92px;
padding-bottom: 24px;
overflow: hidden;
}
.launcher-agent-chat-page > header .launcher-project-list-actions button {
@@ -1074,16 +1062,13 @@ textarea {
grid-template-columns: minmax(220px, 0.3fr) minmax(0, 1fr);
gap: 12px;
width: 100%;
height: 100%;
min-width: 0;
min-height: 0;
overflow: hidden;
min-height: min(620px, calc(100vh - 168px));
}
.launcher-agent-chat-sidebar,
.launcher-agent-chat-main {
min-width: 0;
min-height: 0;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #fff;
@@ -1091,11 +1076,9 @@ textarea {
.launcher-agent-chat-sidebar {
display: grid;
grid-template-rows: auto minmax(0, 1fr);
align-content: stretch;
align-content: start;
gap: 12px;
padding: 12px;
overflow: hidden;
}
.launcher-agent-chat-project {
@@ -1123,9 +1106,8 @@ textarea {
.launcher-agent-picker {
display: grid;
gap: 8px;
min-height: 0;
max-height: 450px;
overflow: auto;
overscroll-behavior: contain;
}
.launcher-agent-picker button {
@@ -1167,9 +1149,8 @@ textarea {
.launcher-agent-chat-main {
display: grid;
grid-template-rows: auto auto auto minmax(0, 1fr) auto;
height: 100%;
overflow: hidden;
grid-template-rows: auto auto auto auto minmax(320px, auto) auto;
overflow: visible;
}
.launcher-agent-chat-main > header {
@@ -1278,11 +1259,9 @@ textarea {
display: grid;
align-content: start;
gap: 10px;
min-height: 320px;
padding: 14px;
overflow: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
contain: layout paint;
overflow: visible;
}
.launcher-agent-chat-messages .message {
@@ -1324,11 +1303,6 @@ textarea {
.launcher-agent-runtime-stack {
display: grid;
gap: 8px;
max-height: min(44vh, 420px);
overflow: auto;
overscroll-behavior: contain;
scrollbar-gutter: stable;
contain: layout paint;
}
.launcher-agent-runtime-stack:empty {
@@ -1791,21 +1765,7 @@ textarea {
.launcher-agent-chat-layout {
grid-template-columns: 1fr;
height: auto;
min-height: auto;
overflow: visible;
}
.launcher-agent-chat-page {
grid-template-rows: auto auto;
height: auto;
max-height: none;
padding-bottom: 24px;
overflow: visible;
}
.launcher-agent-chat-sidebar {
overflow: visible;
}
.launcher-agent-picker {
@@ -1813,7 +1773,6 @@ textarea {
}
.launcher-agent-chat-main {
height: auto;
min-height: 620px;
}
@@ -1095,6 +1095,22 @@ describe('AI 游戏创作 App 界面边界', () => {
);
const confirmation = detail.closest('.pending-command');
expect(confirmation).not.toBeNull();
const resumeSlot = confirmation?.closest('.launcher-agent-resume-slot');
expect(resumeSlot).not.toBeNull();
const agentChatMain = confirmation?.closest('.launcher-agent-chat-main');
const chatMessages = agentChatMain?.querySelector(
'.launcher-agent-chat-messages',
);
expect(chatMessages).not.toBeNull();
expect(
Array.from(agentChatMain?.children ?? []).indexOf(
resumeSlot as HTMLElement,
),
).toBeLessThan(
Array.from(agentChatMain?.children ?? []).indexOf(
chatMessages as HTMLElement,
),
);
expect(screen.getByText('agent.resume')).not.toBeNull();
expect(
invoke.mock.calls.filter(
@@ -21,7 +21,7 @@
- 背景:开发用单 Agent 聊天已经能真实调用各 Agent 的 LLM 路由并持久化对话,但 Agent 仍主要表现为同步问答,用户无法明确投递一个任务让某个 Agent 独立运行,也无法同时启动多个 Agent 的工作。
- 决策:在现有 `.agent/runtime``.agent/conversations` 基础上新增单 Agent 后台任务入口。Tauri 命令 `start_game_creator_agent_runtime_task` 立即写入该 Agent 的 runtime state/event/task history,追加用户任务到 `.agent/conversations/agents/<agentId>.jsonl`,随后在 App 进程内启动 tokio task 执行最小 Agent loopAgent 按轮输出 `thinkingSummary / plan / actions / response`,Runtime 按白名单和项目权限策略执行工具并记录 `action / observation` 事件,再把已有 observation 放回下一轮 prompt,让 Agent 修正计划、继续行动或用空 actions + response 收束;当前后台任务最多执行 3 轮 loop,仍未收束时再按最后计划和全部观察生成最终回复。完成或失败后把 assistant 回复或错误追加回对话,并写入 `.agent/agent.db` 审计记录。工具箱包含只读工具 `memory.read``conversation.read``asset.list``project.index``project.diff``file.list``file.read``agent.run_status`,以及受策略保护的写/运行工具 `memory.write``file.write``command.run_limited``blackboard.write``agent.message``agent.delegate``memory.write` 可追加或覆盖本 Agent 私有记忆、项目长期/短期记忆或黑板,`file.write` 只能写项目内相对路径,`command.run_limited` 只接受 `game.static_smoke` 并复用本地静态自检安全边界,`blackboard.write` 追加共享黑板,`agent.message` 写目标 Agent 对话,`agent.delegate` 把任务投递到目标 Agent 的独立后台队列;策略拒绝时不执行工具并把 `blocked` observation 回给 Agent;策略要求确认时不执行工具,而是持久化精确待确认动作并暂停该 Agent 队列,待开发者确认或拒绝后在同一 run 续跑。每个 Agent 的任务历史落在 `.agent/runtime/tasks/<agentId>.jsonl`,读 runtime 时按 `runId` 去重返回最近任务,任务视角状态使用 `pending / running / completed / failed`Runtime state 增加 `nextStep`UI 在 Runtime 面板和主 Agent 状态卡展示当前任务、动作、下一步与最近任务。不同 Agent 使用独立 `.agent/runtime/locks/<agentId>.lock`,允许并行运行;同一 Agent 已有运行任务时,新任务会先进入该 Agent 的 pending 队列,当前 drain 持锁完成后串行继续下一条 pending。该能力仍不是独立 OS 进程或跨重启离线常驻 worker。
- 2026-07-10 补充:后台 Runtime 每次追加 `.agent/runtime/events/<agentId>.jsonl` 后会通过 Tauri `game-creator-agent-runtime-update` 事件广播当前 `AgentRuntimeResult`;开发单 Agent 聊天页、项目内 Agent 对话弹窗和主窗口 Agent 状态列表都只把该事件作为实时 UI 通知并复用前端 runtime 归一化合并,事实源仍是 `.agent/runtime/agents``events``tasks` 文件。
- 2026-07-11 补充:开发单 Agent 聊天页桌面端固定在当前视口内,Agent 列表、Runtime 状态和聊天记录使用各自的有界滚动区,避免长状态详情把整个 WebView 撑高并在实时事件更新时触发整页布局。Runtime 面板详情可折叠且折叠时不渲染详情 DOM,但状态标题与任务控制按钮继续保留;连续流式 delta 合并到动画帧更新,并跳过 delta 内重复的 Runtime state 提交。
- 2026-07-11 补充:开发单 Agent 聊天页保留整页纵向滚动,Runtime 恢复确认区使用独立布局行,避免与 Runtime 详情或聊天内容重叠。Runtime 面板详情可折叠且折叠时不渲染详情 DOM,但状态标题与任务控制按钮继续保留;连续流式 delta 合并到动画帧更新,并跳过 delta 内重复的 Runtime state 提交。
- 2026-07-10 补充:后台 Agent Runtime 的白名单工具继续扩到 `preview.start`,让 Agent 在完成写盘或静态自检后能按策略自行启动当前项目的 `127.0.0.1` 本地 HTTP 预览。该工具复用 `preview.start` 权限策略、项目写锁、共享 `PreviewRegistry`、manifest 预览状态、`.agent/logs/preview.log` 和 run trace 追加逻辑;写入 `.agent/agent.db` 的审计类型为 `agent.runtime.preview.start`。发给 LLM 的 observation 只包含 localhost URL 和端口,不包含用户项目绝对路径。
- 2026-07-10 补充:后台 Agent Runtime 的白名单工具继续扩到 `canvas.asset_generate`,让美术类 Agent 可在 loop 中自行请求生成首版美术素材。该工具读取 AppData / Tauri 配置中的 `editorApi`,复用 `canvas.asset_generate` 权限策略、项目写锁、External Editor API 生成和下载链路、manifest 资产登记以及 `canvas.asset_generate` 本地索引记录;另写 `agent.runtime.canvas.asset_generate` 记录到 `.agent/agent.db`,标明触发的 agent 与本地素材路径。API Key 不进入 prompt observation、manifest、agent.db 或日志;策略要求确认或拒绝时不会调用外部 API。
- 补充:规范 Agent ID 统一使用 manifest taskId,例如 `art-asset-plan``code-prototype`;历史前端曾使用的 `group-role` 别名只在 Tauri command 层兼容并映射到规范 taskId。主窗口 Agent 状态列表通过 `read_game_creator_agent_runtimes` 批量读取 `.agent/runtime/agents/<taskId>.json` 和最近任务,把每个 Agent 的 Runtime 状态、当前动作和最近 task 直接显示在状态卡片和 `/agents` 汇总里。
@@ -52,7 +52,7 @@ Agent Runtime 负责:
- 2026-07-10 补充:`recentEvents` 接入前端归一态和 Runtime 状态面板,事件事实源仍是 `.agent/runtime/events/<agentId>.jsonl`;面板按时间展示最近 `thinking_summary / plan / action / observation / response / error` 事件,现在能同时看到 Agent 的计划、最近观察、最近事件、最近工具动作和任务队列。
- 2026-07-10 补充:后台 Runtime 每次追加 `.agent/runtime/events/<agentId>.jsonl` 后会通过 Tauri `game-creator-agent-runtime-update` 事件广播当前 `AgentRuntimeResult`,开发单 Agent 聊天页、项目内 Agent 对话弹窗和主窗口 Agent 状态卡用同一套前端归一化逻辑合并状态;该事件只做实时 UI 通知,`.agent/runtime/agents``events``tasks` 仍是重开项目后的事实源。
- 2026-07-10 补充:后台 Agent loop 的统一语义事件类型为 `thinking_summary / plan / action / observation / response / error`。普通失败和 loop 预算耗尽都会追加 `error` 事件,并继续保留 `turn.failed / turn.budget_exhausted` 生命周期事件兼容既有读取方;开发窗口、项目内 Agent 对话弹窗和主窗口状态卡通过现有最近事件列表直接展示统一错误事件及其安全详情。状态面板默认保持最新 4 条的紧凑视图,当前后端返回的最近事件超过 4 条时可展开查看全部返回记录,确保同一 run 的六类语义事件不会因 UI 硬截断而无法检查。
- 2026-07-11 补充:开发单 Agent 聊天页在桌面视口内固定壳层高度,Agent 列表、Runtime 状态和聊天记录分别承担局部滚动,避免长 Runtime 详情持续撑高整个 WebView。Runtime 状态面板支持折叠详情,折叠时只卸载目标、计划、事件、动作和任务等详情 DOM,仍保留状态标题与取消、重试、确认、拒绝、刷新操作;流式聊天的连续 delta 通过 `requestAnimationFrame` 合并为每帧最多一次消息更新,delta 不重复提交未变化的 Runtime state,控制流式回复期间的布局与重绘范围。
- 2026-07-11 补充:开发单 Agent 聊天页继续使用整页纵向滚动,不把 Runtime 和聊天记录锁进固定视口或嵌套纵向滚动区;可选的 Runtime 恢复确认区始终占据独立布局行,不能与 Runtime 详情或聊天消息重叠。Runtime 状态面板支持折叠详情,折叠时只卸载目标、计划、事件、动作和任务等详情 DOM,仍保留状态标题与取消、重试、确认、拒绝、刷新操作;流式聊天的连续 delta 通过 `requestAnimationFrame` 合并为每帧最多一次消息更新,delta 不重复提交未变化的 Runtime state,控制流式回复期间的布局与重绘范围。
- 2026-07-10 补充:Agent Runtime state / result 新增 `taskQueue`,从 `.agent/runtime/tasks/<agentId>.jsonl` 中每个 `runId` 的最新记录汇总 `total / pending / running / completed / failed / latestRunId`;开发窗口 Runtime 面板、主窗口 Agent 状态列表、`agent.run_status` observation 和下一轮 planning prompt 都读取该摘要,用于判断同一 Agent 是否仍有排队任务。该字段是运行观测摘要,不新增调度器、SQLite 或独立 worker。
- 2026-07-10 补充:Runtime 新增 `agent.schedule_ready` 调度入口。开发构建可在权限确认后扫描 manifest ready task,把依赖已完成且仍为 `pending` 的任务标成 `running`,并按 taskId 投递到对应 Agent 的既有后台队列;source 固定为 `agent-ready-task-scheduler`,审计记录写 `agent.runtime.ready_task.scheduled`。该入口只把 manifest ready task 接入现有 per-agent 队列、锁、JSONL、LLM loop、工具策略和事件流,不新增独立 worker,也不会在默认确认策略下静默启动。
- 2026-07-10 补充:主窗口 Agent 状态栏的“调度 Ready”只在开发模式显示。点击后复用项目策略确认弹窗,确认通过才调用 `schedule_game_creator_agent_ready_tasks`,并把返回的 Runtime 合并回 Agent 状态卡;普通用户窗口继续只展示状态和单 Agent 对话入口,不直接暴露 ready-task 调度按钮。