Skip to content

Commit 82cef8f

Browse files
committed
Enhance ConnectionBanner and LiveContext for improved data handling
- Updated the ConnectionBanner component to conditionally render based on the presence of loaded data, preventing unnecessary "Connecting..." messages. - Modified the LiveContext to include a new `hasData` state, indicating when data is available, enhancing the overall user experience. - Refactored the RootLayout to pass the new `hasData` prop to the ConnectionBanner. - Cleaned up the Sidebar component by removing unused links, streamlining the navigation structure.
1 parent 7cd9190 commit 82cef8f

4 files changed

Lines changed: 17 additions & 24 deletions

File tree

interface/src/components/ConnectionBanner.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ const stateConfig: Record<Exclude<ConnectionState, "connected">, { label: string
77
disconnected: { label: "Disconnected from server.", variant: "error" },
88
};
99

10-
export function ConnectionBanner({ state }: { state: ConnectionState }) {
10+
export function ConnectionBanner({ state, hasData }: { state: ConnectionState; hasData: boolean }) {
11+
// Don't show "Connecting..." if we already have data loaded
12+
if (state === "connecting" && hasData) return null;
13+
1114
if (state === "connected") return null;
1215

1316
const { label, variant } = stateConfig[state];

interface/src/components/Sidebar.tsx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,15 @@ export function Sidebar({ liveStates, collapsed, onToggle }: SidebarProps) {
8181
{/* Collapsed: icon-only nav */}
8282
{collapsed ? (
8383
<div className="flex flex-col items-center gap-1 pt-2">
84-
<Link
85-
to="/"
86-
className={`flex h-8 w-8 items-center justify-center rounded-md ${
87-
isOverview ? "bg-sidebar-selected text-sidebar-ink" : "text-sidebar-inkDull hover:bg-sidebar-selected/50"
88-
}`}
84+
<Link
85+
to="/"
86+
className={`flex h-8 w-8 items-center justify-center rounded-md ${
87+
isOverview ? "bg-sidebar-selected text-sidebar-ink" : "text-sidebar-inkDull hover:bg-sidebar-selected/50"
88+
}`}
8989
title="Dashboard"
9090
>
9191
<HugeiconsIcon icon={DashboardSquare01Icon} className="h-4 w-4" />
9292
</Link>
93-
<Link
94-
to="/logs"
95-
className="flex h-8 w-8 items-center justify-center rounded-md text-sidebar-inkDull hover:bg-sidebar-selected/50 [&.active]:bg-sidebar-selected [&.active]:text-sidebar-ink"
96-
activeProps={{ className: "active" }}
97-
title="Logs"
98-
>
99-
<HugeiconsIcon icon={LeftToRightListBulletIcon} className="h-4 w-4" />
100-
</Link>
10193
<Link
10294
to="/settings"
10395
className={`flex h-8 w-8 items-center justify-center rounded-md ${
@@ -139,13 +131,6 @@ export function Sidebar({ liveStates, collapsed, onToggle }: SidebarProps) {
139131
>
140132
Dashboard
141133
</Link>
142-
<Link
143-
to="/logs"
144-
className="mx-2 flex items-center gap-2 rounded-md px-2 py-1.5 text-sm text-sidebar-inkDull hover:bg-sidebar-selected/50 [&.active]:bg-sidebar-selected [&.active]:text-sidebar-ink"
145-
activeProps={{ className: "active" }}
146-
>
147-
Logs
148-
</Link>
149134
<Link
150135
to="/settings"
151136
className={`mx-2 flex items-center gap-2 rounded-md px-2 py-1.5 text-sm ${

interface/src/hooks/useLiveContext.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ interface LiveContextValue {
88
liveStates: Record<string, ChannelLiveState>;
99
channels: ChannelInfo[];
1010
connectionState: ConnectionState;
11+
hasData: boolean;
1112
loadOlderMessages: (channelId: string) => void;
1213
}
1314

1415
const LiveContext = createContext<LiveContextValue>({
1516
liveStates: {},
1617
channels: [],
1718
connectionState: "connecting",
19+
hasData: false,
1820
loadOlderMessages: () => {},
1921
});
2022

@@ -46,8 +48,11 @@ export function LiveContextProvider({ children }: { children: ReactNode }) {
4648
onReconnect,
4749
});
4850

51+
// Consider app "ready" once we have any data loaded
52+
const hasData = channels.length > 0 || channelsData !== undefined;
53+
4954
return (
50-
<LiveContext.Provider value={{ liveStates, channels, connectionState, loadOlderMessages }}>
55+
<LiveContext.Provider value={{ liveStates, channels, connectionState, hasData, loadOlderMessages }}>
5156
{children}
5257
</LiveContext.Provider>
5358
);

interface/src/router.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {useLiveContext} from "@/hooks/useLiveContext";
2323
import {AgentTabs} from "@/components/AgentTabs";
2424

2525
function RootLayout() {
26-
const {liveStates, connectionState} = useLiveContext();
26+
const {liveStates, connectionState, hasData} = useLiveContext();
2727
const [sidebarCollapsed, setSidebarCollapsed] = useState(true);
2828

2929
return (
@@ -34,7 +34,7 @@ function RootLayout() {
3434
onToggle={() => setSidebarCollapsed(!sidebarCollapsed)}
3535
/>
3636
<div className="flex flex-1 flex-col overflow-hidden">
37-
<ConnectionBanner state={connectionState} />
37+
<ConnectionBanner state={connectionState} hasData={hasData} />
3838
<UpdateBanner />
3939
<SetupBanner />
4040
<div className="flex-1 overflow-hidden">

0 commit comments

Comments
 (0)