mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
perf(notifications): answer the mute check per row before the full sidebar pass
A row the Filters switches show is visible, and a hidden row that no lineage record names as a parent cannot be shown above a child, so only a hidden lineage parent needs computeVisibleWorktreeIds. At 1,000 workspaces a mute check drops from ~0.2-0.3 ms to ~6 us.
This commit is contained in:
@@ -101,6 +101,33 @@ describe('isWorkspaceNotificationMutedBySidebarFilters', () => {
|
||||
expect(muted(CLI_ID)).toBe(false)
|
||||
})
|
||||
|
||||
it('still mutes a hidden parent whose only lineage child is hidden too', () => {
|
||||
store.setState({
|
||||
worktreeLineageById: {
|
||||
[PLAIN_ID]: {
|
||||
worktreeId: PLAIN_ID,
|
||||
worktreeInstanceId: 'plain',
|
||||
parentWorktreeId: CLI_ID,
|
||||
parentWorktreeInstanceId: 'cli',
|
||||
origin: 'cli',
|
||||
capture: { source: 'terminal-context', confidence: 'inferred' },
|
||||
createdAt: 1
|
||||
}
|
||||
},
|
||||
worktreesByRepo: {
|
||||
repo1: [
|
||||
{ ...cliRow, instanceId: 'cli' },
|
||||
{
|
||||
...plainRow,
|
||||
instanceId: 'plain',
|
||||
cliProvenance: { kind: 'created-by-cli', createdAt: 0 }
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
expect(muted(CLI_ID)).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps notifying for an id whose twin on another host the switches show', () => {
|
||||
store.setState({
|
||||
worktreesByRepo: {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { ALL_EXECUTION_HOSTS_SCOPE } from '../../../shared/execution-host'
|
||||
import { parseWorkspaceKey } from '../../../shared/workspace-scope'
|
||||
import { sidebarHasActiveFilters } from '@/components/sidebar/sidebar-filter-actions'
|
||||
import { computeVisibleWorktreeIds } from '@/components/sidebar/compute-visible-worktrees'
|
||||
import { isHiddenBySidebarSwitch } from '@/components/sidebar/sidebar-switch-hidden-workspace'
|
||||
import { buildVisibleWorktreeOptionsFromState } from '@/components/sidebar/visible-worktree-options-from-state'
|
||||
import { isFolderWorkspaceFromOtherDevice } from '../../../shared/workspace-creator-visibility'
|
||||
|
||||
@@ -39,12 +40,26 @@ export function isWorkspaceNotificationMutedBySidebarFilters(
|
||||
isFolderWorkspaceFromOtherDevice(folder, inputs.pairedDeviceIdsByEnvironment)
|
||||
)
|
||||
}
|
||||
const known = getIndexedAllWorktrees(state.worktreesByRepo).some(
|
||||
const matches = getIndexedAllWorktrees(state.worktreesByRepo).filter(
|
||||
(worktree) => worktree.id === workspaceId && !worktree.isArchived
|
||||
)
|
||||
if (!known) {
|
||||
// Why these shortcuts: the full pass below only adds lineage parents, so a row the switches show
|
||||
// is visible, and a hidden row no lineage record names as a parent cannot be shown above a child.
|
||||
if (
|
||||
matches.length === 0 ||
|
||||
matches.some(
|
||||
(worktree) => !isHiddenBySidebarSwitch(worktree, repoMap.get(worktree.repoId), inputs)
|
||||
)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
if (
|
||||
!Object.values(state.worktreeLineageById).some(
|
||||
(lineage) => lineage.parentWorktreeId === workspaceId
|
||||
)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
const visibleIds = computeVisibleWorktreeIds(state.worktreesByRepo, [], {
|
||||
...inputs,
|
||||
filterRepoIds: [],
|
||||
|
||||
Reference in New Issue
Block a user