fix(coding-agent): make session path traversal linear
Avoid quadratic path construction when walking deep session branches. On a 600k-entry pathological session, path construction improved from about 20.3s with Array.unshift() to about 35ms with push() plus reverse(). Refs #5804.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed deep session branches taking quadratic time to build context or branch paths ([#5909](https://github.com/earendil-works/pi/issues/5909)).
|
||||||
- Fixed fuzzy `edit` matches to preserve untouched line blocks instead of rewriting the whole file through normalized content ([#5899](https://github.com/earendil-works/pi/issues/5899)).
|
- Fixed fuzzy `edit` matches to preserve untouched line blocks instead of rewriting the whole file through normalized content ([#5899](https://github.com/earendil-works/pi/issues/5899)).
|
||||||
- Fixed bash commands through legacy WSL `bash.exe` to pass scripts over stdin so shell variables expand in the target bash ([#5893](https://github.com/earendil-works/pi/issues/5893)).
|
- Fixed bash commands through legacy WSL `bash.exe` to pass scripts over stdin so shell variables expand in the target bash ([#5893](https://github.com/earendil-works/pi/issues/5893)).
|
||||||
- Fixed `/model` to hide GitHub Copilot models that are unavailable to the authenticated account ([#5897](https://github.com/earendil-works/pi/issues/5897)).
|
- Fixed `/model` to hide GitHub Copilot models that are unavailable to the authenticated account ([#5897](https://github.com/earendil-works/pi/issues/5897)).
|
||||||
|
|||||||
@@ -357,9 +357,10 @@ export function buildSessionContext(
|
|||||||
const path: SessionEntry[] = [];
|
const path: SessionEntry[] = [];
|
||||||
let current: SessionEntry | undefined = leaf;
|
let current: SessionEntry | undefined = leaf;
|
||||||
while (current) {
|
while (current) {
|
||||||
path.unshift(current);
|
path.push(current);
|
||||||
current = current.parentId ? byId.get(current.parentId) : undefined;
|
current = current.parentId ? byId.get(current.parentId) : undefined;
|
||||||
}
|
}
|
||||||
|
path.reverse();
|
||||||
|
|
||||||
// Extract settings and find compaction
|
// Extract settings and find compaction
|
||||||
let thinkingLevel = "off";
|
let thinkingLevel = "off";
|
||||||
@@ -1152,9 +1153,10 @@ export class SessionManager {
|
|||||||
const startId = fromId ?? this.leafId;
|
const startId = fromId ?? this.leafId;
|
||||||
let current = startId ? this.byId.get(startId) : undefined;
|
let current = startId ? this.byId.get(startId) : undefined;
|
||||||
while (current) {
|
while (current) {
|
||||||
path.unshift(current);
|
path.push(current);
|
||||||
current = current.parentId ? this.byId.get(current.parentId) : undefined;
|
current = current.parentId ? this.byId.get(current.parentId) : undefined;
|
||||||
}
|
}
|
||||||
|
path.reverse();
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user