feat(guid): polish assistant homepage UX and agent switching#1941
feat(guid): polish assistant homepage UX and agent switching#1941
Conversation
CI 检查未通过以下 job 在本次自动化 review 时未通过,请修复:
本次自动化 review 暂缓,待 CI 全部通过后将重新处理。 |
…, add split-button agent switcher - Replace active dot with agent backend logo (Gemini, Claude, etc.) in PresetAgentTag - Add inner divider between agent logo and assistant avatar for visual clarity - Left area of tag triggers agent type switcher dropdown; right × always closes - Lift agent switcher logic from AssistantSelectionArea to GuidPage - Add border to PresetAgentTag for better theme/dark mode visibility - Add :root block to retroma-obsidian-book-2.css to satisfy preset CSS test requirements - Register retroma-obsidian-book-2 in cssThemePresets test expected list
…telist and add required :root block
…s button only when expanded
When user clicks "New Chat" from the sidebar, navigate to /guid reuses the mounted GuidPage component so state was not cleared. Use location.key in a useEffect to reset selected agent, input, and description expanded state.
…st and add [data-theme=dark] block
- Restructure hero title row with back button, edit button, and agent type dropdown using unified BUILTIN_AGENT_OPTIONS and useAssistantBackends - Add inline description expand/collapse with overflow detection - Add agent logo icons to all agent type selectors across homepage and settings - Add Down chevron indicators to model/agent selector buttons - Implement collapsed sidebar layout with centered icon-only buttons - Reduce expanded sidebar element sizes for better proportion - Replace workspace collapse chevron with folder open/close icons - Compact search modal input (52px → 38px) with rounded corners - Add hover-based expand/collapse to SkillsMarketBanner - Move custom model hint from add-model modal to model list header - Remove agent tab content default padding, unify form item spacing - Route AgentPillBar + to settings/agent?tab=remote
Code Review:feat(guid): polish assistant homepage UX and agent switching (#1941)变更概述本 PR 对 assistant 主页(GuidPage)进行了大幅 UX 重构:新增 Hero 标题区控制栏(返回按钮、编辑入口、Agent 切换 Dropdown)、description 折叠展开逻辑、以及 SkillsMarketBanner 悬停展开效果。同时将 Agent 类型切换逻辑从 方案评估结论: 整体方向合理——将 Agent 切换逻辑上移到 GuidPage 统一管理、减少 prop drilling 是正确重构路径。但在上移过程中,旧版的错误处理被丢掉,且原本通过 问题清单🟠 HIGH — Agent 切换失败时无用户反馈文件: 问题代码: const handlePresetAgentTypeSwitch = useCallback(
async (nextType: string) => {
const customAgentId = agentSelection.selectedAgentInfo?.customAgentId;
if (!customAgentId || nextType === currentPresetAgentType) return;
const agents = ((await ConfigStorage.get('acp.customAgents')) || []) as AcpBackendConfig[];
const idx = agents.findIndex((a) => a.id === customAgentId);
if (idx < 0) return;
const updated = [...agents];
updated[idx] = { ...updated[idx], presetAgentType: nextType as PresetAgentType };
await ConfigStorage.set('acp.customAgents', updated);
await agentSelection.refreshCustomAgents();
const agentName = ACP_BACKENDS_ALL[nextType as PresetAgentType]?.name || nextType;
Message.success(t('guid.switchedToAgent', { agent: agentName }));
},
[agentSelection, currentPresetAgentType]
);问题说明:此函数无 try/catch,调用方只用 修复建议: const handlePresetAgentTypeSwitch = useCallback(
async (nextType: string) => {
const customAgentId = agentSelection.selectedAgentInfo?.customAgentId;
if (!customAgentId || nextType === currentPresetAgentType) return;
try {
const agents = ((await ConfigStorage.get('acp.customAgents')) || []) as AcpBackendConfig[];
const idx = agents.findIndex((a) => a.id === customAgentId);
if (idx < 0) {
Message.warning(t('common.failed', { defaultValue: 'Failed' }));
return;
}
const updated = [...agents];
updated[idx] = { ...updated[idx], presetAgentType: nextType as PresetAgentType };
await ConfigStorage.set('acp.customAgents', updated);
await agentSelection.refreshCustomAgents();
const agentName = ACP_BACKENDS_ALL[nextType as PresetAgentType]?.name || nextType;
Message.success(t('guid.switchedToAgent', { agent: agentName }));
} catch (error) {
console.error('[GuidPage] Failed to switch preset agent type:', error);
Message.error(t('common.failed', { defaultValue: 'Failed' }));
}
},
[agentSelection, currentPresetAgentType, t]
);🟠 HIGH — AssistantSelectionArea 模态树 JSX 重复文件: 问题说明:原有的 修复建议:恢复 const modalTree = (
<>
{agentMessageContext}
<AssistantEditDrawer ... />
<DeleteAssistantModal ... />
<AddSkillsModal ... />
<SkillConfirmModals ... />
<AddCustomPathModal ... />
</>
);
// 在两处 return 语句末尾直接使用 {modalTree}🟡 MEDIUM — selectedAssistantForSwitcher 不处理 builtin- 前缀文件: 问题代码: const selectedAssistantForSwitcher = useMemo(() => {
if (!agentSelection.isPresetAgent || !agentSelection.selectedAgentInfo?.customAgentId) return undefined;
return agentSelection.customAgents.find((a) => a.id === agentSelection.selectedAgentInfo?.customAgentId);
}, [...]);问题说明:同文件的 修复建议:复用 const currentPresetAgentType =
(selectedAssistantRecord?.presetAgentType as PresetAgentType | undefined) || 'gemini';删除 🔵 LOW — handlePresetAgentTypeSwitch useCallback 缺少 t 依赖文件: 问题代码: [agentSelection, currentPresetAgentType] // t 未列入依赖问题说明:函数体内使用了 汇总
结论本报告由本地 CONCLUSION: CONDITIONAL |
- Add try/catch to handlePresetAgentTypeSwitch with Message.error toast on failure - Fix currentPresetAgentType to use selectedAssistantRecord (handles builtin- prefix) - Extract modal tree into const to eliminate ~90-line JSX duplication Review follow-up for #1941
PR Fix 验证报告原始 PR: #1941
总结: ✅ 已修复 3 个 | ❌ 未能修复 0 个
|
…AI#1941) * feat(guid): polish assistant homepage interactions and agent switcher * refactor(guid): replace green dot with agent logo in preset agent tag, add split-button agent switcher - Replace active dot with agent backend logo (Gemini, Claude, etc.) in PresetAgentTag - Add inner divider between agent logo and assistant avatar for visual clarity - Left area of tag triggers agent type switcher dropdown; right × always closes - Lift agent switcher logic from AssistantSelectionArea to GuidPage - Add border to PresetAgentTag for better theme/dark mode visibility - Add :root block to retroma-obsidian-book-2.css to satisfy preset CSS test requirements - Register retroma-obsidian-book-2 in cssThemePresets test expected list * fix(tests): add retroma-obsidian-book-2-1-dark to preset CSS test whitelist and add required :root block * feat(guid): expand/collapse assistant description inline, show details button only when expanded * feat(guid): reset agent selection and input state on new chat navigation When user clicks "New Chat" from the sidebar, navigate to /guid reuses the mounted GuidPage component so state was not cleared. Use location.key in a useEffect to reset selected agent, input, and description expanded state. * fix(tests): add retroma-nocturne-parchment to preset CSS test whitelist and add [data-theme=dark] block * feat(guid): show toast after manually switching preset agent type * feat(guid): refine homepage hero, sidebar, search modal, and settings UI - Restructure hero title row with back button, edit button, and agent type dropdown using unified BUILTIN_AGENT_OPTIONS and useAssistantBackends - Add inline description expand/collapse with overflow detection - Add agent logo icons to all agent type selectors across homepage and settings - Add Down chevron indicators to model/agent selector buttons - Implement collapsed sidebar layout with centered icon-only buttons - Reduce expanded sidebar element sizes for better proportion - Replace workspace collapse chevron with folder open/close icons - Compact search modal input (52px → 38px) with rounded corners - Add hover-based expand/collapse to SkillsMarketBanner - Move custom model hint from add-model modal to model list header - Remove agent tab content default padding, unify form item spacing - Route AgentPillBar + to settings/agent?tab=remote * style: auto-format theme preset CSS files * fix(guid): use i18n name for assistant hero title * fix(i18n): remove duplicate shortTitle keys in conversation locale files * fix(tests): update AgentPillBar test for remote agent tab navigation * fix(guid): address review issues from PR iOfficeAI#1941 - Add try/catch to handlePresetAgentTypeSwitch with Message.error toast on failure - Fix currentPresetAgentType to use selectedAssistantRecord (handles builtin- prefix) - Extract modal tree into const to eliminate ~90-line JSX duplication Review follow-up for iOfficeAI#1941 --------- Co-authored-by: Waili(瓦砾) <[email protected]> Co-authored-by: zynx <>
Summary
This PR improves the assistant homepage experience and related interactions:
Why
Users should be able to understand:
without leaving the homepage.
Technical Notes
origin/mainto minimize merge conflict risk.oxlintandoxfmtbinaries are unavailable, so lint/format scripts could not be executed locally.