Files
paseo/packages/app/src/plugins/focused-agent.ts
T
Mohamed Boudra ded20eb85c fix(plugins): composers by reference follow the focused agent and reach retained composers
- `{ focused: true }` is the agent Command Center hands to agent items, published by its
  registration through plugins/focused-agent.ts and empty outside a workspace. The composer source
  reads that module instead of the remembered workspace selection, the navigation store and the
  layout store, which also removes the require cycles those imports added.
- A composer the app retains in a workspace the user left has no live input. `insertText` and
  `setPrompt` now store the text with `replaceDraftText`, which asks the mounted input to show it;
  before, the text reached the store but the retained input never displayed it.
- `model` and `thinking` read exactly what the picker resolves before the catalog loads (no
  models), then re-resolve when it lands, instead of reading null.
- The daemon validates a thinking option against the model the agent runs: the runtime model when
  the provider lists it, else the configured one.
- The composer sources subscribe to query-cache updates only. A query another component creates
  during its render is announced as `added`, and a subscriber that updates then made React warn
  about updating a component while rendering a different one. A catalog read no longer starts its
  load synchronously either.
2026-11-05 23:25:42 +01:00

31 lines
1008 B
TypeScript

/**
* The agent the user has focused: the one the Command Center hands to agent items. The Command
* Center registration reads the router and the workspace layout, publishes the answer here, and
* publishes `null` outside a workspace. A plugin's `{ focused: true }` composer reads it from here,
* so both name the same agent and neither imports the navigation or layout stores.
*/
export interface FocusedAgent {
serverId: string;
agentId: string;
}
let current: FocusedAgent | null = null;
const listeners = new Set<() => void>();
export function publishFocusedAgent(next: FocusedAgent | null): void {
if (current?.serverId === next?.serverId && current?.agentId === next?.agentId) return;
current = next;
for (const listener of listeners) listener();
}
export function getFocusedAgent(): FocusedAgent | null {
return current;
}
export function subscribeFocusedAgent(listener: () => void): () => void {
listeners.add(listener);
return () => {
listeners.delete(listener);
};
}