@@ -3,6 +3,7 @@ import { ArrowLeftIcon, ArrowRightIcon, PanelLeftOpenIcon, PlusIcon } from "luci
33import { Reorder } from "motion/react" ;
44import { useCallback , useEffect , useRef } from "react" ;
55import { useHotkeys } from "react-hotkeys-hook" ;
6+ import { useShallow } from "zustand/shallow" ;
67
78import { Button } from "@hypr/ui/components/ui/button" ;
89import { cn } from "@hypr/utils" ;
@@ -20,7 +21,12 @@ import { Search } from "./search";
2021import { TabContentNote , TabItemNote } from "./sessions" ;
2122
2223export function Body ( ) {
23- const { tabs, currentTab } = useTabs ( ) ;
24+ const { tabs, currentTab } = useTabs (
25+ useShallow ( ( state ) => ( {
26+ tabs : state . tabs ,
27+ currentTab : state . currentTab ,
28+ } ) ) ,
29+ ) ;
2430
2531 if ( ! currentTab ) {
2632 return null ;
@@ -41,7 +47,19 @@ export function Body() {
4147
4248function Header ( { tabs } : { tabs : Tab [ ] } ) {
4349 const { leftsidebar } = useShell ( ) ;
44- const { select, close, reorder, goBack, goNext, canGoBack, canGoNext, closeOthers, closeAll } = useTabs ( ) ;
50+ const { select, close, reorder, goBack, goNext, canGoBack, canGoNext, closeOthers, closeAll } = useTabs (
51+ useShallow ( ( state ) => ( {
52+ select : state . select ,
53+ close : state . close ,
54+ reorder : state . reorder ,
55+ goBack : state . goBack ,
56+ goNext : state . goNext ,
57+ canGoBack : state . canGoBack ,
58+ canGoNext : state . canGoNext ,
59+ closeOthers : state . closeOthers ,
60+ closeAll : state . closeAll ,
61+ } ) ) ,
62+ ) ;
4563 const tabsScrollContainerRef = useRef < HTMLDivElement > ( null ) ;
4664 const handleNewEmptyTab = useNewEmptyTab ( ) ;
4765
@@ -341,7 +359,14 @@ function useScrollActiveTabIntoView(tabs: Tab[]) {
341359}
342360
343361function useTabsShortcuts ( ) {
344- const { tabs, currentTab, close, select } = useTabs ( ) ;
362+ const { tabs, currentTab, close, select } = useTabs (
363+ useShallow ( ( state ) => ( {
364+ tabs : state . tabs ,
365+ currentTab : state . currentTab ,
366+ close : state . close ,
367+ select : state . select ,
368+ } ) ) ,
369+ ) ;
345370 const newNote = useNewNote ( { behavior : "new" } ) ;
346371 const newEmptyTab = useNewEmptyTab ( ) ;
347372
@@ -396,7 +421,7 @@ function useTabsShortcuts() {
396421}
397422
398423function useNewEmptyTab ( ) {
399- const { openNew } = useTabs ( ) ;
424+ const openNew = useTabs ( ( state ) => state . openNew ) ;
400425
401426 const handler = useCallback ( ( ) => {
402427 openNew ( { type : "empty" } ) ;
0 commit comments