fix(coding-agent): show resources before messages when resuming session
This commit is contained in:
@@ -265,6 +265,7 @@ export interface InteractiveModeOptions {
|
||||
export class InteractiveMode {
|
||||
private runtimeHost: AgentSessionRuntime;
|
||||
private ui: TUI;
|
||||
private loadedResourcesContainer: Container;
|
||||
private chatContainer: Container;
|
||||
private pendingMessagesContainer: Container;
|
||||
private statusContainer: Container;
|
||||
@@ -401,6 +402,7 @@ export class InteractiveMode {
|
||||
this.ui = new TUI(new ProcessTerminal(), this.settingsManager.getShowHardwareCursor());
|
||||
this.ui.setClearOnShrink(this.settingsManager.getClearOnShrink());
|
||||
this.headerContainer = new Container();
|
||||
this.loadedResourcesContainer = new Container();
|
||||
this.chatContainer = new Container();
|
||||
this.pendingMessagesContainer = new Container();
|
||||
this.statusContainer = new Container();
|
||||
@@ -636,8 +638,10 @@ export class InteractiveMode {
|
||||
console.log(theme.fg("dim", `Model scope: ${modelList}${cycleHint}`));
|
||||
}
|
||||
|
||||
// Add header container as first child. Populate it after detectThemeIfUnset.
|
||||
// Add header container as first child. Populate it after applying theme settings.
|
||||
// Keep loaded resources before chat so restored session messages never precede them.
|
||||
this.ui.addChild(this.headerContainer);
|
||||
this.ui.addChild(this.loadedResourcesContainer);
|
||||
|
||||
this.ui.addChild(this.chatContainer);
|
||||
this.ui.addChild(this.pendingMessagesContainer);
|
||||
@@ -1330,6 +1334,9 @@ export class InteractiveMode {
|
||||
force?: boolean;
|
||||
showDiagnosticsWhenQuiet?: boolean;
|
||||
}): void {
|
||||
// Resource rendering is idempotent; chat clears no longer clear this separate container.
|
||||
this.loadedResourcesContainer.clear();
|
||||
|
||||
const showListing = options?.force || this.options.verbose || !this.settingsManager.getQuietStartup();
|
||||
const showDiagnostics = showListing || options?.showDiagnosticsWhenQuiet === true;
|
||||
if (!showListing && !showDiagnostics) {
|
||||
@@ -1357,8 +1364,8 @@ export class InteractiveMode {
|
||||
0,
|
||||
0,
|
||||
);
|
||||
this.chatContainer.addChild(section);
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(section);
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
};
|
||||
|
||||
const skillsResult = this.session.resourceLoader.getSkills();
|
||||
@@ -1395,7 +1402,7 @@ export class InteractiveMode {
|
||||
if (showListing) {
|
||||
const contextFiles = this.session.resourceLoader.getAgentsFiles().agentsFiles;
|
||||
if (contextFiles.length > 0) {
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
const contextList = contextFiles
|
||||
.map((f) => theme.fg("dim", ` ${this.formatDisplayPath(f.path)}`))
|
||||
.join("\n");
|
||||
@@ -1478,17 +1485,19 @@ export class InteractiveMode {
|
||||
const skillDiagnostics = skillsResult.diagnostics;
|
||||
if (skillDiagnostics.length > 0) {
|
||||
const warningLines = this.formatDiagnostics(skillDiagnostics, sourceInfos);
|
||||
this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Skill conflicts]")}\n${warningLines}`, 0, 0));
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(
|
||||
new Text(`${theme.fg("warning", "[Skill conflicts]")}\n${warningLines}`, 0, 0),
|
||||
);
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
}
|
||||
|
||||
const promptDiagnostics = promptsResult.diagnostics;
|
||||
if (promptDiagnostics.length > 0) {
|
||||
const warningLines = this.formatDiagnostics(promptDiagnostics, sourceInfos);
|
||||
this.chatContainer.addChild(
|
||||
this.loadedResourcesContainer.addChild(
|
||||
new Text(`${theme.fg("warning", "[Prompt conflicts]")}\n${warningLines}`, 0, 0),
|
||||
);
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
}
|
||||
|
||||
const extensionDiagnostics: ResourceDiagnostic[] = [];
|
||||
@@ -1508,17 +1517,19 @@ export class InteractiveMode {
|
||||
|
||||
if (extensionDiagnostics.length > 0) {
|
||||
const warningLines = this.formatDiagnostics(extensionDiagnostics, sourceInfos);
|
||||
this.chatContainer.addChild(
|
||||
this.loadedResourcesContainer.addChild(
|
||||
new Text(`${theme.fg("warning", "[Extension issues]")}\n${warningLines}`, 0, 0),
|
||||
);
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
}
|
||||
|
||||
const themeDiagnostics = themesResult.diagnostics;
|
||||
if (themeDiagnostics.length > 0) {
|
||||
const warningLines = this.formatDiagnostics(themeDiagnostics, sourceInfos);
|
||||
this.chatContainer.addChild(new Text(`${theme.fg("warning", "[Theme conflicts]")}\n${warningLines}`, 0, 0));
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
this.loadedResourcesContainer.addChild(
|
||||
new Text(`${theme.fg("warning", "[Theme conflicts]")}\n${warningLines}`, 0, 0),
|
||||
);
|
||||
this.loadedResourcesContainer.addChild(new Spacer(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1651,6 +1662,7 @@ export class InteractiveMode {
|
||||
}
|
||||
|
||||
private renderCurrentSessionState(): void {
|
||||
this.loadedResourcesContainer.clear();
|
||||
this.chatContainer.clear();
|
||||
this.pendingMessagesContainer.clear();
|
||||
this.compactionQueuedMessages = [];
|
||||
@@ -3606,9 +3618,11 @@ export class InteractiveMode {
|
||||
if (isExpandable(activeHeader)) {
|
||||
activeHeader.setExpanded(expanded);
|
||||
}
|
||||
for (const child of this.chatContainer.children) {
|
||||
if (isExpandable(child)) {
|
||||
child.setExpanded(expanded);
|
||||
for (const container of [this.loadedResourcesContainer, this.chatContainer]) {
|
||||
for (const child of container.children) {
|
||||
if (isExpandable(child)) {
|
||||
child.setExpanded(expanded);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ui.requestRender();
|
||||
|
||||
Reference in New Issue
Block a user