[FEATURE]: GUI plugin API: expose the new-session draft's directory and composer

未关闭
#65,154 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start by reading the GUI plugin SDK definitions and the host code for ctx.screen.current(), ctx.sessions.current(), and draft composer writes; the issue names no source files or tests. Trace how /new-session stores the draft's server and directory, then determine how the proposed API should expose them and support composer actions. Done when a plugin can read the draft directory and use its composer before the first message is sent.

由索引模型根据 Issue 内容生成。

描述

area/plugins platform/macos type/feature version/v2
Environment
  • OpenCode Desktop 2.3.2, macOS
  • GUI plugin SDK @opencode/plugin 2.3.2
Summary

On the new-session (draft) screen, before the first message is sent, a GUI plugin can't find out which directory the draft runs in, and can't write to its composer:

  • ctx.sessions.current() is undefined (documented: "Undefined on Home, on a draft…").
  • ctx.screen.current() is undefined, so there's no composer to attach or insert into.
  • ctx.router.path() is /new-session, with no directory in it.
  • ctx.tabs.list() returns the draft tab with session: undefined, and no directory.

The draft composer does list plugin slash commands, so a command that attaches context to the prompt looks available but can't do anything.

Use case

opencode-gh-search adds /pr and /issue. They search the GitHub PRs and issues of the session's repo and attach the picked one to the composer as a chip. Starting a new session with "look at PR #123" is the most common way to use it, but on a draft:

  • the plugin doesn't know which repo to search, and
  • it has nowhere to attach the pick.

Today it disables the commands there, or shows a toast asking the user to send a message first.

Proposal

Give plugins the draft as well as mounted sessions, for example:

  • ctx.screen.current() returns a screen for the draft too, with a working composer (attach, insert, focus). The host already supports writes that wait for the session's stored draft.
  • the draft's server and directory are readable, either on that screen, as a ctx.drafts.current(), or as a directory on the draft's ShellTab.
Related
  • #60883: no side region or plugin panels on the draft screen. Same root cause: plugin APIs are keyed on a session that doesn't exist yet.
主要语言
TypeScript
星标
227k
派生
30.7k
平均合并
3 小时 57 分钟
30 天内合并 PR
484

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。