feat(coding-agent): added automatic deduplication of context files by content

- Added automatic deduplication of identical context files by content, keeping the closest (lowest depth) copy when duplicates are discovered.
- Implemented dedupeExactContextFiles() function to filter duplicate context entries in both explicit and discovered file lists.
- Added 3 test cases covering deduplication of explicit context entries, discovered context entries, and preservation of distinct entries.
This commit is contained in:
can1357
2026-03-18 23:00:17 +01:00
parent 20cdf31b9f
commit 22a876bb8f
5 changed files with 94 additions and 8 deletions
@@ -639,6 +639,14 @@ export class SelectorController {
this.ctx.pendingTools.clear();
}
#refreshSessionTerminalTitle(): void {
const sessionManager = this.ctx.sessionManager as {
getSessionName?: () => string | undefined;
getCwd: () => string;
};
setSessionTerminalTitle(sessionManager.getSessionName?.(), sessionManager.getCwd());
}
async #detachActiveSessionBeforeDeletion(sessionPath: string): Promise<boolean> {
const currentSessionFile = this.ctx.sessionManager.getSessionFile();
if (currentSessionFile !== sessionPath) {
@@ -649,7 +657,7 @@ export class SelectorController {
if (!detached) {
return false;
}
setSessionTerminalTitle(this.ctx.sessionManager.getSessionName(), this.ctx.sessionManager.getCwd());
this.#refreshSessionTerminalTitle();
this.#clearTransientSessionUi();
this.ctx.statusLine.invalidate();
@@ -666,7 +674,7 @@ export class SelectorController {
// Switch session via AgentSession (emits hook and tool session events)
await this.ctx.session.switchSession(sessionPath);
setSessionTerminalTitle(this.ctx.sessionManager.getSessionName(), this.ctx.sessionManager.getCwd());
this.#refreshSessionTerminalTitle();
// Clear and re-render the chat
this.ctx.chatContainer.clear();