feat(daemon): resolve /api/v1/models without spawning an instance
`GET /api/v1/models?workspaceId=` could only answer for a named workspace, and
naming one is enough to spawn its Neovim — fine for the chat picker, wrong for
the status page, which has no session to offer and would sit in
E_INSTANCE_STARTING forever.
The parameter is now optional. With one, the read is relayed exactly as before.
Without one, src/daemon/models.ts scans only instances that are already `ready`,
prefers the one with live sessions and the longest uptime, and relays
`workspace.query{kind:"models"}` to it, falling through to the next candidate on
failure. No instance is ever created.
The plugin's answer is lazy: the first call returns
`{providers:[], pending:true}` while its cache fills. The response therefore
carries `pending`, the `workspaceId` that answered (or null) and a
`pendingReason` of `fetching`, `no-instance` or `no-live-session`, so a client
can poll with a bound and explain itself instead of showing an empty list. The
workspaceId-scoped answer now also echoes `workspaceId` back.
This commit is contained in:
1 parent
88354ec078
commit
22de7dcc9c
6 files changed
+535
-4
No files matched your search
@@ -31,6 +31,8 @@ export interface PluginConnection {
|
||||
): Promise<{ seq?: number; disposition?: string } & Record<string, unknown>>;
|
||||
subscribe(sessionId: string): void;
|
||||
unsubscribe(sessionId: string): void;
|
||||
/** Session IDs currently known by the plugin. */
|
||||
sessionIds(): string[];
|
||||
/** Last snapshot received for a session (render cache, may be undefined). */
|
||||
snapshot(sessionId: string): SessionState | undefined;
|
||||
/** Last seq received for a session. */
|
||||
|
||||
Reference in new issue
Block a user