GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(preview): preserve server-card routing · pingdotgg/t3code@57c59af

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/preview
    • PreviewView.test.tsx
    • PreviewView.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/preview/PreviewView.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/preview/PreviewView.test.tsx
+57-15Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const mocks = vi.hoisted(() => ({
77
rememberPreviewUrl: vi.fn(),
88
readPreparedConnection: vi.fn(() => ({ httpBaseUrl: "http://172.25.85.75:3773" })),
99
submittedUrl: null as ((url: string) => void) | null,
10+
emptyStateUrl: null as ((url: string) => void) | null,
11+
showEmptyState: false,
1012
}));
1113

1214
vi.mock("~/state/session", () => ({
@@ -42,20 +44,22 @@ vi.mock("~/previewStateStore", () => ({
4244
},
4345
},
4446
recentlySeenUrls: [],
45-
sessions: {
46-
"tab-1": {
47-
threadId: "thread-1",
48-
tabId: "tab-1",
49-
navStatus: {
50-
_tag: "Success",
51-
url: "http://example.com/",
52-
title: "Example",
47+
sessions: mocks.showEmptyState
48+
? {}
49+
: {
50+
"tab-1": {
51+
threadId: "thread-1",
52+
tabId: "tab-1",
53+
navStatus: {
54+
_tag: "Success",
55+
url: "http://example.com/",
56+
title: "Example",
57+
},
58+
canGoBack: false,
59+
canGoForward: false,
60+
updatedAt: "2026-07-13T00:00:00.000Z",
61+
},
5362
},
54-
canGoBack: false,
55-
canGoForward: false,
56-
updatedAt: "2026-07-13T00:00:00.000Z",
57-
},
58-
},
5963
}),
6064
}));
6165

@@ -100,7 +104,12 @@ vi.mock("./PreviewChromeRow", () => ({
100104
},
101105
}));
102106

103-
vi.mock("./PreviewEmptyState", () => ({ PreviewEmptyState: () => null }));
107+
vi.mock("./PreviewEmptyState", () => ({
108+
PreviewEmptyState: (props: { onOpenUrl: (url: string) => void }) => {
109+
mocks.emptyStateUrl = props.onOpenUrl;
110+
return null;
111+
},
112+
}));
104113
vi.mock("./PreviewMoreMenu", () => ({ PreviewMoreMenu: () => null }));
105114
vi.mock("./PreviewUnreachable", () => ({ PreviewUnreachable: () => null }));
106115
vi.mock("./ZoomIndicator", () => ({ ZoomIndicator: () => null }));
@@ -111,12 +120,14 @@ vi.mock("./usePreviewSession", () => ({ usePreviewSession: vi.fn() }));
111120

112121
import { PreviewView } from "./PreviewView";
113122

114-
describe("PreviewView address bar", () => {
123+
describe("PreviewView navigation", () => {
115124
beforeEach(() => {
116125
mocks.navigate.mockClear();
117126
mocks.rememberPreviewUrl.mockClear();
118127
mocks.readPreparedConnection.mockClear();
119128
mocks.submittedUrl = null;
129+
mocks.emptyStateUrl = null;
130+
mocks.showEmptyState = false;
120131
});
121132

122133
it("preserves a direct localhost URL in a WSL environment", async () => {
@@ -148,4 +159,35 @@ describe("PreviewView address bar", () => {
148159
"https://localhost:8000/dashboard?mode=test#top",
149160
);
150161
});
162+
163+
it("maps an empty-state localhost server onto the WSL host", async () => {
164+
mocks.showEmptyState = true;
165+
renderToStaticMarkup(
166+
<PreviewView
167+
threadRef={{
168+
environmentId: EnvironmentId.make("environment-1"),
169+
threadId: ThreadId.make("thread-1"),
170+
}}
171+
tabId="tab-1"
172+
visible
173+
/>,
174+
);
175+
176+
expect(mocks.emptyStateUrl).not.toBeNull();
177+
mocks.emptyStateUrl?.("http://localhost:5173/app?mode=test#top");
178+
179+
await vi.waitFor(() =>
180+
expect(mocks.navigate).toHaveBeenCalledWith(
181+
"tab-1",
182+
"http://172.25.85.75:5173/app?mode=test#top",
183+
),
184+
);
185+
expect(mocks.rememberPreviewUrl).toHaveBeenCalledWith(
186+
{
187+
environmentId: "environment-1",
188+
threadId: "thread-1",
189+
},
190+
"http://172.25.85.75:5173/app?mode=test#top",
191+
);
192+
});
151193
});
Collapse file

‎apps/web/src/components/preview/PreviewView.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/preview/PreviewView.tsx
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import {
1717
updatePreviewServerSnapshot,
1818
useThreadPreviewState,
1919
} from "~/previewStateStore";
20-
import { resolveBrowserNavigationTarget } from "~/browser/browserTargetResolver";
20+
import {
21+
resolveBrowserNavigationTarget,
22+
resolveDiscoveredServerUrl,
23+
} from "~/browser/browserTargetResolver";
2124
import { useEnvironment, useEnvironmentHttpBaseUrl } from "~/state/environments";
2225
import { previewEnvironment } from "~/state/preview";
2326
import { useAtomCommand } from "~/state/use-atom-command";
@@ -138,6 +141,11 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls,
138141
[open, tabId, threadRef],
139142
);
140143

144+
const handleOpenServerUrl = useCallback(
145+
(next: string) => handleSubmitUrl(resolveDiscoveredServerUrl(threadRef.environmentId, next)),
146+
[handleSubmitUrl, threadRef.environmentId],
147+
);
148+
141149
const handleRefresh = useCallback(() => {
142150
if (previewBridge && tabId) void previewBridge.refresh(tabId);
143151
}, [tabId]);
@@ -616,7 +624,7 @@ export function PreviewView({ threadRef, tabId: requestedTabId, configuredUrls,
616624
environmentId={threadRef.environmentId}
617625
configuredUrls={configuredUrls}
618626
recentlySeenUrls={previewState.recentlySeenUrls}
619-
onOpenUrl={(next) => void handleSubmitUrl(next)}
627+
onOpenUrl={(next) => void handleOpenServerUrl(next)}
620628
/>
621629
) : null}
622630
{snapshot && desktopOverlay ? (

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.