* perf(app): keep large sidebars responsive Sidebar rows rescanned every agent for each session update, multiplying work with both workspace and agent count. Build workspace activity once and share the derived sidebar model so updates scale with the underlying collections. * test(app): use valid agent fixture for workspace restore * refactor(app): keep sidebar model surface focused
28 lines
872 B
TypeScript
28 lines
872 B
TypeScript
import { useEffect } from "react";
|
|
import { useSidebarModel } from "@/components/sidebar/sidebar-model";
|
|
import { useKeyboardShortcutsStore } from "@/stores/keyboard-shortcuts-store";
|
|
|
|
export function WorkspaceShortcutTargetsSubscriber({ enabled }: { enabled: boolean }) {
|
|
const { shortcutModel } = useSidebarModel();
|
|
const setSidebarShortcutWorkspaceTargets = useKeyboardShortcutsStore(
|
|
(state) => state.setSidebarShortcutWorkspaceTargets,
|
|
);
|
|
|
|
useEffect(() => {
|
|
if (!enabled) {
|
|
setSidebarShortcutWorkspaceTargets([]);
|
|
return;
|
|
}
|
|
|
|
setSidebarShortcutWorkspaceTargets(shortcutModel.shortcutTargets);
|
|
}, [enabled, setSidebarShortcutWorkspaceTargets, shortcutModel.shortcutTargets]);
|
|
|
|
useEffect(() => {
|
|
return () => {
|
|
setSidebarShortcutWorkspaceTargets([]);
|
|
};
|
|
}, [setSidebarShortcutWorkspaceTargets]);
|
|
|
|
return null;
|
|
}
|