Skip to content

Commit 9be66e9

Browse files
amitsingh-007claude
andcommitted
refactor: remove dead code across workspaces
Nine confirmed-unused symbols, verified by repo-wide grep including both Playwright suites as callers. - trpc: drop the reqMetaData context field plus getIpAddress and FALLBACK_IP_ADDRESS. Two header parses ran on every request and nothing ever read the result; ITRPCContext collapses to { user }. - shared: drop DEFAULT_RULE_ALIAS from e2e-tests constants. It had no importers and had drifted to 'http://///' against the real 'http:///' in ShortcutsPanel, so it was a trap rather than dead weight. - shared: drop clickButtonByName and shouldRenderBookmarks. The latter reduced to contextBookmarks.length > 0 because both params are non-nullable, so it is inlined at its two call sites. - extension: drop searchAndVerify, the off-interface updateTaggedPersons and resetCutBookmarks store members (invisible to the compiler, so they would have rotted silently), setProgress/resetProgress, and fullName — a write-only duplicate of displayName that was being persisted to localStorage. - web: drop the bookmarks localStorage write-back, which re-serialised the entire bookmark DB on every mount and folder navigation without changing anything. Removing shouldRenderBookmarks also drops `folders` from the BookmarksPanel useShallow selector, so that component no longer re-renders when folders change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 6a910a2 commit 9be66e9

14 files changed

Lines changed: 7 additions & 115 deletions

File tree

apps/extension/src/entrypoints/popup/panels/BookmarksPanel/components/BookmarksPanel.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
HEADER_HEIGHT,
66
ScrollButton,
77
getFilteredContextBookmarks,
8-
shouldRenderBookmarks,
98
} from '@bypass/shared';
109
import { ScrollArea } from '@bypass/ui';
1110
import { useVirtualizer } from '@tanstack/react-virtual';
@@ -31,15 +30,13 @@ function BookmarksPanel({ folderId, operation, bmUrl }: BMPanelQueryParams) {
3130
);
3231
const {
3332
contextBookmarks,
34-
folders,
3533
selectedBookmarks,
3634
cutBookmarks,
3735
isFetching,
3836
loadData,
3937
} = useBookmarkStore(
4038
useShallow((state) => ({
4139
contextBookmarks: state.contextBookmarks,
42-
folders: state.folders,
4340
selectedBookmarks: state.selectedBookmarks,
4441
cutBookmarks: state.cutBookmarks,
4542
isFetching: state.isFetching,
@@ -117,7 +114,7 @@ function BookmarksPanel({ folderId, operation, bmUrl }: BMPanelQueryParams) {
117114
className="w-full"
118115
style={{ height: MAX_PANEL_SIZE.HEIGHT - HEADER_HEIGHT }}
119116
>
120-
{shouldRenderBookmarks(folders, filteredContextBookmarks) ? (
117+
{filteredContextBookmarks.length > 0 ? (
121118
<div
122119
className="relative w-full"
123120
style={{ height: virtualizer.getTotalSize() }}

apps/extension/src/entrypoints/popup/panels/BookmarksPanel/store/useBookmarkStore.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const useBookmarkStore = create<State>()((set, get) => ({
6060
cutBookmarks: [],
6161
isFetching: true,
6262
isSaveButtonActive: false,
63-
updateTaggedPersons: [],
6463

6564
async loadData(folderId: string) {
6665
set({ isSaveButtonActive: false, isFetching: true });
@@ -98,8 +97,6 @@ const useBookmarkStore = create<State>()((set, get) => ({
9897
set({ cutBookmarks: [...selectedBookmarks] });
9998
},
10099

101-
resetCutBookmarks: () => set({ cutBookmarks: [] }),
102-
103100
handleCreateNewFolder(name: string, parentFolderId: string) {
104101
const { contextBookmarks, folderList } = get();
105102
const isDir = true;

apps/extension/src/interfaces/firebase.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export interface IAuthResponse {
22
readonly uid: string;
33
readonly email: string;
4-
readonly fullName: string;
54
readonly photoUrl?: string;
65
readonly displayName?: string;
76
readonly expiresIn: number;

apps/extension/src/store/firebase/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const signInWithCredential = async (accessToken: string) => {
3232
.json<IAuthResponse>((res) => ({
3333
uid: res.localId,
3434
email: res.email,
35-
fullName: res.displayName,
3635
photoUrl: res.photoUrl,
3736
displayName: res.displayName,
3837
idToken: res.idToken,

apps/extension/src/store/progress.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ interface ProgressState {
55
progress: number;
66
startLoading: () => void;
77
stopLoading: () => void;
8-
setProgress: (progress: number) => void;
98
incrementProgress: (totalSteps: number) => void;
10-
resetProgress: () => void;
119
}
1210

1311
const useProgressStore = create<ProgressState>()((set, get) => ({
@@ -21,18 +19,12 @@ const useProgressStore = create<ProgressState>()((set, get) => ({
2119
set(() => ({ isLoading: false, progress: 0 }));
2220
}, 300); // 300ms delay allows users to see progress at 100% before overlay disappears
2321
},
24-
setProgress(progress: number) {
25-
set(() => ({ progress }));
26-
},
2722
incrementProgress(totalSteps: number) {
2823
const { progress } = get();
2924
const stepSize = 100 / totalSteps;
3025
const newProgress = Math.min(progress + stepSize, 100);
3126
set(() => ({ progress: newProgress }));
3227
},
33-
resetProgress() {
34-
set(() => ({ progress: 0 }));
35-
},
3628
}));
3729

3830
export default useProgressStore;

apps/extension/tests/auth.setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const signInWithEmailAndPassword = async (): Promise<IAuthResponse> => {
3838
.json<IAuthResponse>((res) => ({
3939
uid: res.localId,
4040
email: res.email,
41-
fullName: res.displayName,
4241
photoUrl: '',
4342
displayName: res.displayName,
4443
idToken: res.idToken,

apps/extension/tests/utils/test-utils.ts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
fillSearchInput as fillSearchInputShared,
3-
parseBadgeCount,
4-
} from '@bypass/shared/tests';
1+
import { parseBadgeCount } from '@bypass/shared/tests';
52
import { expect, type Page } from '@playwright/test';
63

74
// Re-export shared utilities for convenience
@@ -83,38 +80,6 @@ export const openFolder = async (page: Page, folderName: string) => {
8380
await folder.click();
8481
};
8582

86-
interface SearchAndVerifyOptions {
87-
visibleTexts: string[];
88-
hiddenTexts?: string[];
89-
selector?: string;
90-
}
91-
92-
/**
93-
* Search and verify elements are visible/not visible.
94-
*/
95-
export const searchAndVerify = async (
96-
page: Page,
97-
searchText: string,
98-
options: SearchAndVerifyOptions
99-
) => {
100-
const {
101-
visibleTexts,
102-
hiddenTexts = [],
103-
selector = '[data-testid^="person-item-"]',
104-
} = options;
105-
await fillSearchInputShared(page, searchText);
106-
107-
for (const text of visibleTexts) {
108-
const element = page.locator(selector).filter({ hasText: text });
109-
await expect(element).toBeVisible();
110-
}
111-
112-
for (const text of hiddenTexts) {
113-
const element = page.locator(selector).filter({ hasText: text });
114-
await expect(element).not.toBeVisible();
115-
}
116-
};
117-
11883
/**
11984
* Get item from chrome.storage.local
12085
*/

apps/web/src/app/bookmark-panel/page.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ import {
99
getFolderName,
1010
Header,
1111
type IBookmarksObj,
12-
shouldRenderBookmarks,
1312
STORAGE_KEYS,
1413
} from '@bypass/shared';
1514
import { ScrollArea } from '@bypass/ui';
1615
import { useVirtualizer } from '@tanstack/react-virtual';
1716
import { useSearchParams } from 'next/navigation';
1817
import { useCallback, useEffect, useRef, useState } from 'react';
1918

20-
import { getFromLocalStorage, setToLocalStorage } from '@app/utils/storage';
19+
import { getFromLocalStorage } from '@app/utils/storage';
2120

2221
import VirtualRow from './components/VirtualRow';
2322

@@ -61,7 +60,6 @@ export default function BookmarksPage() {
6160
setContextBookmarks(modifiedBookmarks);
6261
setFolders(foldersData);
6362
setFolderName(getFolderName(folderListData, folderId));
64-
setToLocalStorage(STORAGE_KEYS.bookmarks, bookmarksData);
6563
}, [folderId]);
6664

6765
useEffect(() => {
@@ -77,7 +75,7 @@ export default function BookmarksPage() {
7775
onSearchChange={handleSearchTextChange}
7876
/>
7977
<ScrollArea viewportRef={scrollAreaRef} className="flex-1">
80-
{shouldRenderBookmarks(folders, filteredContextBookmarks) ? (
78+
{filteredContextBookmarks.length > 0 ? (
8179
<div
8280
style={{ height: virtualizer.getTotalSize() }}
8381
className="relative w-full"

packages/shared/src/components/Bookmarks/utils/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ export const getFilteredContextBookmarks = (
2929
return hasText(searchText, ctx.url) || hasText(searchText, ctx.title);
3030
});
3131

32-
export const shouldRenderBookmarks = (
33-
folders: IBookmarksObj['folders'],
34-
contextBookmarks: ContextBookmarks
35-
) => folders && contextBookmarks && contextBookmarks.length > 0;
36-
3732
export const getEncryptedBookmark = (
3833
bookmark: IEncodedBookmark
3934
): IEncodedBookmark => ({

packages/shared/src/constants/e2e-tests.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ export const TEST_SITES = {
5353
EXAMPLE_NET: 'https://example.net',
5454
} as const;
5555

56-
/**
57-
* Default rule alias that indicates an incomplete rule.
58-
*/
59-
export const DEFAULT_RULE_ALIAS = 'http://///';
60-
6156
/**
6257
* Timeout constants used across test files to avoid magic numbers.
6358
*/

0 commit comments

Comments
 (0)