Skip to content

Commit 6996487

Browse files
committed
remove pinned tabs fe/electron updates
1 parent c912b89 commit 6996487

9 files changed

Lines changed: 32 additions & 153 deletions

File tree

Taskfile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ tasks:
435435
- task: dev:cleardata:linux
436436
- task: dev:cleardata:macos
437437

438+
check:ts:
439+
desc: Typecheck TypeScript code (frontend and electron).
440+
cmd: npx tsc --noEmit
441+
deps:
442+
- npm:install
443+
438444
init:
439445
desc: Initialize the project for development.
440446
cmds:

emain/emain-window.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ type WindowActionQueueEntry =
120120
}
121121
| {
122122
op: "createtab";
123-
pinned: boolean;
124123
}
125124
| {
126125
op: "closetab";
@@ -132,7 +131,7 @@ type WindowActionQueueEntry =
132131
};
133132

134133
function isNonEmptyUnsavedWorkspace(workspace: Workspace): boolean {
135-
return !workspace.name && !workspace.icon && (workspace.tabids?.length > 1 || workspace.pinnedtabids?.length > 1);
134+
return !workspace.name && !workspace.icon && workspace.tabids?.length > 1;
136135
}
137136

138137
export class WaveBrowserWindow extends BaseWindow {
@@ -496,8 +495,8 @@ export class WaveBrowserWindow extends BaseWindow {
496495
}
497496
}
498497

499-
async queueCreateTab(pinned = false) {
500-
await this._queueActionInternal({ op: "createtab", pinned });
498+
async queueCreateTab() {
499+
await this._queueActionInternal({ op: "createtab" });
501500
}
502501

503502
async queueCloseTab(tabId: string) {
@@ -537,7 +536,7 @@ export class WaveBrowserWindow extends BaseWindow {
537536
// have to use "===" here to get the typechecker to work :/
538537
switch (entry.op) {
539538
case "createtab":
540-
tabId = await WorkspaceService.CreateTab(this.workspaceId, null, true, entry.pinned);
539+
tabId = await WorkspaceService.CreateTab(this.workspaceId, null, true);
541540
break;
542541
case "switchtab":
543542
tabId = entry.tabId;

frontend/app/store/keymodel.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
WOS,
2222
} from "@/app/store/global";
2323
import { getActiveTabModel } from "@/app/store/tab-model";
24-
import { TabBarModel } from "@/app/tab/tabbar-model";
2524
import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model";
2625
import { deleteLayoutModelForTab, getLayoutModelForStaticTab, NavigateDirection } from "@/layout/index";
2726
import * as keyutil from "@/util/keyutil";
@@ -125,12 +124,6 @@ function getStaticTabBlockCount(): number {
125124
return tabData?.blockids?.length ?? 0;
126125
}
127126

128-
function isStaticTabPinned(): boolean {
129-
const ws = globalStore.get(atoms.workspace);
130-
const tabId = globalStore.get(atoms.staticTabId);
131-
return ws.pinnedtabids?.includes(tabId) ?? false;
132-
}
133-
134127
function simpleCloseStaticTab() {
135128
const ws = globalStore.get(atoms.workspace);
136129
const tabId = globalStore.get(atoms.staticTabId);
@@ -139,11 +132,6 @@ function simpleCloseStaticTab() {
139132
}
140133

141134
function uxCloseBlock(blockId: string) {
142-
if (isStaticTabPinned() && getStaticTabBlockCount() === 1) {
143-
TabBarModel.getInstance().jiggleActivePinnedTab();
144-
return;
145-
}
146-
147135
const workspaceLayoutModel = WorkspaceLayoutModel.getInstance();
148136
const isAIPanelOpen = workspaceLayoutModel.getAIPanelVisible();
149137
if (isAIPanelOpen && getStaticTabBlockCount() === 1) {
@@ -177,10 +165,6 @@ function genericClose() {
177165
WorkspaceLayoutModel.getInstance().setAIPanelVisible(false);
178166
return;
179167
}
180-
if (isStaticTabPinned() && getStaticTabBlockCount() === 1) {
181-
TabBarModel.getInstance().jiggleActivePinnedTab();
182-
return;
183-
}
184168

185169
const workspaceLayoutModel = WorkspaceLayoutModel.getInstance();
186170
const isAIPanelOpen = workspaceLayoutModel.getAIPanelVisible();
@@ -266,7 +250,7 @@ function switchBlockInDirection(direction: NavigateDirection) {
266250
}
267251

268252
function getAllTabs(ws: Workspace): string[] {
269-
return [...(ws.pinnedtabids ?? []), ...(ws.tabids ?? [])];
253+
return ws.tabids ?? [];
270254
}
271255

272256
function switchTabAbs(index: number) {
@@ -532,10 +516,6 @@ function registerGlobalKeys() {
532516
return true;
533517
});
534518
globalKeyMap.set("Cmd:Shift:w", () => {
535-
if (isStaticTabPinned()) {
536-
TabBarModel.getInstance().jiggleActivePinnedTab();
537-
return true;
538-
}
539519
simpleCloseStaticTab();
540520
return true;
541521
});

frontend/app/store/services.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,13 @@ export const WindowService = new WindowServiceType();
133133

134134
// workspaceservice.WorkspaceService (workspace)
135135
class WorkspaceServiceType {
136-
// @returns object updates
137-
ChangeTabPinning(workspaceId: string, tabId: string, pinned: boolean): Promise<void> {
138-
return WOS.callBackendService("workspace", "ChangeTabPinning", Array.from(arguments))
139-
}
140-
141136
// @returns CloseTabRtn (and object updates)
142137
CloseTab(workspaceId: string, tabId: string, fromElectron: boolean): Promise<CloseTabRtnType> {
143138
return WOS.callBackendService("workspace", "CloseTab", Array.from(arguments))
144139
}
145140

146141
// @returns tabId (and object updates)
147-
CreateTab(workspaceId: string, tabName: string, activateTab: boolean, pinned: boolean): Promise<string> {
142+
CreateTab(workspaceId: string, tabName: string, activateTab: boolean): Promise<string> {
148143
return WOS.callBackendService("workspace", "CreateTab", Array.from(arguments))
149144
}
150145

@@ -182,7 +177,7 @@ class WorkspaceServiceType {
182177
}
183178

184179
// @returns object updates
185-
UpdateTabIds(workspaceId: string, tabIds: string[], pinnedTabIds: string[]): Promise<void> {
180+
UpdateTabIds(workspaceId: string, tabIds: string[]): Promise<void> {
186181
return WOS.callBackendService("workspace", "UpdateTabIds", Array.from(arguments))
187182
}
188183

frontend/app/tab/tab.tsx

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import { Button } from "@/element/button";
88
import { ContextMenuModel } from "@/store/contextmenu";
99
import { fireAndForget } from "@/util/util";
1010
import clsx from "clsx";
11-
import { useAtomValue } from "jotai";
1211
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
1312
import { ObjectService } from "../store/services";
1413
import { makeORef, useWaveObjectValue } from "../store/wos";
1514
import "./tab.scss";
16-
import { TabBarModel } from "./tabbar-model";
1715

1816
interface TabProps {
1917
id: string;
@@ -23,39 +21,21 @@ interface TabProps {
2321
isDragging: boolean;
2422
tabWidth: number;
2523
isNew: boolean;
26-
isPinned: boolean;
2724
onSelect: () => void;
2825
onClose: (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null) => void;
2926
onDragStart: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
3027
onLoaded: () => void;
31-
onPinChange: () => void;
3228
}
3329

3430
const Tab = memo(
3531
forwardRef<HTMLDivElement, TabProps>(
3632
(
37-
{
38-
id,
39-
active,
40-
isPinned,
41-
isBeforeActive,
42-
isDragging,
43-
tabWidth,
44-
isNew,
45-
onLoaded,
46-
onSelect,
47-
onClose,
48-
onDragStart,
49-
onPinChange,
50-
},
33+
{ id, active, isBeforeActive, isDragging, tabWidth, isNew, onLoaded, onSelect, onClose, onDragStart },
5134
ref
5235
) => {
5336
const [tabData, _] = useWaveObjectValue<Tab>(makeORef("tab", id));
5437
const [originalName, setOriginalName] = useState("");
5538
const [isEditable, setIsEditable] = useState(false);
56-
const [isJiggling, setIsJiggling] = useState(false);
57-
58-
const jiggleTrigger = useAtomValue(TabBarModel.getInstance().jigglePinAtom);
5939

6040
const editableRef = useRef<HTMLDivElement>(null);
6141
const editableTimeoutRef = useRef<NodeJS.Timeout>(null);
@@ -148,16 +128,6 @@ const Tab = memo(
148128
}
149129
}, [isNew, tabWidth]);
150130

151-
useEffect(() => {
152-
if (active && isPinned && jiggleTrigger > 0) {
153-
setIsJiggling(true);
154-
const timeout = setTimeout(() => {
155-
setIsJiggling(false);
156-
}, 500);
157-
return () => clearTimeout(timeout);
158-
}
159-
}, [jiggleTrigger, active, isPinned]);
160-
161131
// Prevent drag from being triggered on mousedown
162132
const handleMouseDownOnClose = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
163133
event.stopPropagation();
@@ -167,7 +137,6 @@ const Tab = memo(
167137
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
168138
e.preventDefault();
169139
let menu: ContextMenuItem[] = [
170-
{ label: isPinned ? "Unpin Tab" : "Pin Tab", click: () => onPinChange() },
171140
{ label: "Rename Tab", click: () => handleRenameTab(null) },
172141
{
173142
label: "Copy TabId",
@@ -210,7 +179,7 @@ const Tab = memo(
210179
menu.push({ label: "Close Tab", click: () => onClose(null) });
211180
ContextMenuModel.showContextMenu(menu, e);
212181
},
213-
[onPinChange, handleRenameTab, id, onClose, isPinned]
182+
[handleRenameTab, id, onClose]
214183
);
215184

216185
return (
@@ -239,27 +208,14 @@ const Tab = memo(
239208
>
240209
{tabData?.name}
241210
</div>
242-
{isPinned ? (
243-
<Button
244-
className={clsx("ghost grey pin", { jiggling: isJiggling })}
245-
onClick={(e) => {
246-
e.stopPropagation();
247-
onPinChange();
248-
}}
249-
title="Unpin Tab"
250-
>
251-
<i className="fa fa-solid fa-thumbtack" />
252-
</Button>
253-
) : (
254-
<Button
255-
className="ghost grey close"
256-
onClick={onClose}
257-
onMouseDown={handleMouseDownOnClose}
258-
title="Close Tab"
259-
>
260-
<i className="fa fa-solid fa-xmark" />
261-
</Button>
262-
)}
211+
<Button
212+
className="ghost grey close"
213+
onClick={onClose}
214+
onMouseDown={handleMouseDownOnClose}
215+
title="Close Tab"
216+
>
217+
<i className="fa fa-solid fa-xmark" />
218+
</Button>
263219
</div>
264220
</div>
265221
);

frontend/app/tab/tabbar.tsx

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ function setIsEqual(a: Set<string> | null, b: Set<string> | null): boolean {
160160

161161
const TabBar = memo(({ workspace }: TabBarProps) => {
162162
const [tabIds, setTabIds] = useState<string[]>([]);
163-
const [pinnedTabIds, setPinnedTabIds] = useState<Set<string>>(new Set());
164163
const [dragStartPositions, setDragStartPositions] = useState<number[]>([]);
165164
const [draggingTab, setDraggingTab] = useState<string>();
166165
const [tabsLoaded, setTabsLoaded] = useState({});
@@ -209,17 +208,14 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
209208
if (!workspace) {
210209
return;
211210
}
212-
// Compare current tabIds with new workspace.tabids
213-
const newTabIdsArr = [...(workspace.pinnedtabids ?? []), ...(workspace.tabids ?? [])];
214-
const newPinnedTabSet = new Set(workspace.pinnedtabids ?? []);
211+
const newTabIdsArr = workspace.tabids ?? [];
215212

216-
const areEqual = strArrayIsEqual(tabIds, newTabIdsArr) && setIsEqual(pinnedTabIds, newPinnedTabSet);
213+
const areEqual = strArrayIsEqual(tabIds, newTabIdsArr);
217214

218215
if (!areEqual) {
219216
setTabIds(newTabIdsArr);
220-
setPinnedTabIds(newPinnedTabSet);
221217
}
222-
}, [workspace, tabIds, pinnedTabIds]);
218+
}, [workspace, tabIds]);
223219

224220
const saveTabsPosition = useCallback(() => {
225221
const tabs = tabRefs.current;
@@ -483,47 +479,17 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
483479
}
484480
};
485481

486-
// } else if ((tabIndex > pinnedTabCount || (tabIndex === 1 && pinnedTabCount === 1)) && isPinned) {
487-
488482
const setUpdatedTabsDebounced = useCallback(
489-
debounce(300, (tabIndex: number, tabIds: string[], pinnedTabIds: Set<string>) => {
490-
console.log(
491-
"setting updated tabs",
492-
tabIds,
493-
pinnedTabIds,
494-
tabIndex,
495-
draggingTabDataRef.current.tabStartIndex
496-
);
483+
debounce(300, (tabIds: string[]) => {
497484
// Reset styles
498485
tabRefs.current.forEach((ref) => {
499486
ref.current.style.zIndex = "0";
500487
ref.current.classList.remove("animate");
501488
});
502-
let pinnedTabCount = pinnedTabIds.size;
503-
const draggedTabId = draggingTabDataRef.current.tabId;
504-
const isPinned = pinnedTabIds.has(draggedTabId);
505-
const nextTabId = tabIds[tabIndex + 1];
506-
const prevTabId = tabIds[tabIndex - 1];
507-
if (!isPinned && nextTabId && pinnedTabIds.has(nextTabId)) {
508-
pinnedTabIds.add(draggedTabId);
509-
} else if (isPinned && prevTabId && !pinnedTabIds.has(prevTabId)) {
510-
pinnedTabIds.delete(draggedTabId);
511-
}
512-
if (pinnedTabCount != pinnedTabIds.size) {
513-
console.log("updated pinnedTabIds", pinnedTabIds, tabIds);
514-
setPinnedTabIds(pinnedTabIds);
515-
pinnedTabCount = pinnedTabIds.size;
516-
}
517489
// Reset dragging state
518490
setDraggingTab(null);
519491
// Update workspace tab ids
520-
fireAndForget(() =>
521-
WorkspaceService.UpdateTabIds(
522-
workspace.oid,
523-
tabIds.slice(pinnedTabCount),
524-
tabIds.slice(0, pinnedTabCount)
525-
)
526-
);
492+
fireAndForget(() => WorkspaceService.UpdateTabIds(workspace.oid, tabIds));
527493
}),
528494
[]
529495
);
@@ -542,7 +508,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
542508
}
543509

544510
if (dragged) {
545-
setUpdatedTabsDebounced(tabIndex, tabIds, pinnedTabIds);
511+
setUpdatedTabsDebounced(tabIds);
546512
} else {
547513
// Reset styles
548514
tabRefs.current.forEach((ref) => {
@@ -626,14 +592,6 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
626592
deleteLayoutModelForTab(tabId);
627593
};
628594

629-
const handlePinChange = useCallback(
630-
(tabId: string, pinned: boolean) => {
631-
console.log("handlePinChange", tabId, pinned);
632-
fireAndForget(() => WorkspaceService.ChangeTabPinning(workspace.oid, tabId, pinned));
633-
},
634-
[workspace]
635-
);
636-
637595
const handleTabLoaded = useCallback((tabId: string) => {
638596
setTabsLoaded((prev) => {
639597
if (!prev[tabId]) {
@@ -703,20 +661,17 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
703661
<div className="tab-bar" ref={tabBarRef} data-overlayscrollbars-initialize>
704662
<div className="tabs-wrapper" ref={tabsWrapperRef} style={{ width: `${tabsWrapperWidth}px` }}>
705663
{tabIds.map((tabId, index) => {
706-
const isPinned = pinnedTabIds.has(tabId);
707664
return (
708665
<Tab
709666
key={tabId}
710667
ref={tabRefs.current[index]}
711668
id={tabId}
712669
isFirst={index === 0}
713-
isPinned={isPinned}
714670
onSelect={() => handleSelectTab(tabId)}
715671
active={activeTabId === tabId}
716672
onDragStart={(event) => handleDragStart(event, tabId, tabRefs.current[index])}
717673
onClose={(event) => handleCloseTab(event, tabId)}
718674
onLoaded={() => handleTabLoaded(tabId)}
719-
onPinChange={() => handlePinChange(tabId, !isPinned)}
720675
isBeforeActive={isBeforeActive(tabId)}
721676
isDragging={draggingTab === tabId}
722677
tabWidth={tabWidthRef.current}

0 commit comments

Comments
 (0)