TUI plugin API: allow a location on the home route (router.navigate)

オープン 初心者向け
#62,322 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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
  1. In a TUI plugin, call ctx.ui.router.navigate({ type: "home", location: { directory: "/some/other/project" } }).
  2. 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分
マージ済み PR(30日)
494

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anomalyco/opencode のほかの issue

anomalyco/opencode の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。