Skip to content

Commit 1c5f2f9

Browse files
Copilotsawka
andauthored
Remove unused FlashError pipeline (UI + global state + style/type surface) (#2928)
`FlashError` was legacy UI/state that was never wired into real runtime flows (only self-referenced and window-exported for ad-hoc testing). This PR removes that dead path end-to-end to reduce global surface area and stale styling/types. - **Scope: UI removal (`frontend/app/app.tsx`)** - Deleted the `FlashError` component and its render site (`<FlashError />`). - Removed now-unused imports tied to that component (`removeFlashError`, `Fragment`, `useState`). - **Scope: global store cleanup (`frontend/app/store/global.ts`, `frontend/app/store/global-atoms.ts`)** - Removed `pushFlashError` / `removeFlashError`. - Removed `flashErrors` atom from global atom initialization and registry. - Kept notification path intact (`pushNotification`, `removeNotificationById`, etc.). - **Scope: external/debug surface cleanup (`frontend/wave.ts`)** - Removed `pushFlashError` from imports and from `window` export wiring. - **Scope: type + style cleanup (`frontend/types/custom.d.ts`, `frontend/app/app.scss`, `frontend/app/theme.scss`)** - Removed `GlobalAtomsType.flashErrors`. - Removed `FlashErrorType`. - Removed `.flash-error-container` style block and related z-index token `--zindex-flash-error-container`. ```ts // before (window as any).pushFlashError = pushFlashError; // after (window as any).pushNotification = pushNotification; ``` - **`<screenshot>`** - User-provided screenshot URL (if suitable for PR timeline context): https://github.com/user-attachments/assets/aacc2e61-a65c-4dbf-bfcc-f9f99a490f20 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
1 parent 4dd83c3 commit 1c5f2f9

7 files changed

Lines changed: 1 addition & 145 deletions

File tree

frontend/app/app.scss

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -111,41 +111,3 @@ a {
111111
transition-delay: none !important;
112112
}
113113
}
114-
115-
.flash-error-container {
116-
position: absolute;
117-
right: 10px;
118-
bottom: 10px;
119-
z-index: var(--zindex-flash-error-container);
120-
display: flex;
121-
flex-direction: column;
122-
gap: 10px;
123-
124-
.flash-error {
125-
background: var(--error-color);
126-
color: var(--main-text-color);
127-
border-radius: 4px;
128-
padding: 10px;
129-
display: flex;
130-
flex-direction: column;
131-
width: 280px;
132-
border: 1px solid transparent;
133-
max-height: 100px;
134-
cursor: pointer;
135-
136-
.flash-error-scroll {
137-
overflow-y: auto;
138-
display: flex;
139-
flex-direction: column;
140-
}
141-
142-
&.hovered {
143-
border: 1px solid var(--main-text-color);
144-
}
145-
146-
.flash-error-title {
147-
font-weight: bold;
148-
margin-bottom: 5px;
149-
}
150-
}
151-
}

frontend/app/app.tsx

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
getTabIndicatorAtom,
1515
globalStore,
1616
isDev,
17-
removeFlashError,
1817
} from "@/store/global";
1918
import { appHandleKeyDown, keyboardMouseDownHandler } from "@/store/keymodel";
2019
import { getElemAsStr } from "@/util/focusutil";
@@ -25,7 +24,7 @@ import clsx from "clsx";
2524
import debug from "debug";
2625
import { Provider, useAtomValue } from "jotai";
2726
import "overlayscrollbars/overlayscrollbars.css";
28-
import { Fragment, useEffect, useState } from "react";
27+
import { useEffect } from "react";
2928
import { DndProvider } from "react-dnd";
3029
import { HTML5Backend } from "react-dnd-html5-backend";
3130
import { AppBackground } from "./app-bg";
@@ -237,78 +236,6 @@ const TabIndicatorAutoClearing = () => {
237236
return null;
238237
};
239238

240-
const FlashError = () => {
241-
const flashErrors = useAtomValue(atoms.flashErrors);
242-
const [hoveredId, setHoveredId] = useState<string>(null);
243-
const [ticker, setTicker] = useState<number>(0);
244-
245-
useEffect(() => {
246-
if (flashErrors.length == 0 || hoveredId != null) {
247-
return;
248-
}
249-
const now = Date.now();
250-
for (let ferr of flashErrors) {
251-
if (ferr.expiration == null || ferr.expiration < now) {
252-
removeFlashError(ferr.id);
253-
}
254-
}
255-
setTimeout(() => setTicker(ticker + 1), 1000);
256-
}, [flashErrors, ticker, hoveredId]);
257-
258-
if (flashErrors.length == 0) {
259-
return null;
260-
}
261-
262-
function copyError(id: string) {
263-
const ferr = flashErrors.find((f) => f.id === id);
264-
if (ferr == null) {
265-
return;
266-
}
267-
let text = "";
268-
if (ferr.title != null) {
269-
text += ferr.title;
270-
}
271-
if (ferr.message != null) {
272-
if (text.length > 0) {
273-
text += "\n";
274-
}
275-
text += ferr.message;
276-
}
277-
navigator.clipboard.writeText(text);
278-
}
279-
280-
function convertNewlinesToBreaks(text) {
281-
return text.split("\n").map((part, index) => (
282-
<Fragment key={index}>
283-
{part}
284-
<br />
285-
</Fragment>
286-
));
287-
}
288-
289-
return (
290-
<div className="flash-error-container">
291-
{flashErrors.map((err, idx) => (
292-
<div
293-
key={idx}
294-
className={clsx("flash-error", { hovered: hoveredId === err.id })}
295-
onClick={() => copyError(err.id)}
296-
onMouseEnter={() => setHoveredId(err.id)}
297-
onMouseLeave={() => setHoveredId(null)}
298-
title="Click to Copy Error Message"
299-
>
300-
<div className="flash-error-scroll">
301-
{err.title != null ? <div className="flash-error-title">{err.title}</div> : null}
302-
{err.message != null ? (
303-
<div className="flash-error-message">{convertNewlinesToBreaks(err.message)}</div>
304-
) : null}
305-
</div>
306-
</div>
307-
))}
308-
</div>
309-
);
310-
};
311-
312239
const AppInner = () => {
313240
const prefersReducedMotion = useAtomValue(atoms.prefersReducedMotionAtom);
314241
const client = useAtomValue(ClientModel.getInstance().clientAtom);
@@ -340,7 +267,6 @@ const AppInner = () => {
340267
<DndProvider backend={HTML5Backend}>
341268
<Workspace />
342269
</DndProvider>
343-
<FlashError />
344270
{isDev() ? <NotificationBubbles></NotificationBubbles> : null}
345271
</div>
346272
);

frontend/app/store/global-atoms.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
119119
const connStatuses = Array.from(connStatusMap.values()).map((atom) => get(atom));
120120
return connStatuses;
121121
});
122-
const flashErrorsAtom = atom<FlashErrorType[]>([]);
123122
const notificationsAtom = atom<NotificationType[]>([]);
124123
const notificationPopoverModeAtom = atom<boolean>(false);
125124
const reinitVersion = atom(0);
@@ -144,7 +143,6 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
144143
documentHasFocus: documentHasFocusAtom,
145144
modalOpen,
146145
allConnStatus: allConnStatusAtom,
147-
flashErrors: flashErrorsAtom,
148146
notifications: notificationsAtom,
149147
notificationPopoverMode: notificationPopoverModeAtom,
150148
reinitVersion,

frontend/app/store/global.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -736,16 +736,6 @@ function clearAllTabIndicators() {
736736
}
737737
}
738738

739-
function pushFlashError(ferr: FlashErrorType) {
740-
if (ferr.expiration == null) {
741-
ferr.expiration = Date.now() + 5000;
742-
}
743-
ferr.id = crypto.randomUUID();
744-
globalStore.set(atoms.flashErrors, (prev) => {
745-
return [...prev, ferr];
746-
});
747-
}
748-
749739
function addOrUpdateNotification(notif: NotificationType) {
750740
globalStore.set(atoms.notifications, (prevNotifications) => {
751741
// Remove any existing notification with the same ID
@@ -769,12 +759,6 @@ function removeNotificationById(id: string) {
769759
});
770760
}
771761

772-
function removeFlashError(id: string) {
773-
globalStore.set(atoms.flashErrors, (prev) => {
774-
return prev.filter((ferr) => ferr.id !== id);
775-
});
776-
}
777-
778762
function removeNotification(id: string) {
779763
globalStore.set(atoms.notifications, (prev) => {
780764
return prev.filter((notif) => notif.id !== id);
@@ -831,13 +815,11 @@ export {
831815
loadConnStatus,
832816
loadTabIndicators,
833817
openLink,
834-
pushFlashError,
835818
pushNotification,
836819
readAtom,
837820
recordTEvent,
838821
refocusNode,
839822
registerBlockComponentModel,
840-
removeFlashError,
841823
removeNotification,
842824
removeNotificationById,
843825
replaceBlock,

frontend/app/theme.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
--zindex-layout-ephemeral-node-backdrop: 8;
6666
--zindex-layout-ephemeral-node: 9;
6767
--zindex-block-mask-inner: 10;
68-
--zindex-flash-error-container: 550;
6968
--zindex-app-background: -1;
7069

7170
// z-indexes in xterm.css

frontend/types/custom.d.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ declare global {
2525
updaterStatusAtom: jotai.PrimitiveAtom<UpdaterStatus>;
2626
modalOpen: jotai.PrimitiveAtom<boolean>;
2727
allConnStatus: jotai.Atom<ConnStatus[]>;
28-
flashErrors: jotai.PrimitiveAtom<FlashErrorType[]>;
2928
notifications: jotai.PrimitiveAtom<NotificationType[]>;
3029
notificationPopoverMode: jotai.Atom<boolean>;
3130
reinitVersion: jotai.PrimitiveAtom<number>;
@@ -408,14 +407,6 @@ declare global {
408407
baseDir: string;
409408
};
410409

411-
type FlashErrorType = {
412-
id: string;
413-
icon: string;
414-
title: string;
415-
message: string;
416-
expiration: number;
417-
};
418-
419410
export type NotificationActionType = {
420411
label: string;
421412
actionKey: string;

frontend/wave.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
initGlobalWaveEventSubs,
2727
loadConnStatus,
2828
loadTabIndicators,
29-
pushFlashError,
3029
pushNotification,
3130
removeNotificationById,
3231
subscribeToConnEvents,
@@ -50,7 +49,6 @@ let savedInitOpts: WaveInitOpts = null;
5049
(window as any).countersPrint = countersPrint;
5150
(window as any).countersClear = countersClear;
5251
(window as any).getLayoutModelForStaticTab = getLayoutModelForStaticTab;
53-
(window as any).pushFlashError = pushFlashError;
5452
(window as any).pushNotification = pushNotification;
5553
(window as any).removeNotificationById = removeNotificationById;
5654
(window as any).modalsModel = modalsModel;

0 commit comments

Comments
 (0)