Skip to content

[v2] 任务评论 @ 工作流:启动运行并在时间线展示结果 - #386

Merged
EricWvi merged 8 commits into
ora-space:mainfrom
wanglongan587:feat/1212-task-comment-workflow-mention
Nov 17, 2026
Merged

EricWvi merged 8 commits into
ora-space:mainfrom
wanglongan587:feat/1212-task-comment-workflow-mention

Conversation

@wanglongan587

@wanglongan587 wanglongan587 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Refs ora-space/circus#1212

v2,不涉及 specs。

改动

任务评论支持 @ 已发布工作流,按启动表单校验后以评论人身份启动,时间线展示实时状态、详情链接和最终输出,刷新后仍能读取。

  • 后端扩展评论/运行关联与 OpenAPI 契约;结构化表单文本在 CheckStart 前解码,非法输入按字段返回错误;评论启动不改变任务处理状态。
  • 同一 Idempotency-Key 并发或重放只产生一个评论和运行。Prepare/Start 拒绝且尚未执行时,事务撤销评论、pending 运行与初始 scope,原 key 可重试;已进入执行后才报错则保留历史,确认停止后记录安全失败原因。
  • 软删除运行后,时间线及同 key 重放不返回 output/error;前端也隐藏缓存中的旧输出、错误及详情链接。
  • README 说明与正式 Cloud 的差异,包括同 key 换内容仍返回原评论,以及已执行失败分支保留记录。

验证

最新 head:ab82530e706630ffdfdab42bef8128da149675f9。

CI 44057531396 三项全部通过:

  • server:gofmt、go vet、真实 PostgreSQL 上 go test -race -count=1 ./...,含启动失败清理、同 key 重试、执行后失败保留、软删除时间线与重放回归。
  • frontend:npm ci、生成客户端无漂移及完整 npm run check。
  • e2e:79 passed / 14 skipped,含评论 @ 工作流真实栈流程及新增软删除断言;跳过项需要外部资产等前置条件。

本地另通过协作域 7 个文件 / 88 个前端用例、typecheck、lint、生产构建及 Linux 目标 go vet。

@wanglongan587
wanglongan587 force-pushed the feat/1212-task-comment-workflow-mention branch from e996647 to f76f0f4 Compare November 17, 2026 02:55

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(f76f0f4)

@wanglongan587 我看了这个 PR,理解它是要让任务评论支持 @ 已发布工作流,按启动表单校验后以评论人身份幂等启动,并在时间线持续展示状态和最终结果。可以合并,有三处边界问题建议修正:表单 input 在启动时丢失、清空字段后仍使用默认值,以及多个活运行的 SSE 连接可能阻塞页面请求。前端定向测试通过,后端 HTTP 测试因缺少数据库配置未执行。

  • 🔧 3 处小改已写成建议(P2-1、P2-2、P2-3):见行内 suggestion,可以一键采纳,也可以不改或留到以后。
  • 测试:cd v2-server && go test ./internal/workflow -run 'TestDecodeFormStartValuesAndCheckStart|TestBuildStartForm' -count=1 通过;cd v2-server && go test -race ./internal/server -run '^TestTaskCommentWorkflow' -count=1 -v 没跑(未配置 TEST_DATABASE_URL,三个相关 HTTP 测试全部跳过。);cd frontend-v2 && npm test -- src/features/collaboration/comment-workflow.test.ts src/features/collaboration/task-page.test.tsx 通过;没跑全量和 e2e。

涉及对外 API/协议、数据迁移、并发核心,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 f76f0f4 · 第 1 轮(全量)

const errors: Record<string, string> = {}

for (const field of fields) {
const val = Object.hasOwn(draft, field.key) ? draft[field.key] : initialFieldDraft(field)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2-1(建议) 这里各分支遇到空值直接跳过,因此把有默认值的可选文本、数字或结构化字段清空后,实际提交的 values 不包含该字段,后端会继续使用图中的默认值。比如清空默认的结构化配置后,运行仍收到原配置,与表单显示不一致。建议先以 null 表示清空,再由非空分支覆盖;后端已有对应的清除语义。

Suggested change
const val = Object.hasOwn(draft, field.key) ? draft[field.key] : initialFieldDraft(field)
const val = Object.hasOwn(draft, field.key) ? draft[field.key] : initialFieldDraft(field)
values[field.key] = null

可直接采纳,也可以不改。

)
useEffect(() => {
if (!tenantId || !liveCommentRunIds || typeof EventSource === 'undefined') return
const sources = liveCommentRunIds.split(',').filter(Boolean).map(runId => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2-2(建议) 这里为每个活运行打开一个长期连接,数量没有上限。同一任务积累六个等待人工确认的运行时,在默认 Vite HTTP/1.1 环境下会占满浏览器的同源连接额度,时间线轮询和表单提交也会排队,轮询回退无法恢复页面。建议限制订阅数,其余运行继续由已有轮询刷新,并为普通请求预留连接。

Suggested change
const sources = liveCommentRunIds.split(',').filter(Boolean).map(runId => {
const sources = liveCommentRunIds.split(',').filter(Boolean).slice(0, 2).map(runId => {

可直接采纳,也可以不改。

Comment on lines +158 to +164
startInput := in.Input
if startInput == nil {
if _, hasExplicitInput := in.Values["input"]; !hasExplicitInput {
body := in.Body
startInput = &body
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2-3(建议) 当 Start 声明了名为 input 的字段时,前端会提交 values.input,这里却让顶层 startInput 保持 nil。已复现这组值通过 CheckStart,但 Engine.StartAs 再次调用 MirrorInput(nil) 后将其清除:必填字段会启动失败并留下已取消运行,可选字段则丢失输入。建议把显式填写的字符串同步到持久化的顶层输入。

Suggested change
startInput := in.Input
if startInput == nil {
if _, hasExplicitInput := in.Values["input"]; !hasExplicitInput {
body := in.Body
startInput = &body
}
}
startInput := in.Input
if startInput == nil {
if raw, hasExplicitInput := in.Values["input"]; hasExplicitInput {
var value *string
if err := json.Unmarshal(raw, &value); err == nil {
startInput = value
}
} else {
body := in.Body
startInput = &body
}
}

可直接采纳,也可以不改。

@wanglongan587
wanglongan587 force-pushed the feat/1212-task-comment-workflow-mention branch from f76f0f4 to c0c0fe2 Compare November 17, 2026 07:12

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(c0c0fe2)

@wanglongan587 我看了这个 PR,理解它是要让任务评论支持 @ 已发布工作流,按启动表单校验后以评论人身份幂等启动,并在时间线持续展示状态和最终结果。可以合并,建议补上评论启动后的工作流列表刷新,避免快速完成的运行无法通过时间线链接打开。上轮三条意见仍未处理,本轮不重复列出。

  • 🔧 1 处小改已写成建议(P2-4):见行内 suggestion,可以一键采纳,也可以不改或留到以后。
  • ⏳ 上轮还没处理的:P2-1、P2-2、P2-3(仍是建议,不影响合并)。
  • 测试:cd frontend-v2 && npm test -- src/features/collaboration/comment-workflow.test.ts src/features/collaboration/task-page.test.tsx 通过;cd v2-server && go test ./internal/workflow -run 'TestDecodeFormStartValuesAndCheckStart|TestBuildStartForm' -count=1 通过;cd v2-server && go test -race ./internal/server -run '^TestTaskCommentWorkflow' -count=1 -v 没跑(未配置 TEST_DATABASE_URL,三个相关 HTTP 测试全部跳过。);没跑全量和 e2e。

涉及对外 API/协议、数据迁移、并发核心,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 c0c0fe2 · 第 2 轮(全量)

{ headers: { 'Idempotency-Key': idempotencyKey } },
),
onSuccess: async (created, draft) => {
commentKeyRef.current = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2-4(建议) 这里成功后只通过 refresh() 刷新任务和时间线,没有刷新工作流列表。首次启动一个同步完成的工作流时,任务状态和版本不变,时间线也不会建立活运行的 SSE,而原本为空的 workflowHistory 不会轮询;此时点击卡片的「查看运行」仍显示空列表,直到刷新页面。建议创建关联运行后立即刷新工作流列表。

Suggested change
commentKeyRef.current = null
commentKeyRef.current = null
if (created.workflowRun) {
await client.invalidateQueries({ queryKey: ['task-workflow-runs', tenantId, taskId] })
}

可直接采纳,也可以不改。

@EricWvi EricWvi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner 验收第 1 轮(head c0c0fe27):0H/2M/4L。授权、并发幂等、结构化变量解码和 README 差异都成立,门槛全过。需要修两个 Medium,详情见 ora-space/circus#1212。

  • M1:taskworkflow/host.go:188-195 先提交评论和 pending 运行,Prepare/Start 失败后只取消运行。用同一个 Idempotency-Key 重试会走 !fresh 分支,返回 201 和已取消的运行,工作流永远不会启动。4xx 后前端换新 key 重发,又会多出一条评论。
  • M2:store/taskruns.go 的 taskCommentSelect 选取 r.output, r.error 时不看 deleted_at,task-discussion.tsx 只要是 succeeded 就渲染输出。运行软删后,时间线仍然显示完整输出。

@zhangxinhao zhangxinhao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM(b43a8d3)

@wanglongan587 我看了这个 PR,理解它是要让任务评论支持 @ 已发布工作流,按表单校验后以评论人身份幂等启动,并在时间线展示状态和结果。这是第 3 轮,我看了 c0c0fe2 之后的改动。整体没问题,可以合并。本轮增量未发现新问题;前四条建议仍未处理,本轮不重复列出。后端数据库回归测试因缺少配置未执行。

  • ⏳ 上轮还没处理的:P2-1、P2-2、P2-3、P2-4(仍是建议,不影响合并)。
  • 测试:cd frontend-v2 && npm test -- src/features/collaboration/task-discussion.test.tsx src/features/collaboration/comment-workflow.test.ts src/features/collaboration/task-page.test.tsx 通过;cd v2-server && go test ./internal/workflow -run 'TestDecodeFormStartValuesAndCheckStart|TestBuildStartForm' -count=1 通过;cd v2-server && go test -race ./internal/server -run '^TestTaskCommentWorkflow' -count=1 -v 没跑(已尝试运行,但未配置 TEST_DATABASE_URL,相关数据库测试全部跳过。);没跑全量和 e2e。

涉及对外 API/协议、数据迁移、删除数据、并发核心,建议 owner 再看一眼。

以上都是建议,怎么处理由你决定。

自动检视 · 基于 b43a8d3 · 第 3 轮(增量)

@EricWvi EricWvi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第 2 轮复审 0H/0M/4L:M1、M2、L1 已满足;L5–L8 另开跟进。

@EricWvi
EricWvi merged commit 543f81d into ora-space:main Nov 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants