diff --git a/frontend/app/tab/tabbar.tsx b/frontend/app/tab/tabbar.tsx index 90c618e6c..0d567a652 100644 --- a/frontend/app/tab/tabbar.tsx +++ b/frontend/app/tab/tabbar.tsx @@ -12,7 +12,8 @@ import { OverlayScrollbars } from "overlayscrollbars"; import { createRef, memo, useCallback, useEffect, useRef, useState } from "react"; import { debounce } from "throttle-debounce"; import { IconButton } from "../element/iconbutton"; -import { WorkspaceService } from "../store/services"; +import { ObjectService, WorkspaceService } from "../store/services"; +import { makeORef } from "../store/wos"; import { Tab } from "./tab"; import "./tabbar.scss"; import { UpdateStatusBanner } from "./updatebanner"; @@ -201,6 +202,10 @@ const TabBar = memo(({ workspace }: TabBarProps) => { setTabIds(newTabIdsArr); setPinnedTabIds(newPinnedTabSet); } + if (osInstanceRef.current) { + const { viewport } = osInstanceRef.current.elements(); + viewport.scrollLeft = workspace.meta?.["scroll:offset"] ?? 0; + } }, [workspace, tabIds, pinnedTabIds]); const saveTabsPosition = useCallback(() => { @@ -578,6 +583,11 @@ const TabBar = memo(({ workspace }: TabBarProps) => { if (scrollableRef.current) { const { viewport } = osInstanceRef.current.elements(); viewport.scrollLeft = tabIds.length * tabWidthRef.current; + fireAndForget(() => + ObjectService.UpdateObjectMeta(makeORef("workspace", workspace.oid), { + "scroll:offset": viewport.scrollLeft, + }) + ); } }), [tabIds] diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 8584c1260..040cb4dc0 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -494,6 +494,7 @@ declare global { "vdom:correlationid"?: string; "vdom:route"?: string; "vdom:persist"?: boolean; + "scroll:offset"?: number; count?: number; }; diff --git a/pkg/waveobj/metaconsts.go b/pkg/waveobj/metaconsts.go index bc984fe9b..4c479a40e 100644 --- a/pkg/waveobj/metaconsts.go +++ b/pkg/waveobj/metaconsts.go @@ -100,6 +100,8 @@ const ( MetaKey_VDomRoute = "vdom:route" MetaKey_VDomPersist = "vdom:persist" + MetaKey_ScrollOffset = "scroll:offset" + MetaKey_Count = "count" ) diff --git a/pkg/waveobj/wtypemeta.go b/pkg/waveobj/wtypemeta.go index 4aded7782..3f36ce951 100644 --- a/pkg/waveobj/wtypemeta.go +++ b/pkg/waveobj/wtypemeta.go @@ -101,6 +101,8 @@ type MetaTSType struct { VDomRoute string `json:"vdom:route,omitempty"` VDomPersist bool `json:"vdom:persist,omitempty"` + ScrollOffset float64 `json:"scroll:offset,omitempty"` + Count int `json:"count,omitempty"` // temp for cpu plot. will remove later }