Skip to content

Commit e913695

Browse files
fix(web): record address-bar visits by the profile the page opened in
An address-bar submit from an Incognito tab can open a new regular-profile tab (no in-place navigation available); that visit belongs in history. Check the destination tab's profile instead of the source tab's. AI-assisted; verified with the tests and tools listed above.
1 parent 6a7e4ed commit e913695

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,23 @@ export function PreviewView({
245245
// IPC interprets undefined profile ids as all profiles.
246246
const activeProfileId = snapshot?.profileId ?? DEFAULT_BROWSER_PROFILE_ID;
247247
const activeProfileName = previewProfileName(browserDefaults.profiles, activeProfileId);
248-
// Incognito visits stay out of the project's persisted history.
249-
const isIncognito = activeProfileId === INCOGNITO_BROWSER_PROFILE_ID;
250248
const panelRect = useBrowserSurfaceStore((state) =>
251249
runtimeTabId ? (state.byTabId[runtimeTabId]?.rect ?? null) : null,
252250
);
253251

252+
/** Resolves to the profile of the tab that loaded the URL, or null when nothing opened. */
254253
const navigateToResolvedUrl = async (resolvedUrl: string) => {
255254
if (isServerTab && serverSurfaceRef.current) {
256-
if (serverInputDisabled) return false;
255+
if (serverInputDisabled) return null;
257256
serverSurfaceRef.current.navigate(resolvedUrl);
258257
rememberPreviewUrl(threadRef, resolvedUrl);
259-
return true;
258+
return activeProfileId;
260259
}
261260
if (runtimeTabId && previewBridge) {
262261
await previewBridge.navigate(runtimeTabId, resolvedUrl);
263262
rememberPreviewUrl(threadRef, resolvedUrl);
264263
focusPreviewPage(runtimeTabId);
265-
return true;
264+
return activeProfileId;
266265
}
267266
const result = await openPreviewSession({ openPreview: open, threadRef, url: resolvedUrl });
268267
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
@@ -275,13 +274,19 @@ export function PreviewView({
275274
});
276275
}
277276
}
278-
return result._tag === "Success";
277+
return result._tag === "Success"
278+
? (result.value.profileId ?? DEFAULT_BROWSER_PROFILE_ID)
279+
: null;
279280
};
280281

282+
// Incognito visits stay out of the project's persisted history.
283+
const isHistoryProfile = (profileId: string | null) =>
284+
profileId !== null && profileId !== INCOGNITO_BROWSER_PROFILE_ID;
285+
281286
const handleSubmitUrl = async (next: string) => {
282287
try {
283288
const resolved = resolveAddressBarInput(next, resolveSearchUrlTemplate(getClientSettings()));
284-
if ((await navigateToResolvedUrl(resolved)) && !isIncognito) {
289+
if (isHistoryProfile(await navigateToResolvedUrl(resolved))) {
285290
recordVisitForThread(threadRef, resolved);
286291
}
287292
} catch (error) {
@@ -303,7 +308,7 @@ export function PreviewView({
303308
isServerTab || !previewBridge
304309
? normalizePreviewUrl(next)
305310
: resolveDiscoveredServerUrl(threadRef.environmentId, next);
306-
if ((await navigateToResolvedUrl(resolved)) && !isIncognito) {
311+
if (isHistoryProfile(await navigateToResolvedUrl(resolved))) {
307312
recordVisitForThread(threadRef, next);
308313
}
309314
} catch (error) {

0 commit comments

Comments
 (0)