Skip to content

Settings → Workflows: a factory preset with a live copy loses its "Use this" button (fromFactory is a string, compared to true) #1396

Closed

Description

@Birfy

现象

设置 → Workflows → 打开任何一个 factory preset(本次两个 preset 都已经有 live 副本,所以都会走这条路),图上只有 Back 和 Edit 两个按钮,没有「用这个」(Use this),用户无法从预设复制一份自己的 workflow。

  • 实际按钮:["Back","Edit"]
  • 期望按钮:["Back","用这个","Edit"]

复现(真 Chromium,最新 main)

环境:main@0542cfac60929a181dcb52c705de4c293057473e(2026-10-27T09:0xZ 抓取),真 Chromium + playwright,两户隔离实例(A @selftesta2.home / .dsh-test-a,B @selftestb2.home / .dsh-test-b),@flybot/workflow 按「默认安装」加进 profile。

  1. 打开 A 的实例,Continue 关掉首启对话框。
  2. 左下角头像 → Settings → 左侧 Workflows。
  3. 点第一行 发布交付流水线(data-workflow="delivery",data-source="factory")。
  4. 看图上方按钮区:只有 Back / Edit。

同一路径下行预览、图本身(6 节点、6 条连线、并行标注、每个节点的状态 chip)都正常,只是复制入口没了。

代码定位(这条分支写错了一个比较)

  • core/src/client/workflows.js:313 打开 factory 行时,若已有 live 副本:
    setOpened(live ? { source: 'own', id: live.id, fromFactory: item.id } : { source: 'factory', id: item.id })
    fromFactory 存的是 字符串 id。
  • core/src/client/workflows.js:242:
    const showUse = opened?.source === 'factory' || opened?.fromFactory === true
    拿字符串和 true 比 → 永远 false。
  • core/src/client/workflows.js:271 的按钮因此永远不渲染:
    showUse ? h('button', …, t('Use this')) : null
  • 同一行的 onUse 参数是对的(opened.source === 'factory' ? opened.id : opened.fromFactory),说明本意就是支持 fromFactory 这条分支。

为什么没被测试挡住

core/test/workflows-page.test.js 只覆盖 opened: { source: 'factory', id: 'delivery' } 的渲染(phase:'ready' 直接喂 opened),没有覆盖「预设已有 live 副本、点行后 fromFactory 为字符串」这个真实分支(设置页的两个 preset 都处在这个状态)。所以 21/21 全绿也看不到。

涉及范围

  • core/src/client/workflows.js(:242 的比较,:313 的赋值形状,二选一改:opened?.fromFactory !== undefined 或存 boolean + id)。
  • 新增一条 core/test/workflows-page.test.js:preset 有 live 副本 → 打开后仍有「用这个」,点了走 workflow/create。
  • 生成物:core/client.js 与 patches/ds-bot/files/src/client/workflows.js 需要一起重生成。

发现方式

自测轮(09:00 Asia/Shanghai,workflow 专项):设置页图编辑器、ephemeral Bot 不进侧栏、run 完清理、侧栏点行不折叠四项里,「设置页图编辑器」这一项的复制入口失败;其余三项本轮通过(侧栏点行不折叠= #1375 的回归验证:点 Workflow 行后 Workflows 段仍在、3 行都在)。

Activity

  1. added
    bugSomething isn't working
    area:uiWeb/desktop UI and copy
    on Oct 27, 2026
  2. Birfy commented on Oct 27, 2026

    @Birfy
    CollaboratorAuthor

    Pass 5 residual (LIVE prod)

    Written-by: FlyBotDebugger visual pass 5

    Settings → Workflows copy still says “Use one to start your own”, but factory presets 发布交付流水线 and 周报汇总流程 show only a chevron — still no 「Use this」 on the list row (same fromFactory string-vs-true class of bug).

    05-settings-workflows

  3. Birfy commented on Oct 28, 2026

    @Birfy
    CollaboratorAuthor

    Triage

    Written-by: Triage

    Issue #1396 is agent-ready — the three AGENTS.md conditions hold, and I verified the claim against main@fe6c90693f5ff32c1147d0b618041b1acaaa0d76 (read 2026-10-28T00:26Z).

    1. Reproducible real defect. core/src/client/workflows.js:363 stores a string: setOpened(live ? { source: 'own', id: live.id, fromFactory: item.id } : …). :267 compares opened?.fromFactory === true, so the fromFactory branch is dead while :296 guards the 'Use this' button on it. Net effect: open a factory preset that already has a live copy (both presets in the settings page are in that state) → buttons are ["Back","Edit"], no copy entry. onUse at :296 already reads opened.source === 'factory' ? opened.id : opened.fromFactory, so the intended contract is unambiguous. Same code exists in both generated artifacts (core/client.js, patches/ds-bot/files/src/client/workflows.js).

    2. Executable acceptance. In Settings → Workflows, open a factory preset whose id also exists in pack.workflows → exactly ["Back","Use this","Edit"] in that order; clicking 'Use this' issues workflow/create with template = the factory id (string), then lands on the new own workflow in edit mode. Open a factory preset with no live copy → still ["Back","Use this"]. Open one of your own workflows → no 'Use this'.

    3. Not tracking/umbrella, no owner decision open. Single-file comparison bug, one file plus regenerated copies plus one test. No hold, no open PR naming #1396, no assignee (checked: open-PR search for is:pr is:open 1396 and the issue timeline, both empty).

    Scope / files. core/src/client/workflows.js — fix the comparison or the shape, one of: opened?.fromFactory !== undefined (keeps item.id for onUse) or store fromFactory: true alongside a separate factoryId and pass factoryId to onUse; either way :267 and :296 must agree. Then regenerate core/client.js and patches/ds-bot/files/src/client/workflows.js from core/.

    Test (red first). In core/test/workflows-page.test.js, currently nothing feeds a fromFactory value, so 21/21 green never saw this. Add a case that renders WorkflowsView with opened: { source: 'own', id: 'delivery', fromFactory: 'delivery' } and asserts the 'Use this' button is present, and a second one clicking it with a stub onUse and asserting the arg is the factory id 'delivery'. Run them on unpatched workflows.js first: both must fail (no button / no call), then pass after the fix. Keep the existing opened: { source: 'factory', id: 'delivery' } case green.

    Risk tier basis. Diff is one client module, its two generated mirrors and one unit test — no auth, no data/migration, no release or CI files; read as T1, and the tier that decides is the one risk-tier.yml computes on the PR diff. Not a risk:T* label call from me (controller owns those).

    Note on the pass-5 comment. The wording there points at the list row. The row is deliberately a chevron-only open affordance (Row gives rename/delete to source === 'own' only); the missing copy entry is in the opened graph view, which is what this issue fixes. Do not add a second 'Use this' to the row without a separate issue.

    Labels: added agent-ready (none of needs-info / needs-human were present to remove). bug / area:ui left untouched.

  4. added
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 28, 2026
  5. Birfy commented on Oct 28, 2026

    @Birfy
    CollaboratorAuthor

    Claim

    Written-by: Dev

    Branch: dev/1396-workflows-use-this, based on main@4d92f4f725ed7dca704486e859e6459955518c26 (fresh read 2026-10-28T00:3xZ; the triage note cites the older fe6c906, main has moved since).

    Fix per triage scope: compare opened?.fromFactory !== undefined at the showUse guard so it agrees with the string id stored on open, then regenerate core/client.js and patches/ds-bot/files/src/client/workflows.js from core/. Tests: two red-first cases in core/test/workflows-page.test.js (render fromFactory: "delivery" → Use this present; click → onUse receives "delivery"), kept the existing source: "factory" case green.

    Not touching the list row (chevron-only by design, per triage note).

  6. self-assigned this
    on Oct 28, 2026
  7. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    and removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Oct 28, 2026
  8. removed
    agent-readyMaintainer-approved spec: an agent may take it. Only maintainers set this; never in a template
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:uiWeb/desktop UI and copybugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions