Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 24 additions & 14 deletions docs/en/user-guide/coding/managing-code-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ This guide explains how to create, execute, and manage code-type tasks in Wegent
A code task is a task type in Wegent specifically designed for software development. Unlike regular chat tasks, code tasks connect to Git repositories, allowing AI agents to make code changes directly in the repository.

**Core Concept**:

```
Code Task = User Prompt + Code Agent + Git Repository + Branch
```

### Code Tasks vs Chat Tasks

| Feature | Code Task | Chat Task |
|---------|-----------|-----------|
| **Git Repository** | Required | Optional |
| **Code Execution** | Runs in Docker container | No code execution |
| **Workbench** | Shows file changes, commit history | Not displayed |
| **Branch Management** | Auto-creates feature branches | None |
| **Use Cases** | Development, refactoring, bug fixes | Q&A, analysis, documentation |
| Feature | Code Task | Chat Task |
| --------------------- | ----------------------------------- | ---------------------------- |
| **Git Repository** | Required | Optional |
| **Code Execution** | Runs in Docker container | No code execution |
| **Workbench** | Shows file changes, commit history | Not displayed |
| **Branch Management** | Auto-creates feature branches | None |
| **Use Cases** | Development, refactoring, bug fixes | Q&A, analysis, documentation |

---

Expand Down Expand Up @@ -146,13 +147,13 @@ graph LR

### Task States

| Status | Description | Actions |
|--------|-------------|---------|
| **PENDING** | Waiting to execute | Can cancel |
| **RUNNING** | Currently executing | Can stop |
| **COMPLETED** | Execution finished | Can view results, create PR |
| **FAILED** | Execution failed | Can retry |
| **CANCELLED** | Was cancelled | Can recreate |
| Status | Description | Actions |
| ------------- | ------------------- | --------------------------- |
| **PENDING** | Waiting to execute | Can cancel |
| **RUNNING** | Currently executing | Can stop |
| **COMPLETED** | Execution finished | Can view results, create PR |
| **FAILED** | Execution failed | Can retry |
| **CANCELLED** | Was cancelled | Can recreate |

### Stopping a Task

Expand Down Expand Up @@ -187,6 +188,7 @@ After task completion, you can continue chatting with the agent:
View detailed execution information in the Workbench:

- **Execution Timeline**: See tools used by AI and execution order
- **Tool Duration**: Shows seconds below one minute, then minutes and seconds from one minute onward
- **Commit History**: View all code commits
- **File Changes**: See specific modifications for each file

Expand Down Expand Up @@ -235,49 +237,57 @@ For API details, see [Runtime Cleanup](../../developer-guide/runtime-cleanup.md)
### Q1: Task stuck in PENDING status?

**Possible causes**:

1. No available execution containers
2. Repository access permission issues
3. Git token expired

**Solutions**:

- Check if system resources are sufficient
- Verify Git token is valid
- Check repository access permissions

### Q2: Code commit failed?

**Possible causes**:

1. Branch protection rules
2. Insufficient permissions
3. Network issues

**Solutions**:

- Check target branch protection rules
- Confirm Git token has write permissions
- Retry the task

### Q3: AI modified the wrong files?

**Solutions**:

1. Explicitly specify file paths to modify in the task
2. Provide more detailed context information
3. Use knowledge base to provide project structure documentation

### Q4: How to make AI follow project coding standards?

**Solutions**:

1. Add `.cursorrules` or `.windsurfrules` file in repository root
2. Explicitly state coding standards in task description
3. Use knowledge base to provide coding standards documentation

### Q5: Task execution taking too long?

**Possible causes**:

1. Task scope too large
2. Need to install many dependencies
3. Network latency

**Solutions**:

- Split large tasks into smaller ones
- Use pre-configured base images
- Check network connection
Expand Down
36 changes: 23 additions & 13 deletions docs/zh/user-guide/coding/managing-code-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ sidebar_position: 2
代码任务是 Wegent 中专门用于软件开发的任务类型。与普通聊天任务不同,代码任务会连接到 Git 仓库,AI 智能体可以直接在仓库中进行代码修改。

**核心概念**:

```
代码任务 = 用户提示词 + 代码智能体 + Git 仓库 + 分支
```

### 代码任务 vs 聊天任务

| 特性 | 代码任务 | 聊天任务 |
|------|----------|----------|
| **Git 仓库** | 必需 | 可选 |
| **代码执行** | 在 Docker 容器中执行 | 无代码执行 |
| **工作台** | 显示文件变更、提交历史 | 不显示 |
| **分支管理** | 自动创建功能分支 | 无 |
| **适用场景** | 代码开发、重构、修复 | 问答、分析、文档 |
| 特性 | 代码任务 | 聊天任务 |
| ------------ | ---------------------- | ---------------- |
| **Git 仓库** | 必需 | 可选 |
| **代码执行** | 在 Docker 容器中执行 | 无代码执行 |
| **工作台** | 显示文件变更、提交历史 | 不显示 |
| **分支管理** | 自动创建功能分支 | 无 |
| **适用场景** | 代码开发、重构、修复 | 问答、分析、文档 |

---

Expand Down Expand Up @@ -146,13 +147,13 @@ graph LR

### 任务状态

| 状态 | 描述 | 操作 |
|------|------|------|
| **PENDING** | 等待执行 | 可取消 |
| **RUNNING** | 正在执行 | 可停止 |
| 状态 | 描述 | 操作 |
| ------------- | -------- | ------------------- |
| **PENDING** | 等待执行 | 可取消 |
| **RUNNING** | 正在执行 | 可停止 |
| **COMPLETED** | 执行完成 | 可查看结果、创建 PR |
| **FAILED** | 执行失败 | 可重试 |
| **CANCELLED** | 已取消 | 可重新创建 |
| **FAILED** | 执行失败 | 可重试 |
| **CANCELLED** | 已取消 | 可重新创建 |

### 停止任务

Expand Down Expand Up @@ -187,6 +188,7 @@ graph LR
在工作台中查看详细的执行信息:

- **执行时间线**:查看 AI 使用的工具和执行顺序
- **工具耗时**:不足 1 分钟时按秒显示,达到 1 分钟后按“分 + 秒”显示
- **提交历史**:查看所有代码提交
- **文件变更**:查看每个文件的具体修改

Expand Down Expand Up @@ -235,49 +237,57 @@ graph LR
### Q1:任务一直处于 PENDING 状态?

**可能原因**:

1. 没有可用的执行容器
2. 仓库访问权限问题
3. Git 令牌过期

**解决方案**:

- 检查系统资源是否充足
- 验证 Git 令牌是否有效
- 检查仓库访问权限

### Q2:代码提交失败?

**可能原因**:

1. 分支保护规则
2. 权限不足
3. 网络问题

**解决方案**:

- 检查目标分支的保护规则
- 确认 Git 令牌有写入权限
- 重试任务

### Q3:AI 修改了错误的文件?

**解决方案**:

1. 在任务中明确指定要修改的文件路径
2. 提供更详细的上下文信息
3. 使用知识库提供项目结构说明

### Q4:如何让 AI 遵循项目的编码规范?

**解决方案**:

1. 在仓库根目录添加 `.cursorrules` 或 `.windsurfrules` 文件
2. 在任务描述中明确说明编码规范
3. 使用知识库提供编码规范文档

### Q5:任务执行时间过长?

**可能原因**:

1. 任务范围过大
2. 需要安装大量依赖
3. 网络延迟

**解决方案**:

- 将大任务拆分成小任务
- 使用预配置的基础镜像
- 检查网络连接
Expand Down
23 changes: 21 additions & 2 deletions wework/src/components/chat/blocks/ToolBlocksDisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ describe('ToolBlocksDisplay', () => {
expect(screen.getByRole('button', { name: /已处理 6 分 8 秒/ })).toBeInTheDocument()
})

test('formats live duration with natural Chinese units', () => {
test('formats live duration with minutes and seconds after one minute', () => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-06-05T00:00:00.000Z'))

Expand All @@ -777,7 +777,26 @@ describe('ToolBlocksDisplay', () => {
vi.advanceTimersByTime(62000)
})

expect(screen.getByText('62 秒')).toBeInTheDocument()
expect(screen.getByText('1 分 2 秒')).toBeInTheDocument()
})

test('formats exactly one minute with zero remaining seconds', () => {
vi.useFakeTimers()
vi.setSystemTime(new Date('2026-06-05T00:00:00.000Z'))

const runningBlock: ProcessingBlock = {
...completedCommandBlock,
status: 'streaming',
createdAt: Date.now(),
}

render(<ToolBlocksDisplay blocks={[runningBlock]} isStreaming={true} />)

act(() => {
vi.advanceTimersByTime(60000)
})

expect(screen.getByText('1 分 0 秒')).toBeInTheDocument()
})

test('keeps ticking while streaming even when all tool blocks are done', () => {
Expand Down
6 changes: 5 additions & 1 deletion wework/src/components/chat/blocks/processingDuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export function getWholeSecondsDurationText(
isRunning: boolean
): string {
const durationMs = getProcessingDurationMs(blocks, turnStartedAt, now, completedAt, isRunning)
return `${Math.floor(durationMs / 1000)} 秒`
const seconds = Math.floor(durationMs / 1000)
if (seconds < 60) return `${seconds} 秒`

const minutes = Math.floor(seconds / 60)
return `${minutes} 分 ${seconds % 60} 秒`
}

function getProcessingDurationMs(
Expand Down
Loading