Implement the following plan: FetchURL Ctrl+Click 打开完整链接 (Kimi Web) Context FetchURL 工具的…
- User
Implement the following plan:
FetchURL Ctrl+Click 打开完整链接 (Kimi Web)
Context
FetchURL 工具的 URL 在 ToolHeader 中被截断显示(前50字符 +
…),用户无法点击打开完整链接。需求:仅对 FetchURL,Ctrl/Cmd+Click 截断 URL 时在新标签页打开完整链接,普通点击保持折叠功能不变。修改文件
web/src/components/ai-elements/tool.tsx—ToolHeader组件 (line 159-192)实现
- 从
input.url提取完整 URL(仅当rawName === "FetchURL"时) - 在 primaryParam 的
<span>上添加onClick:Ctrl/Cmd+Click 时stopPropagation+window.open(fullUrl),否则不处理
验证
- 触发 FetchURL(URL > 50 字符)→ Ctrl+Click 截断 URL → 新标签页打开完整链接
- 普通点击截断 URL → 折叠展开不变
- 其他工具的 primaryParam 无影响
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/moonshot/.REDACTED.jsonl
- 从
Assistant
Now let me also check the
getPrimaryParamfunction and theinputtype to understand how the URL is extracted.Assistant
Now I have a clear picture. I need to:
- Extract the full URL from
input.urlwhenrawName === "FetchURL" - Add an
onClickhandler to the primaryParam<span>that opens the URL on Ctrl/Cmd+Click
- Extract the full URL from
Assistant
Let me verify the final result looks correct.
Assistant
Now let me verify the build passes.
Assistant
TypeScript compilation passes with no errors. Here's a summary of the changes made to
web/src/components/ai-elements/tool.tsx:- Added
MouseEventimport from React (line 37) - Extracted
fullUrlfrominput.urlonly whenrawName === "FetchURL"(lines 172-178) - Added
handleParamClickcallback that checks for Ctrl/Cmd+Click, stops propagation (so the collapsible toggle doesn't fire), and opens the full URL in a new tab (lines 180-189) - Updated the primaryParam
<span>with:- Conditional
cursor-pointer hover:underlineclass when it's a FetchURL (visual affordance) titletooltip hint ("Ctrl+Click to open URL")onClickhandler bound only for FetchURL
- Conditional
Behavior:
- FetchURL with Ctrl/Cmd+Click on the truncated URL → opens full URL in new tab
- FetchURL with normal click → toggles collapse as before
- All other tools → completely unaffected (no handler, no extra styles)
- Added
- User
有个细节,在mac上是command+click。能否根据环境动态调整,有什么方案?
Assistant
这个改动很小——只需把
title里的提示文案根据平台动态切换。让我快速看一下项目中是否已有平台检测的工具函数。Assistant
项目中已有
isMacOS()工具函数(@/hooks/utils),且已有成熟的使用模式:isMacOS() ? "Cmd" : "Ctrl"。改动非常直接,更新计划文件。Assistant
改动很小且明确:项目已有
isMacOS()函数(@/hooks/utils),且多处使用isMacOS() ? "Cmd" : "Ctrl"模式。只需在 tooltip 文案处复用即可。- User
[Request interrupted by user for tool use]