Skip to content

[Feature] 支持为远端工作区(devcontainer/SSH/WSL)创建和调度自动化任务 #950

Description

@nightwares

问题类别 · Category: 功能建议 · Feature Request(自动化 / 远程工作区 · Automations / Remote workspaces)
Agent 框架 · Framework: ZCode Agent(自研)
严重程度 · Severity: 影响体验 · Major(远端工作区无法使用自动化)
复现频率 · Reproducibility: 必现 · Always

问题描述 · Description

连接 devcontainer(或 SSH/WSL 远端工作区)时,自动化(定时任务)存在两处断点:

  1. 远端页面 "立即运行" 报错 "Could not trigger run":Automations 页面在远端工作区激活时解析到容器内的远端 server(packages/server/src/stdioServices.ts 的 createLocalServices 未传入 onAutomationManualRunRequested),runAutomationNow 在 zcodeAgentService 里直接抛出 "Automation immediate dispatcher is unavailable"。远端 DB 里的自动化即使手动也无法运行。
  2. 调度器只读本地 DB:cron tick 是桌面端 Electron utility 进程(packages/desktop/src/scheduler/),只扫描本机 tasks-index.sqlite;远端 DB 的自动化永远不会被调度。同时创建入口(useAutomationProjectOptions)明确排除远端 tab("避免把远端 identity 交给本地 host"),用户没有任何途径为远端工作区建立可调度的自动化。

Automations cannot target remote workspaces at all today: the picker excludes remote tabs; the scheduler only reads the host DB; and "Run now" from a remote-activated Automations page fails because the remote server assembly has no manual-run dispatcher.

建议方案 · Proposal

以"桌面端作为调度编排者"为原则,让远端工作区成为一等自动化目标:

  1. 创建入口放开远端 tab:选择器允许选择已连接的远端工作区(devcontainer/SSH/WSL),UI 用远端标识区分本地/容器目标;表单提示"远端目标在触发时需要 App 运行且容器在线"
  2. 远端目标自动化落在本机 DB:automations 表已带 workspace_path / workspace_identity 字段,无需迁移
  3. 会话感知派发:resolveCronDispatchHost(main/index.ts)目前盲选第一个窗口 host;改为路由到持有该远端会话的 host,resolveAutomationTargetServices 已支持通过在线远端会话派发
  4. 容器离线 = 瞬态失败:沿用现有 30s→15min 退避重试(5 次),运行列表透出每次派发错误
  5. 远端 server 补齐手动派发器:stdioServices.ts 传入 onAutomationManualRunRequested,让远端 DB 中已有(搁浅)的自动化也能立即运行

Off-peak / 闲时任务保持仅本地(远端运行时模型暂不支持),不在本提案范围。

预期价值 · Value

  • devcontainer 是远端开发的主流形态,自动化(如每日代码巡检、定时构建)应能以工作区为单位建立,而不是因为"工作区在容器里"而不可用
  • 与现有身份隔离体系一致:远端身份只路由到对应会话,不跨环境回落
  • 已在 fork(nightwares/ZCode)实现,可提供 PR

Willing to submit a PR from the fork if the approach is accepted.

Activity

github-actions commented on Oct 7, 2026

@github-actions

👋 感谢你的反馈,我们已经收到。

  • 维护者看到后会尽快回复你。
  • 状态保持为 status: 待评估,你可以随时补充信息。
  • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

👋 Thanks — we've received your issue.

  • A maintainer will get back to you as soon as we can.
  • Status stays at status: 待评估 (Triage); feel free to add context.
  • If we need more details, we'll add needs: 更多信息 and ping you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions