Skip to content

Commit b746a0b

Browse files
authored
fix long tab names and syncing tab renaming (#1160)
1 parent be5d73a commit b746a0b

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

frontend/app/store/global.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
140140
return connStatuses;
141141
});
142142
const flashErrorsAtom = atom<FlashErrorType[]>([]);
143+
const reinitVersion = atom(0);
143144
atoms = {
144145
// initialized in wave.ts (will not be null inside of application)
145146
clientId: clientIdAtom,
@@ -159,6 +160,7 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
159160
modalOpen,
160161
allConnStatus: allConnStatusAtom,
161162
flashErrors: flashErrorsAtom,
163+
reinitVersion,
162164
};
163165
}
164166

frontend/app/tab/tab.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
font-size: 11px;
5050
font-weight: 500;
5151
text-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);
52+
overflow: hidden;
53+
width: calc(100% - 10px);
54+
text-overflow: ellipsis;
55+
text-align: center;
5256

5357
&.focused {
5458
outline: none;
@@ -76,6 +80,12 @@
7680

7781
&:hover .close {
7882
visibility: visible;
83+
backdrop-filter: blur(3px);
84+
85+
&:hover {
86+
color: var(--main-text-color);
87+
// background-color: var(--highlight-bg-color);
88+
}
7989
}
8090
}
8191

frontend/app/tab/tabbar.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ const ConfigErrorIcon = ({ buttonRef }: { buttonRef: React.RefObject<HTMLElement
9696
Config Error
9797
</Button>
9898
);
99-
return (
100-
<div className="config-error" ref={buttonRef as React.RefObject<HTMLDivElement>}>
101-
<i className="fa fa-solid fa-exclamation-triangle" />
102-
</div>
103-
);
10499
};
105100

106101
const TabBar = React.memo(({ workspace }: TabBarProps) => {
@@ -254,6 +249,13 @@ const TabBar = React.memo(({ workspace }: TabBarProps) => {
254249
debounce(100, () => saveTabsPosition())();
255250
}, [tabIds, newTabId, isFullScreen]);
256251

252+
const reinitVersion = useAtomValue(atoms.reinitVersion);
253+
useEffect(() => {
254+
if (reinitVersion > 0) {
255+
setSizeAndPosition();
256+
}
257+
}, [reinitVersion]);
258+
257259
useEffect(() => {
258260
window.addEventListener("resize", () => handleResizeTabs());
259261
return () => {

frontend/types/custom.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ declare global {
2424
modalOpen: jotai.PrimitiveAtom<boolean>;
2525
allConnStatus: jotai.Atom<ConnStatus[]>;
2626
flashErrors: jotai.PrimitiveAtom<FlashErrorType[]>;
27+
reinitVersion: jotai.PrimitiveAtom<number>;
2728
};
2829

2930
type WritableWaveObjectAtom<T extends WaveObj> = jotai.WritableAtom<T, [value: T], void>;

frontend/wave.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,22 @@ async function reinitWave() {
8585
getApi().sendLog("Reinit Wave");
8686
const client = await WOS.reloadWaveObject<Client>(WOS.makeORef("client", savedInitOpts.clientId));
8787
const waveWindow = await WOS.reloadWaveObject<WaveWindow>(WOS.makeORef("window", savedInitOpts.windowId));
88-
await WOS.reloadWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));
88+
const ws = await WOS.reloadWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));
8989
const initialTab = await WOS.reloadWaveObject<Tab>(WOS.makeORef("tab", savedInitOpts.tabId));
9090
await WOS.reloadWaveObject<LayoutState>(WOS.makeORef("layout", initialTab.layoutstate));
91+
reloadAllWorkspaceTabs(ws);
9192
document.title = `Wave Terminal - ${initialTab.name}`; // TODO update with tab name change
9293
getApi().setWindowInitStatus("wave-ready");
94+
globalStore.set(atoms.reinitVersion, globalStore.get(atoms.reinitVersion) + 1);
95+
}
96+
97+
function reloadAllWorkspaceTabs(ws: Workspace) {
98+
if (ws == null || ws.tabids == null) {
99+
return;
100+
}
101+
ws.tabids.forEach((tabid) => {
102+
WOS.reloadWaveObject<Tab>(WOS.makeORef("tab", tabid));
103+
});
93104
}
94105

95106
function loadAllWorkspaceTabs(ws: Workspace) {

0 commit comments

Comments
 (0)