diff --git a/src/bundled/mentions/MentionCompletion.tsx b/src/bundled/mentions/MentionCompletion.tsx index 1d0b5b314e..2a0578a189 100644 --- a/src/bundled/mentions/MentionCompletion.tsx +++ b/src/bundled/mentions/MentionCompletion.tsx @@ -394,8 +394,12 @@ export function MentionCompletion({ retry: () => { teams.retry(); model.directory.retry(); + // Reread the agent library only when it failed: while a reload + // runs, shown rows that depend on it are disabled. void session.agentChoices.refresh( - !!inviteAgents || teams.includeLegacy, + (model.includeLegacy && + (agents.status === "error" || !!agents.error)) || + teams.includeLegacy, ); void session.archives?.refresh(); retry((value) => value + 1); diff --git a/src/bundled/mentions/MentionPicker.tsx b/src/bundled/mentions/MentionPicker.tsx index c09c9bd6dd..bf41048c98 100644 --- a/src/bundled/mentions/MentionPicker.tsx +++ b/src/bundled/mentions/MentionPicker.tsx @@ -181,6 +181,21 @@ export function MentionPicker({ // Underline with the same rule that ranks mentions. const matched = (label: string) => search.trim() ? matchPerson(label, search)?.positions : undefined; + // Agent rows may still arrive: the agent list is loading, or the chooser + // waits on a read of it (inviting, or the hold of README section 6) that + // the combined status misses once native inventory is ready. Members and a + // roster have their own status text. + const agentsLoading = agents.status === "loading" || model.agentsPending; + const agentsFailed = agents.status === "error" || !!agents.error; + // No results is only known once nothing is pending and the agent read has + // not failed: Retry may still bring rows. + const empty = + !!members && + !model.pending && + !agentsLoading && + !agentsFailed && + !candidates.length && + !teams.choices.length; return ( )} - {agents.status === "loading" && !candidates.length && ( + {agentsLoading && !candidates.length && (

Loading agents…

)} - {(agents.status === "error" || !!agents.error) && ( + {agentsFailed && (