mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
refactor(vscode): reduce diff noise vs main
This commit is contained in:
@@ -721,16 +721,16 @@
|
||||
},
|
||||
},
|
||||
"trustedDependencies": [
|
||||
"esbuild",
|
||||
"tree-sitter-powershell",
|
||||
"protobufjs",
|
||||
"web-tree-sitter",
|
||||
"tree-sitter-bash",
|
||||
"esbuild",
|
||||
"protobufjs",
|
||||
],
|
||||
"patchedDependencies": {
|
||||
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
||||
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
||||
"mammoth@1.12.0": "patches/mammoth@1.12.0.patch",
|
||||
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
||||
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
||||
},
|
||||
"overrides": {
|
||||
"@effect/platform-node-shared": "4.0.0-beta.46",
|
||||
|
||||
@@ -1993,7 +1993,7 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
|
||||
this.contextSessionID = undefined
|
||||
this.setCurrentSession(null)
|
||||
}
|
||||
if (this.streams.active === sessionID) this.focusSession(undefined)
|
||||
if (this.streams.focused === sessionID) this.focusSession(undefined)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@ function mergePartUpdate(prev: PartUpdate | undefined, msg: PartUpdate): PartUpd
|
||||
}
|
||||
|
||||
export class SessionStreamScheduler {
|
||||
private _active: string | undefined
|
||||
private active: string | undefined
|
||||
private atimer: ReturnType<typeof setTimeout> | null = null
|
||||
private vtimer: ReturnType<typeof setTimeout> | null = null
|
||||
private btimer: ReturnType<typeof setTimeout> | null = null
|
||||
@@ -146,20 +146,20 @@ export class SessionStreamScheduler {
|
||||
}
|
||||
|
||||
focus(sessionID?: string): void {
|
||||
if (this._active === sessionID) return
|
||||
const prev = this._active
|
||||
if (this.active === sessionID) return
|
||||
const prev = this.active
|
||||
if (this.atimer) {
|
||||
clearTimeout(this.atimer)
|
||||
this.atimer = null
|
||||
}
|
||||
this._active = sessionID
|
||||
this.active = sessionID
|
||||
if (prev && this.queues.get(prev)?.size) this.schedule(prev)
|
||||
if (sessionID) this.flush(sessionID)
|
||||
}
|
||||
|
||||
/** Currently focused (active-lane) session ID, if any. */
|
||||
get active(): string | undefined {
|
||||
return this._active
|
||||
get focused(): string | undefined {
|
||||
return this.active
|
||||
}
|
||||
|
||||
setVisible(sessionID: string, visible: boolean): void {
|
||||
@@ -207,7 +207,7 @@ export class SessionStreamScheduler {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._active === sessionID && this.atimer) {
|
||||
if (this.active === sessionID && this.atimer) {
|
||||
clearTimeout(this.atimer)
|
||||
this.atimer = null
|
||||
}
|
||||
@@ -266,7 +266,7 @@ export class SessionStreamScheduler {
|
||||
|
||||
private schedule(sessionID: string): void {
|
||||
if (!this.queues.get(sessionID)?.size) return
|
||||
if (this._active === sessionID) {
|
||||
if (this.active === sessionID) {
|
||||
if (this.atimer) return
|
||||
this.atimer = setTimeout(() => this.flushActive(), this.activeMs)
|
||||
return
|
||||
@@ -305,7 +305,7 @@ export class SessionStreamScheduler {
|
||||
|
||||
private flushActive(): void {
|
||||
this.atimer = null
|
||||
if (this._active) this.emit(this.take(this._active))
|
||||
if (this.active) this.emit(this.take(this.active))
|
||||
}
|
||||
|
||||
private flushBackground(): void {
|
||||
@@ -336,7 +336,7 @@ export class SessionStreamScheduler {
|
||||
private takeBackground(): PartUpdate[] {
|
||||
const updates: PartUpdate[] = []
|
||||
for (const [sid, queue] of this.queues) {
|
||||
if (sid === this._active) continue
|
||||
if (sid === this.active) continue
|
||||
if (this.visible.has(sid)) continue
|
||||
updates.push(...queue.values())
|
||||
this.queues.delete(sid)
|
||||
@@ -347,7 +347,7 @@ export class SessionStreamScheduler {
|
||||
private takeVisible(): PartUpdate[] {
|
||||
const updates: PartUpdate[] = []
|
||||
for (const [sid, queue] of this.queues) {
|
||||
if (sid === this._active || !this.visible.has(sid)) continue
|
||||
if (sid === this.active || !this.visible.has(sid)) continue
|
||||
updates.push(...queue.values())
|
||||
this.queues.delete(sid)
|
||||
}
|
||||
@@ -357,7 +357,7 @@ export class SessionStreamScheduler {
|
||||
private visibleCount(): number {
|
||||
let n = 0
|
||||
for (const [sid, queue] of this.queues) {
|
||||
if (sid !== this._active && this.visible.has(sid) && queue.size > 0) n++
|
||||
if (sid !== this.active && this.visible.has(sid) && queue.size > 0) n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
@@ -365,7 +365,7 @@ export class SessionStreamScheduler {
|
||||
private backgroundCount(): number {
|
||||
let n = 0
|
||||
for (const [sid, queue] of this.queues) {
|
||||
if (sid !== this._active && !this.visible.has(sid) && queue.size > 0) n++
|
||||
if (sid !== this.active && !this.visible.has(sid) && queue.size > 0) n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
@@ -398,7 +398,7 @@ export class SessionStreamScheduler {
|
||||
}
|
||||
|
||||
private countLane(sessionID: string): void {
|
||||
if (sessionID === this._active) this.counters.active++
|
||||
if (sessionID === this.active) this.counters.active++
|
||||
else if (this.visible.has(sessionID)) this.counters.visible++
|
||||
else this.counters.background++
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ describe("KiloProvider pruneDeletedSession contract", () => {
|
||||
// unregisterFocused for this instance.
|
||||
const match = source.match(/pruneDeletedSession\(sessionID: string\): void \{([\s\S]*?)\n \}/)
|
||||
expect(match).not.toBeNull()
|
||||
expect(match![1]).toMatch(/if \(this\.streams\.active === sessionID\) this\.focusSession\(undefined\)/)
|
||||
expect(match![1]).toMatch(/if \(this\.streams\.focused === sessionID\) this\.focusSession\(undefined\)/)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -255,15 +255,15 @@ describe("SessionStreamScheduler / focus and lifecycle", () => {
|
||||
expect(stats.active).toBe(0)
|
||||
})
|
||||
|
||||
it("exposes the active session id via the getter so pruneDeletedSession can match it", () => {
|
||||
it("exposes the focused session id via the getter so pruneDeletedSession can match it", () => {
|
||||
const queue = new SessionStreamScheduler(() => {})
|
||||
expect(queue.active).toBeUndefined()
|
||||
expect(queue.focused).toBeUndefined()
|
||||
queue.focus("sess-1")
|
||||
expect(queue.active).toBe("sess-1")
|
||||
expect(queue.focused).toBe("sess-1")
|
||||
queue.focus("sess-2")
|
||||
expect(queue.active).toBe("sess-2")
|
||||
expect(queue.focused).toBe("sess-2")
|
||||
queue.focus(undefined)
|
||||
expect(queue.active).toBeUndefined()
|
||||
expect(queue.focused).toBeUndefined()
|
||||
})
|
||||
|
||||
it("dispose() stops further emissions from queued work", async () => {
|
||||
|
||||
@@ -2108,20 +2108,20 @@ export const SessionProvider: ParentComponent = (props) => {
|
||||
|
||||
setStore(
|
||||
"sessions",
|
||||
produce((s) => {
|
||||
delete s[cloudKey]
|
||||
produce((sessions) => {
|
||||
delete sessions[cloudKey]
|
||||
}),
|
||||
)
|
||||
setStore(
|
||||
"messages",
|
||||
produce((m) => {
|
||||
delete m[cloudKey]
|
||||
produce((messages) => {
|
||||
delete messages[cloudKey]
|
||||
}),
|
||||
)
|
||||
setStore(
|
||||
"toolParts",
|
||||
produce((p) => {
|
||||
delete p[cloudKey]
|
||||
produce((parts) => {
|
||||
delete parts[cloudKey]
|
||||
}),
|
||||
)
|
||||
})
|
||||
@@ -2626,10 +2626,7 @@ export const SessionProvider: ParentComponent = (props) => {
|
||||
return next
|
||||
})
|
||||
if (id === currentSessionID() || id === draftSessionID()) setUserClearedSession(true)
|
||||
vscode.postMessage({
|
||||
type: "deleteSession",
|
||||
sessionID: id,
|
||||
})
|
||||
vscode.postMessage({ type: "deleteSession", sessionID: id })
|
||||
}
|
||||
|
||||
function renameSession(id: string, title: string) {
|
||||
|
||||
Reference in New Issue
Block a user