From b746a0bfb63b9f09e7b4980c9922e02a0f8cff58 Mon Sep 17 00:00:00 2001 From: Mike Sawka Date: Sun, 27 Oct 2024 23:01:47 -0700 Subject: [PATCH] fix long tab names and syncing tab renaming (#1160) --- frontend/app/store/global.ts | 2 ++ frontend/app/tab/tab.less | 10 ++++++++++ frontend/app/tab/tabbar.tsx | 12 +++++++----- frontend/types/custom.d.ts | 1 + frontend/wave.ts | 13 ++++++++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/frontend/app/store/global.ts b/frontend/app/store/global.ts index 2cfc77297..f71d925aa 100644 --- a/frontend/app/store/global.ts +++ b/frontend/app/store/global.ts @@ -140,6 +140,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) { return connStatuses; }); const flashErrorsAtom = atom([]); + const reinitVersion = atom(0); atoms = { // initialized in wave.ts (will not be null inside of application) clientId: clientIdAtom, @@ -159,6 +160,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) { modalOpen, allConnStatus: allConnStatusAtom, flashErrors: flashErrorsAtom, + reinitVersion, }; } diff --git a/frontend/app/tab/tab.less b/frontend/app/tab/tab.less index 61a56da9d..12f276dd5 100644 --- a/frontend/app/tab/tab.less +++ b/frontend/app/tab/tab.less @@ -49,6 +49,10 @@ font-size: 11px; font-weight: 500; text-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25); + overflow: hidden; + width: calc(100% - 10px); + text-overflow: ellipsis; + text-align: center; &.focused { outline: none; @@ -76,6 +80,12 @@ &:hover .close { visibility: visible; + backdrop-filter: blur(3px); + + &:hover { + color: var(--main-text-color); + // background-color: var(--highlight-bg-color); + } } } diff --git a/frontend/app/tab/tabbar.tsx b/frontend/app/tab/tabbar.tsx index 09690908d..4c6723804 100644 --- a/frontend/app/tab/tabbar.tsx +++ b/frontend/app/tab/tabbar.tsx @@ -96,11 +96,6 @@ const ConfigErrorIcon = ({ buttonRef }: { buttonRef: React.RefObject ); - return ( -
}> - -
- ); }; const TabBar = React.memo(({ workspace }: TabBarProps) => { @@ -254,6 +249,13 @@ const TabBar = React.memo(({ workspace }: TabBarProps) => { debounce(100, () => saveTabsPosition())(); }, [tabIds, newTabId, isFullScreen]); + const reinitVersion = useAtomValue(atoms.reinitVersion); + useEffect(() => { + if (reinitVersion > 0) { + setSizeAndPosition(); + } + }, [reinitVersion]); + useEffect(() => { window.addEventListener("resize", () => handleResizeTabs()); return () => { diff --git a/frontend/types/custom.d.ts b/frontend/types/custom.d.ts index a855c7dad..27f8052e3 100644 --- a/frontend/types/custom.d.ts +++ b/frontend/types/custom.d.ts @@ -24,6 +24,7 @@ declare global { modalOpen: jotai.PrimitiveAtom; allConnStatus: jotai.Atom; flashErrors: jotai.PrimitiveAtom; + reinitVersion: jotai.PrimitiveAtom; }; type WritableWaveObjectAtom = jotai.WritableAtom; diff --git a/frontend/wave.ts b/frontend/wave.ts index 4e05f7e12..c783bcdea 100644 --- a/frontend/wave.ts +++ b/frontend/wave.ts @@ -85,11 +85,22 @@ async function reinitWave() { getApi().sendLog("Reinit Wave"); const client = await WOS.reloadWaveObject(WOS.makeORef("client", savedInitOpts.clientId)); const waveWindow = await WOS.reloadWaveObject(WOS.makeORef("window", savedInitOpts.windowId)); - await WOS.reloadWaveObject(WOS.makeORef("workspace", waveWindow.workspaceid)); + const ws = await WOS.reloadWaveObject(WOS.makeORef("workspace", waveWindow.workspaceid)); const initialTab = await WOS.reloadWaveObject(WOS.makeORef("tab", savedInitOpts.tabId)); await WOS.reloadWaveObject(WOS.makeORef("layout", initialTab.layoutstate)); + reloadAllWorkspaceTabs(ws); document.title = `Wave Terminal - ${initialTab.name}`; // TODO update with tab name change getApi().setWindowInitStatus("wave-ready"); + globalStore.set(atoms.reinitVersion, globalStore.get(atoms.reinitVersion) + 1); +} + +function reloadAllWorkspaceTabs(ws: Workspace) { + if (ws == null || ws.tabids == null) { + return; + } + ws.tabids.forEach((tabid) => { + WOS.reloadWaveObject(WOS.makeORef("tab", tabid)); + }); } function loadAllWorkspaceTabs(ws: Workspace) {