fix(coding-agent): defer catalog refresh until after TUI startup

This commit is contained in:
Armin Ronacher
2026-07-21 18:25:38 +02:00
parent a82289637b
commit b142504125
3 changed files with 20 additions and 5 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased] ## [Unreleased]
### Fixed
- Fixed interactive startup waiting for background model catalog refresh while computing the footer provider count.
## [0.81.0] - 2026-07-21 ## [0.81.0] - 2026-07-21
### New Features ### New Features
+2 -1
View File
@@ -808,7 +808,8 @@ export async function main(args: string[], options?: MainOptions) {
process.exit(1); process.exit(1);
} }
if (!offlineMode && (appMode === "interactive" || appMode === "rpc")) { // RPC refreshes catalogs here in the background; interactive mode starts its refresh after TUI initialization.
if (!offlineMode && appMode === "rpc") {
void modelRuntime.refresh().catch(() => {}); void modelRuntime.refresh().catch(() => {});
} }
@@ -826,6 +826,13 @@ export class InteractiveMode {
async run(): Promise<void> { async run(): Promise<void> {
await this.init(); await this.init();
if (!process.env.PI_OFFLINE) {
void this.session.modelRuntime
.refresh()
.then(() => this.updateAvailableProviderCount())
.catch(() => {});
}
// Start version check asynchronously // Start version check asynchronously
checkForNewPiVersion(this.version).then((newRelease) => { checkForNewPiVersion(this.version).then((newRelease) => {
if (newRelease) { if (newRelease) {
@@ -4352,10 +4359,13 @@ export class InteractiveMode {
} }
} }
/** Update the footer's available provider count from current model candidates */ /** Update the footer's available provider count from the current snapshot without refreshing catalogs. */
private async updateAvailableProviderCount(): Promise<void> { private updateAvailableProviderCount(): void {
const models = await this.getModelCandidates(); const models =
const uniqueProviders = new Set(models.map((m) => m.provider)); this.session.scopedModels.length > 0
? this.session.scopedModels.map((scoped) => scoped.model)
: this.session.modelRuntime.getAvailableSnapshot();
const uniqueProviders = new Set(models.map((model) => model.provider));
this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size); this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size);
} }