Skip to content

Commit 23faa32

Browse files
SharonStratsGPT-5.6 Luna
andcommitted
Refreshing browse.html - do not redirect
Prompt: when on browse.html the user gets redirected to localhost:3100/storare Co-authored-by: GPT-5.6 Luna <gpt-5.6-luna@openai.com>
1 parent d839207 commit 23faa32

4 files changed

Lines changed: 43 additions & 7 deletions

File tree

‎docs/navigation-design.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ navigation controller, which always applies the same follow-up effects.
5353
mashlib. Those callers rely on it to push the history entry and the URL, so it is the one place that
5454
writes history, and it announces what it did.
5555

56+
Standalone shells such as `browse.html` can pass `preserveUrl: true` in the seventh argument when
57+
they display a subject while keeping their own document URL (the subject is carried in the shell's
58+
query parameters). The current history entry is still replaced with the displayed pane and
59+
account-menu metadata, and navigation is announced from that updated state. This is intentionally
60+
opt-in; ordinary `GotoSubject` callers continue to make the displayed subject the page URL.
61+
5662
Storage is an explicit browser view, not a resource's default pane. Its pane item
5763
renders the storage root with `solo` and `fullView` disabled, so the storage
5864
header, sidebar and listing remain visible even if the root has an index document.

‎src/navigation/options.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export type FolderView = 'explorer' | 'storage' | 'container'
1717
export interface GotoSubjectOptions {
1818
source?: NavigationSource
1919
folderView?: FolderView
20+
/** Keep the caller's document URL while displaying a different subject. */
21+
preserveUrl?: boolean
2022
}
2123

2224
/** The folder view a `GotoSubject` caller asked for, if any. */

‎src/outline/manager.js‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,12 +1941,8 @@ export default function (context) {
19411941
createSubjectBlock()
19421942
}
19431943

1944-
if (
1945-
solo &&
1946-
dom &&
1947-
dom.defaultView &&
1948-
dom.defaultView.history
1949-
) {
1944+
if (solo && dom && dom.defaultView && dom.defaultView.history) {
1945+
const preserveUrl = options && typeof options === 'object' && options.preserveUrl === true
19501946
const currentState = dom.defaultView.history.state || {}
19511947
const leavingPage = document.location.href !== subject.uri
19521948
const stateObj = nextHistoryState(currentState, {
@@ -1959,7 +1955,9 @@ export default function (context) {
19591955
try {
19601956
const currentUrl = new URL(document.location.href)
19611957
const targetUrl = new URL(subject.uri, document.location.href)
1962-
if (currentUrl.origin === targetUrl.origin) {
1958+
if (preserveUrl) {
1959+
dom.defaultView.history.replaceState(stateObj, '', currentUrl.href)
1960+
} else if (currentUrl.origin === targetUrl.origin) {
19631961
if (leavingPage) {
19641962
dom.defaultView.history.pushState(stateObj, subject.uri, subject.uri)
19651963
} else if (JSON.stringify(currentState) !== JSON.stringify(stateObj)) {

‎test/unit/outline/manager.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,36 @@ describe('manager', () => {
202202
expect(window.history.state).toMatchObject({ paneName: 'mock', paneUri: profile.uri, viaAccountMenu: true })
203203
})
204204

205+
it('updates navigation state while preserving the current URL', () => {
206+
const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } })
207+
const shellUrl = `${window.location.origin}/browse.html?uri=${encodeURIComponent(`${window.location.origin}/other/`)}`
208+
const subject = sym(`${window.location.origin}/other/`)
209+
const pane = { ...MockPane, subject }
210+
window.history.replaceState({ existing: true }, '', shellUrl)
211+
212+
const seen: NavigatedDetail[] = []
213+
const stop = onNavigated(detail => seen.push(detail))
214+
manager.GotoSubject(subject, false, pane, true, undefined, undefined, {
215+
folderView: 'explorer',
216+
preserveUrl: true
217+
})
218+
stop()
219+
220+
expect(window.location.href).toBe(shellUrl)
221+
expect(window.history.state).toMatchObject({
222+
existing: true,
223+
paneName: 'mock',
224+
paneUri: subject.uri
225+
})
226+
expect(seen.at(-1)).toMatchObject({
227+
url: shellUrl,
228+
state: {
229+
view: { kind: 'pane', pane: 'mock', subject: subject.uri },
230+
viaAccountMenu: false
231+
}
232+
})
233+
})
234+
205235
it('displays a navbar pane\'s own subject, and the page subject for panes without one', () => {
206236
const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } })
207237
const page = sym(`${window.location.origin}/other/container/sub/`)

0 commit comments

Comments
 (0)