mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
perf: defer scrollback pruning indexes until needed (#20297)
* perf: defer scrollback pruning indexes until needed * test: wait for watcher reconciliation event delivery --------- Co-authored-by: Orca Worker <orca-worker@localhost>
This commit is contained in:
@@ -626,8 +626,8 @@ describe('worktree git-common narrow watch (local native platforms)', () => {
|
||||
expect(statCalls.filter((path) => path === worktreesDir)).toHaveLength(1)
|
||||
await vi.waitFor(() => {
|
||||
expect(subscribeMock).toHaveBeenCalledTimes(2)
|
||||
expect(received.flat()).toContainEqual({ type: 'create', path: worktreesDir })
|
||||
})
|
||||
expect(received.flat()).toContainEqual({ type: 'create', path: worktreesDir })
|
||||
})
|
||||
|
||||
it('resumes polling when the dir is still absent on show', async () => {
|
||||
|
||||
@@ -77,21 +77,24 @@ export function pruneLocalTerminalScrollbackBuffers(
|
||||
session: WorkspaceSessionState,
|
||||
repos: readonly RepoConnection[]
|
||||
): WorkspaceSessionState {
|
||||
const repoById = new Map(repos.map((repo) => [repo.id, repo] as const))
|
||||
const worktreeIdByTabId = new Map<string, string>()
|
||||
let repoById: Map<string, RepoConnection> | null = null
|
||||
let worktreeIdByTabId: Map<string, string> | null = null
|
||||
const tabsByWorktree = session.tabsByWorktree ?? {}
|
||||
const terminalLayoutsByTabIdForRead = session.terminalLayoutsByTabId ?? {}
|
||||
for (const [worktreeId, tabs] of Object.entries(tabsByWorktree)) {
|
||||
for (const tab of tabs) {
|
||||
worktreeIdByTabId.set(tab.id, worktreeId)
|
||||
}
|
||||
}
|
||||
|
||||
let terminalLayoutsByTabId: WorkspaceSessionState['terminalLayoutsByTabId'] | null = null
|
||||
for (const [tabId, layout] of Object.entries(terminalLayoutsByTabIdForRead)) {
|
||||
if (!layout.buffersByLeafId && !layout.scrollbackRefsByLeafId) {
|
||||
continue
|
||||
}
|
||||
repoById ??= new Map(repos.map((repo) => [repo.id, repo] as const))
|
||||
if (!worktreeIdByTabId) {
|
||||
worktreeIdByTabId = new Map()
|
||||
for (const [worktreeId, tabs] of Object.entries(tabsByWorktree)) {
|
||||
for (const tab of tabs) {
|
||||
worktreeIdByTabId.set(tab.id, worktreeId)
|
||||
}
|
||||
}
|
||||
}
|
||||
const worktreeId = worktreeIdByTabId.get(tabId)
|
||||
if (shouldPreserveTerminalScrollbackBuffersForRepoMap(worktreeId, repoById)) {
|
||||
const capped = capTerminalScrollbackLeafBuffers(layout.buffersByLeafId)
|
||||
|
||||
Reference in New Issue
Block a user