Skip to content

Serve app shell directly instead of JS-redirect via cookie#2707

Merged
simon04 merged 1 commit into
mainfrom
initial_path
Jul 12, 2026
Merged

Serve app shell directly instead of JS-redirect via cookie#2707
simon04 merged 1 commit into
mainfrom
initial_path

Conversation

@simon04

@simon04 simon04 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Deep links to docs and the static pages (settings, offline, about, news, help) previously bounced through / with a short-lived initial_path cookie that the client read back to restore the path. This removes that detour: the server now renders the app shell (erb :index / erb :other) directly at the requested URL, and page.js dispatches location.pathname on start().

This is behaviour that already shipped for docs a user hadn't enabled; enabled docs and the static pages now take the same path. The offline story is unaffected — the service worker already falls back to the cached / for non-asset paths when the network fails.

Removes the initial_path cookie, the redirect_via_js / supports_js_redirection? / modern_browser? helpers, and the client-side getInitialPathFromCookie. The hash-based initial-path handling (used by /search and legacy /#/ bookmarks) is untouched.

Deep links to docs and the static pages (settings, offline, about, news,
help) previously bounced through `/` with a short-lived `initial_path`
cookie that the client read back to restore the path. This removes that
detour: the server now renders the app shell (erb :index / erb :other)
directly at the requested URL, and page.js dispatches location.pathname
on start().

This is behaviour that already shipped for docs a user hadn't enabled;
enabled docs and the static pages now take the same path. The offline
story is unaffected — the service worker already falls back to the
cached `/` for non-asset paths when the network fails.

Removes the `initial_path` cookie, the redirect_via_js /
supports_js_redirection? / modern_browser? helpers, and the client-side
getInitialPathFromCookie. The hash-based initial-path handling (used by
/search and legacy /#/ bookmarks) is untouched.
@simon04 simon04 requested a review from a team as a code owner July 12, 2026 08:10
@simon04 simon04 requested a review from Copilot July 12, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the initial_path cookie + JS-redirect “bounce through /” and instead serves the SPA app shell directly at deep-link URLs (docs paths and static pages like settings/offline/about/news/help). This aligns enabled-doc behavior with the already-shipped behavior for users without enabled docs, while keeping existing hash-based initial-path handling intact.

Changes:

  • Serve erb :index directly for static pages (/settings, /offline, /about, /news, /help) instead of redirecting to /#/... or via the initial_path cookie.
  • Serve erb :other directly for enabled docs URLs instead of redirecting to / with initial_path.
  • Remove client-side getInitialPathFromCookie() handling from the router.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test/app_test.rb Updates expectations from redirects + initial_path cookie to direct 200 responses for static pages and enabled docs.
lib/app.rb Removes JS-redirection helpers and switches static page + doc handling to render app shell directly at requested URLs.
assets/javascripts/app/router.js Drops cookie-based initial-path restoration; keeps hash-based handling for legacy /#/ entry points.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/app_test.rb
assert_equal 'https://example.org/', last_response['Location']
assert last_response['Set-Cookie'].start_with?("initial_path=%2F#{page}; path=/; expires=")
assert last_response.ok?
assert_nil last_response['Set-Cookie']
Comment thread test/app_test.rb
assert_equal 'https://example.org/', last_response['Location']
assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%7E5%2F; path=/; expires=")
assert last_response.ok?
assert_nil last_response['Set-Cookie']
Comment thread test/app_test.rb
assert_equal 'https://example.org/', last_response['Location']
assert last_response['Set-Cookie'].start_with?("initial_path=%2Fhtml%2F; path=/; expires=")
assert last_response.ok?
assert_nil last_response['Set-Cookie']
@simon04 simon04 merged commit 7913527 into main Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants