fix(coding-agent): stop updating packages on startup closes #1963
This commit is contained in:
@@ -38,6 +38,7 @@ import {
|
||||
import { spawn, spawnSync } from "child_process";
|
||||
import {
|
||||
APP_NAME,
|
||||
getAgentDir,
|
||||
getAuthPath,
|
||||
getDebugLogPath,
|
||||
getShareViewerUrl,
|
||||
@@ -57,6 +58,7 @@ import { FooterDataProvider, type ReadonlyFooterDataProvider } from "../../core/
|
||||
import { type AppAction, KeybindingsManager } from "../../core/keybindings.js";
|
||||
import { createCompactionSummaryMessage } from "../../core/messages.js";
|
||||
import { findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
|
||||
import { DefaultPackageManager } from "../../core/package-manager.js";
|
||||
import type { ResourceDiagnostic } from "../../core/resource-loader.js";
|
||||
import { type SessionContext, SessionManager } from "../../core/session-manager.js";
|
||||
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
||||
@@ -512,6 +514,13 @@ export class InteractiveMode {
|
||||
}
|
||||
});
|
||||
|
||||
// Start package update check asynchronously
|
||||
this.checkForPackageUpdates().then((updates) => {
|
||||
if (updates.length > 0) {
|
||||
this.showPackageUpdateNotification(updates);
|
||||
}
|
||||
});
|
||||
|
||||
// Check tmux keyboard setup asynchronously
|
||||
this.checkTmuxKeyboardSetup().then((warning) => {
|
||||
if (warning) {
|
||||
@@ -593,6 +602,24 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
private async checkForPackageUpdates(): Promise<string[]> {
|
||||
if (process.env.PI_OFFLINE) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const packageManager = new DefaultPackageManager({
|
||||
cwd: process.cwd(),
|
||||
agentDir: getAgentDir(),
|
||||
settingsManager: this.settingsManager,
|
||||
});
|
||||
const updates = await packageManager.checkForAvailableUpdates();
|
||||
return updates.map((update) => update.displayName);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private async checkTmuxKeyboardSetup(): Promise<string | undefined> {
|
||||
if (!process.env.TMUX) return undefined;
|
||||
|
||||
@@ -2887,6 +2914,24 @@ export class InteractiveMode {
|
||||
this.ui.requestRender();
|
||||
}
|
||||
|
||||
showPackageUpdateNotification(packages: string[]): void {
|
||||
const action = theme.fg("accent", `${APP_NAME} update`);
|
||||
const updateInstruction = theme.fg("muted", "Package updates are available. Run ") + action;
|
||||
const packageLines = packages.map((pkg) => `- ${pkg}`).join("\n");
|
||||
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
||||
this.chatContainer.addChild(
|
||||
new Text(
|
||||
`${theme.bold(theme.fg("warning", "Package Updates Available"))}\n${updateInstruction}\n${theme.fg("muted", "Packages:")}\n${packageLines}`,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
);
|
||||
this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
|
||||
this.ui.requestRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all queued messages (read-only).
|
||||
* Combines session queue and compaction queue.
|
||||
|
||||
Reference in New Issue
Block a user