Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en/wework/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Interrupting stops the current response but does not roll back completed file ed

The **Processed** section in an AI response displays tool calls from top to bottom by their actual creation time. Even when executor events arrive out of order, commands, file operations, and other tools created earlier remain above later activity so the timeline reflects the real execution sequence.

Completed processing activity is summarized by type. Terminal commands and Node.js REPL JavaScript calls count as commands, MCP and other capabilities count as tools, and file reads or edits use their own categories. Expand the processing area, then select a row or its chevron to inspect the details. The collapsed row uses a readable short name; the detail view shows the full tool name, invocation input, and returned output. Status-only activity without input or output does not show an empty disclosure control.

Conversations can be continued, renamed, copied to another device, or archived. Project conversations stay under their project; standalone conversations appear in the conversation list.

To branch from a completed AI response, move the pointer to its message actions and choose **Continue in new task**. The new task keeps the conversation context through that response and uses the same workspace. The source task and later messages remain unchanged. The action is hidden for streaming, cancelled, or unmappable Codex turns.
Expand Down
2 changes: 2 additions & 0 deletions docs/zh/wework/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ sidebar_position: 4

AI 回复中的“已处理”区域会按实际创建时间从上到下展示工具调用。即使执行器的事件到达顺序发生变化,较早创建的命令、文件操作或其他工具仍会显示在较早位置,便于按照真实执行过程阅读和排查任务。

已完成的处理活动会按类型汇总:终端命令和 Node.js REPL JavaScript 调用计入“命令”,MCP 等其他能力计入“工具”,文件读取和编辑则使用各自的分类。展开处理区域后,点击某一行或右侧箭头可以查看详情。折叠行使用便于阅读的短名称;详情中会显示完整工具名称、调用输入和返回输出。没有输入或输出的状态型活动不会显示无意义的展开按钮。

## 管理会话

任务可以继续对话、重命名、复制到其他设备或归档。项目会话显示在所属项目下;没有项目的会话显示在独立对话列表中。已归档会话可以在设置中恢复或删除。
Expand Down
107 changes: 106 additions & 1 deletion wework/e2e/desktop/task-flow.e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ const TOOL_BLOCK_ORDER_TASK_ID = 'wework-e2e-tool-block-order'
const TOOL_BLOCK_ORDER_TASK_TITLE = 'Tool block chronological order'
const TOOL_BLOCK_ORDER_COMPLETION_TEXT = 'WEWORK_DESKTOP_E2E_TOOL_BLOCK_ORDER_COMPLETE'
const EARLIER_TOOL_BLOCK_ID = 'wework-e2e-tool-earlier'
const NODE_REPL_TOOL_BLOCK_ID = 'wework-e2e-tool-node-repl'
const GENERIC_MCP_TOOL_BLOCK_ID = 'wework-e2e-tool-generic-mcp'
const LATER_TOOL_BLOCK_ID = 'wework-e2e-tool-later'
const SIDE_CHAT_PROMPT = 'WEWORK_DESKTOP_E2E_SIDE_CHAT: verify isolated attachments.'
const SIDE_CHAT_COMPLETION_TEXT = 'WEWORK_DESKTOP_E2E_SIDE_CHAT_COMPLETE'
Expand Down Expand Up @@ -2840,6 +2842,8 @@ async function seedToolBlockOrderTask(executorHome, workspacePath) {
})
const messageCreatedAt = Date.now()
const earlierCreatedAt = messageCreatedAt + 1_000
const nodeReplCreatedAt = messageCreatedAt + 1_300
const genericMcpCreatedAt = messageCreatedAt + 1_600
const laterCreatedAt = messageCreatedAt + 2_000

runtimeIndex.tasks ??= {}
Expand Down Expand Up @@ -2890,6 +2894,31 @@ async function seedToolBlockOrderTask(executorHome, workspacePath) {
createdAt: earlierCreatedAt,
completedAt: earlierCreatedAt + 100,
},
{
id: NODE_REPL_TOOL_BLOCK_ID,
subtaskId: TOOL_BLOCK_ORDER_TASK_ID,
type: 'tool',
toolName: 'mcp__node_repl__js',
toolInput: { code: "nodeRepl.write({ status: 'ready', value: 42 })" },
toolOutput: "{ status: 'ready', value: 42 }",
status: 'done',
createdAt: nodeReplCreatedAt,
completedAt: nodeReplCreatedAt + 100,
},
{
id: GENERIC_MCP_TOOL_BLOCK_ID,
subtaskId: TOOL_BLOCK_ORDER_TASK_ID,
type: 'tool',
toolName: 'github__issues__get_issue_details',
toolInput: { owner: 'wecode-ai', repo: 'Wegent', issue_number: 123 },
toolOutput: {
title: 'Tool detail verification',
state: 'open',
},
status: 'done',
createdAt: genericMcpCreatedAt,
completedAt: genericMcpCreatedAt + 100,
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
],
},
],
Expand Down Expand Up @@ -2931,6 +2960,8 @@ async function verifyToolBlockChronologicalOrder({
await control.command('click', '[data-testid="processing-summary-toggle"]')

const earlierSelector = `[data-processing-block-id="${EARLIER_TOOL_BLOCK_ID}"]`
const nodeReplSelector = `[data-processing-block-id="${NODE_REPL_TOOL_BLOCK_ID}"]`
const genericMcpSelector = `[data-processing-block-id="${GENERIC_MCP_TOOL_BLOCK_ID}"]`
const laterSelector = `[data-processing-block-id="${LATER_TOOL_BLOCK_ID}"]`
await control.command('waitFor', earlierSelector, {
visible: true,
Expand All @@ -2942,16 +2973,90 @@ async function verifyToolBlockChronologicalOrder({
stableMs: 500,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
await control.command('waitFor', nodeReplSelector, {
text: '运行 JavaScript',
visible: true,
stableMs: 500,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
await control.command('waitFor', genericMcpSelector, {
text: '调用 get issue details',
visible: true,
stableMs: 500,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
const [earlierMetrics] = JSON.parse(await control.command('getElementMetrics', earlierSelector))
const [laterMetrics] = JSON.parse(await control.command('getElementMetrics', laterSelector))
assert.ok(
earlierMetrics.top < laterMetrics.top,
`The later-created tool appeared above the earlier tool (${laterMetrics.top} <= ${earlierMetrics.top})`
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
await control.command('scrollIntoView', earlierSelector)
await captureVerificationScreenshot(
control,
'tool-block-order-01-chronological.png',
'[data-testid="message-assistant"]'
'[data-testid="processing-live-preview"]'
)

await control.command('click', `${nodeReplSelector} [data-tool-detail-toggle]`)
await control.command(
'waitFor',
`${nodeReplSelector} [data-testid="generic-tool-block-detail"]`,
{
text: 'mcp__node_repl__js',
visible: true,
stableMs: 500,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
}
)
await control.command('waitFor', `${nodeReplSelector} [data-testid="generic-tool-input"]`, {
text: "nodeRepl.write({ status: 'ready', value: 42 })",
visible: true,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
await control.command('waitFor', `${nodeReplSelector} [data-testid="generic-tool-output"]`, {
text: "{ status: 'ready', value: 42 }",
visible: true,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
await control.command('scrollIntoView', nodeReplSelector)
await captureVerificationScreenshot(
control,
'tool-block-details-02-node-repl-expanded.png',
nodeReplSelector
)

await control.command('click', `${nodeReplSelector} [data-tool-detail-toggle]`)
await control.command('click', `${genericMcpSelector} [data-tool-detail-toggle]`)
await control.command(
'waitFor',
`${genericMcpSelector} [data-testid="generic-tool-block-detail"]`,
{
text: 'github__issues__get_issue_details',
visible: true,
stableMs: 500,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
}
)
await control.command('waitFor', `${genericMcpSelector} [data-testid="generic-tool-input"]`, {
text: '"issue_number": 123',
visible: true,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
await control.command('waitFor', `${genericMcpSelector} [data-testid="generic-tool-output"]`, {
text: '"title": "Tool detail verification"',
visible: true,
timeoutMs: DEFAULT_STEP_TIMEOUT_MS,
})
await control.command('scrollIntoView', genericMcpSelector)
await control.command(
'clickIfPresent',
`${ACTIVE_WORKBENCH_SELECTOR} [data-testid="scroll-to-bottom-button"]`
)
await captureVerificationScreenshot(
control,
'tool-block-details-03-generic-mcp-expanded.png',
`${genericMcpSelector} [data-testid="generic-tool-block-detail"]`
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

Expand Down
46 changes: 43 additions & 3 deletions wework/src/components/chat/blocks/ToolBlockItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ describe('ToolBlockItem', () => {
scrollHeight.mockRestore()
})

test('renders unknown tool as a non-expandable activity row', () => {
test('renders unknown tool with generic input and output details', async () => {
const user = userEvent.setup()

render(
<ToolBlockItem
block={{
Expand All @@ -266,15 +268,53 @@ describe('ToolBlockItem', () => {
action: 'inspect',
payload: 'raw details should stay hidden',
},
toolOutput: {
status: 'ok',
},
status: 'done',
createdAt: 1770000000002,
}}
/>
)

expect(screen.getByText('调用 custom agent tool')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: /展开工具详情/ })).not.toBeInTheDocument()
expect(screen.queryByText(/raw details should stay hidden/)).not.toBeInTheDocument()
await user.click(screen.getByRole('button', { name: /展开工具详情/ }))

expect(screen.getByTestId('generic-tool-block-detail')).toHaveTextContent('custom_agent_tool')
expect(screen.getByTestId('generic-tool-input')).toHaveTextContent(
'raw details should stay hidden'
)
expect(screen.getByTestId('generic-tool-output')).toHaveTextContent('"status": "ok"')
})

test('renders node_repl js as JavaScript command activity with details', async () => {
const user = userEvent.setup()

render(
<ToolBlockItem
block={{
id: 'node-repl-js',
subtaskId: 1,
type: 'tool',
toolName: 'node_repl.js',
toolInput: {
code: "nodeRepl.write('hello')",
},
toolOutput: 'hello',
status: 'done',
createdAt: 1770000000002,
}}
/>
)

expect(screen.getByText('运行 JavaScript')).toBeInTheDocument()
expect(screen.queryByText('调用 js')).not.toBeInTheDocument()

await user.click(screen.getByRole('button', { name: /展开工具详情/ }))

expect(screen.getByTestId('generic-tool-block-detail')).toHaveTextContent('node_repl.js')
expect(screen.getByTestId('generic-tool-input')).toHaveTextContent("nodeRepl.write('hello')")
expect(screen.getByTestId('generic-tool-output')).toHaveTextContent('hello')
})

test('expands view_image tool details with an image preview', async () => {
Expand Down
102 changes: 100 additions & 2 deletions wework/src/components/chat/blocks/ToolBlockItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
isGuidanceToolName,
isImageViewToolName,
isFileReadToolName,
isNodeReplToolName,
} from './toolBlockKinds'
import { WebSearchActivityRows } from './WebSearchSources'
import { getWebSearchActivityItems } from './webSearchActivity'
Expand Down Expand Up @@ -139,6 +140,9 @@ export function ToolBlockItem({
searchError: t('tool_activity.search_error'),
imageView: filename => t('tool_activity.image_view', { filename }),
imageViewFallback: t('tool_activity.image_view_fallback'),
javascriptRunning: t('tool_activity.javascript_running'),
javascriptDone: t('tool_activity.javascript_done'),
javascriptError: t('tool_activity.javascript_error'),
})
const workspaceFilePath = getWorkspaceFilePath(block)
const labelContent = (
Expand Down Expand Up @@ -975,6 +979,9 @@ type GenericToolLabels = {
searchError: string
imageView: (filename: string) => string
imageViewFallback: string
javascriptRunning: string
javascriptDone: string
javascriptError: string
}

function getBlockLabel(
Expand All @@ -984,6 +991,15 @@ function getBlockLabel(
const name = block.toolName.toLowerCase()
const prefix = getToolStatusPrefix(block)

if (isNodeReplToolName(name)) {
const label =
block.status === 'error'
? genericLabels.javascriptError
: block.status === 'done'
? genericLabels.javascriptDone
: genericLabels.javascriptRunning
return { icon: <TerminalIcon />, label }
}
if (isCommandToolName(name)) {
const activityKind = getToolActivityKind(block)
if (activityKind === 'file') {
Expand Down Expand Up @@ -1228,20 +1244,102 @@ function renderBlockDetail(
return null
}

return null
return <GenericToolBlockDetail block={block} />
}

function hasBlockDetail(block: ToolBlock): boolean {
const name = block.toolName.toLowerCase()
return (
if (isGuidanceToolName(name)) return false
if (
isCommandToolName(name) ||
isFileCreateToolName(name) ||
isFileEditToolName(name) ||
isWebSearchToolName(name) ||
isImageViewToolName(name)
) {
return true
}
return block.toolInput !== undefined || block.toolOutput !== undefined
}

function GenericToolBlockDetail({ block }: { block: ToolBlock }) {
const { t } = useTranslation('chat')
const inputText = stringifyToolValue(block.toolInput)
const outputText = stringifyToolValue(block.toolOutput)
const isJavaScript = isNodeReplToolName(block.toolName)
const code = isJavaScript ? getInputField(block, 'code', 'javascript', 'source') : undefined

return (
<div
className="min-w-0 overflow-hidden rounded-lg border border-border bg-surface"
data-testid="generic-tool-block-detail"
>
<div className="flex min-w-0 items-center justify-between gap-3 border-b border-border px-3 py-2">
<span className="min-w-0 truncate font-mono text-xs text-text-secondary">
{block.toolName}
</span>
{isJavaScript ? <span className="shrink-0 text-xs text-text-muted">JavaScript</span> : null}
</div>
<div className="flex min-w-0 flex-col gap-3 p-3">
{code ? (
<ToolDetailSection
label={t('tool_activity.tool_input')}
content={code}
testId="generic-tool-input"
/>
) : inputText ? (
<ToolDetailSection
label={t('tool_activity.tool_input')}
content={inputText}
testId="generic-tool-input"
/>
) : null}
{outputText ? (
<ToolDetailSection
label={t('tool_activity.tool_output')}
content={outputText}
testId="generic-tool-output"
/>
) : block.status === 'done' ? (
<p className="text-xs text-text-muted">{t('tool_activity.tool_no_output')}</p>
) : null}
</div>
</div>
)
}

function ToolDetailSection({
label,
content,
testId,
}: {
label: string
content: string
testId: string
}) {
return (
<section className="min-w-0">
<div className="mb-1 text-xs text-text-muted">{label}</div>
<pre
className="max-h-48 max-w-full overflow-auto rounded-md bg-code-bg px-3 py-2 font-mono text-xs leading-5 whitespace-pre-wrap break-words text-text-secondary"
data-testid={testId}
>
{content}
</pre>
</section>
)
}

function stringifyToolValue(value: unknown): string {
if (value === undefined || value === null || value === '') return ''
if (typeof value === 'string') return value
try {
return JSON.stringify(value, null, 2)
} catch {
return String(value)
}
}

function ImageViewBlockDetail({ block }: { block: ToolBlock }) {
const { t } = useTranslation('chat')
const source = getImageViewSource(block)
Expand Down
Loading
Loading