fix(coding-agent): defer catalog refresh until after TUI startup
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed interactive startup waiting for background model catalog refresh while computing the footer provider count.
|
||||
|
||||
## [0.81.0] - 2026-07-21
|
||||
|
||||
### New Features
|
||||
|
||||
@@ -808,7 +808,8 @@ export async function main(args: string[], options?: MainOptions) {
|
||||
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(() => {});
|
||||
}
|
||||
|
||||
|
||||
@@ -826,6 +826,13 @@ export class InteractiveMode {
|
||||
async run(): Promise<void> {
|
||||
await this.init();
|
||||
|
||||
if (!process.env.PI_OFFLINE) {
|
||||
void this.session.modelRuntime
|
||||
.refresh()
|
||||
.then(() => this.updateAvailableProviderCount())
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
// Start version check asynchronously
|
||||
checkForNewPiVersion(this.version).then((newRelease) => {
|
||||
if (newRelease) {
|
||||
@@ -4352,10 +4359,13 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
/** Update the footer's available provider count from current model candidates */
|
||||
private async updateAvailableProviderCount(): Promise<void> {
|
||||
const models = await this.getModelCandidates();
|
||||
const uniqueProviders = new Set(models.map((m) => m.provider));
|
||||
/** Update the footer's available provider count from the current snapshot without refreshing catalogs. */
|
||||
private updateAvailableProviderCount(): void {
|
||||
const models =
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user