diff --git a/src/client/native/tab-adapter.tsx b/src/client/native/tab-adapter.tsx index 35c79cf5..ee30834a 100644 --- a/src/client/native/tab-adapter.tsx +++ b/src/client/native/tab-adapter.tsx @@ -196,12 +196,16 @@ export function createNativeTabRecords(): NativeTabRecords { if (existing === undefined) { const seeded = params?.title === undefined && params?.meta === undefined ? mint?.() : undefined const meta = params?.meta ?? seeded?.meta + // A url seed lands on `path`: the browser tab reads its address from + // there and persists navigations back to the same field, so a record + // that dropped it opened with an empty address bar. + const path = params?.path ?? params?.url const minted: View = { tab: { id, type: kind as TabType, title: params?.title ?? seeded?.title ?? title, - ...(params?.path === undefined ? {} : { path: params.path }), + ...(path === undefined ? {} : { path }), ...(params?.diff === undefined ? {} : { diff: params.diff }), ...(meta === undefined ? {} : { meta }), }, @@ -217,14 +221,9 @@ export function createNativeTabRecords(): NativeTabRecords { // a browser tab pointed at another URL); the record's identity and any // plugin-side mutation (title/meta from updateTab) stay. const patch: Partial = {} - if (params?.path !== undefined && params.path !== existing.tab.path) patch.path = params.path + const nextPath = params?.path ?? params?.url + if (nextPath !== undefined && nextPath !== existing.tab.path) patch.path = nextPath if (params?.diff !== undefined) patch.diff = params.diff - if (params?.url !== undefined) { - const meta = typeof existing.tab.meta === 'object' && existing.tab.meta !== null - ? existing.tab.meta as Record - : {} - patch.meta = { ...meta, url: params.url } - } // The expansion set always mirrors the CURRENT session state (a record // reused for another session must not keep the previous one's set). const expanded = expandedOf(scope.sessionId) diff --git a/src/client/service.ts b/src/client/service.ts index 182f1da5..1e55c7b0 100644 --- a/src/client/service.ts +++ b/src/client/service.ts @@ -925,11 +925,17 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe // Multi-instance kinds (terminal / browser / side chat / diff) mint a // fresh tab per open; single-instance kinds focus the existing one. const revealIfOpened = descriptor.createTab === undefined + // A url seed lands on `path`: the browser tab reads its address from + // there and persists navigations back to the same field + // (BrowserView's `persist`), so dropping the seed left an opened tab + // with an empty address bar. `path` means the file to open only for + // `editor`, which never carries a url seed. + const componentPath = seed.path ?? seed.url const synthetic: SidebarTab = { id: seed.id ?? minted?.tab.id ?? seed.type, type: seed.type, title, - ...(seed.path === undefined ? {} : { path: seed.path }), + ...(componentPath === undefined ? {} : { path: componentPath }), ...(seed.diff === undefined ? {} : { diff: seed.diff }), ...(seed.meta === undefined && minted?.tab.meta === undefined ? {} : { meta: seed.meta ?? minted?.tab.meta }), }