TUI plugin API: allow a location on the home route (router.navigate)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 packages/plugin/src/tui/context.ts 中的插件 Route 类型开始,并将其与 packages/tui/src/context/route.tsx 中的 HomeRoute 进行比较。为 home 变体添加可选位置并编写文档;检查 router.current() 是否公开 home 路由的位置,以及导航是否接受复现中显示的目录。该 issue 没有指定测试,因此先查找现有的插件 API 类型测试。
由索引模型根据 Issue 内容生成。
描述
Description
A TUI plugin cannot open the new-session screen for a specific directory with the typed plugin API. OpenCode's own code can.
Internally, HomeRoute carries an optional location (packages/tui/src/context/route.tsx):
export type HomeRoute = {
type: "home"
prompt?: PromptInfo
// Location carried over from the previous session or project picker so a new session lands there.
location?: LocationRef
}
The project picker (component/dialog-open.tsx) and the workspace move (component/prompt/move.tsx) both call route.navigate({ type: "home", location: { directory } }). Home then applies route.location (routes/home.tsx), so the next session is created in that directory.
The plugin API's Route type (packages/plugin/src/tui/context.ts) has only { readonly type: "home" }. ui.router.navigate passes a home destination straight through to the host (packages/tui/src/plugin/api.tsx), so navigate({ type: "home", location }) works at runtime. However, a plugin has to cast to reach it, and nothing guarantees it keeps working.
Proposal: add readonly location?: LocationRef to the home variant of the plugin Route type, and document it. router.current() would then also type the location of the current home route, which the host already returns.
Use case: opencode-switchboard, a side panel that lists sessions grouped by project, wants a "New session" action on a project. It should open that project's new-session screen, as picking the project in Ctrl+O does, without creating an empty session up front with session.create.
Happy to send a PR.
Plugins
opencode-switchboard
OpenCode version
2.2.5
Steps to reproduce
- In a TUI plugin, call
ctx.ui.router.navigate({ type: "home", location: { directory: "/some/other/project" } }). - TypeScript rejects
location. With a cast, it works: the new-session screen opens in that directory.
Operating System
Ubuntu 24.04
Terminal
Ghostty
- 主要语言
- TypeScript
- 星标
- 224k
- 派生
- 30k
- 平均合并
- 5 小时 25 分钟
- 30 天内合并 PR
- 494
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
pending close
难度 2/5 1-3 小时 新手友好度 76/100
anomalyco/opencode#62305 · 1 条评论 ·
维护者通常 1 天内回复
-
docs: AgentEditor.update creates missing agents, but the plugin docs don't say so可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 76/100
anomalyco/opencode#62210 · 1 条评论 ·
维护者通常 1 天内回复
-
tui: /models drops provider grouping when the session location differs from the default location可能重新可做 关联的 PR 已关闭且未合并。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#62105 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#62046 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#61897 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
binding:python bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
coollabsio/orbit#72 ·
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
bug needs-triage potential-regression
难度 2/5 1-3 小时 新手友好度 78/100
aws/aws-sdk-js-v3#8408 ·
维护者通常 1 天内回复