TUI plugin API: allow a location on the home route (router.navigate)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- developer-experience
Direzione di ricerca
Inizia dal tipo Route del plugin in packages/plugin/src/tui/context.ts e confrontalo con HomeRoute in packages/tui/src/context/route.tsx. Aggiungi la posizione facoltativa alla variante home e documentala; verifica che router.current() esponga la posizione della route home e che la navigazione accetti la directory mostrata nella riproduzione. L’issue non indica un test, quindi cerca prima i test di tipo esistenti dell’API del plugin.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 224k
- Fork
- 30k
- Merge medio
- 5h 25m
- PR unite (30g)
- 494
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anomalyco/opencode
-
pending close
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
anomalyco/opencode#62305 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
anomalyco/opencode#62210 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
tui: /models drops provider grouping when the session location differs from the default locationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertareproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
anomalyco/opencode#62105 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
anomalyco/opencode#62046 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anomalyco/opencode#61897 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
Navbar avatar and name stay stale after saving profile changesForse già presa @alexechoi l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
marmelab/atomic-crm#416 ·
I maintainer di solito rispondono entro 1 giorno
-
feature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
bluesky-social/social-app#12343 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
lucide-icons/lucide#5165 ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature] Preferences - Keep the theme selection popover open after selection for quick previewAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
marktext/marktext#6033 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:desktop bug has repro platform:macos
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
anthropics/claude-code#107903 ·