Merge PR #718: fix(native): keep a link's url seed on the tab it opens

# Conflicts:
#	src/client/native/tab-adapter.tsx
This commit is contained in:
HuanLinOTO committed 2026-10-01 17:11:15 +08:00
commit 84d93ba6ce
2 files changed
+14 -9

No files matched your search

+7 -8
View File
@@ -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<SidebarTab> = {}
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<string, unknown>
: {}
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)
+7 -1
View File
@@ -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 }),
}