Skip to content

feat: support sidebar=collapsed query param for embedded launches - #712

Open
almendio-dev wants to merge 1 commit into
agegr:mainfrom
Almendio:feat/sidebar-collapsed-param
Open

feat: support sidebar=collapsed query param for embedded launches#712
almendio-dev wants to merge 1 commit into
agegr:mainfrom
Almendio:feat/sidebar-collapsed-param

Conversation

@almendio-dev

Copy link
Copy Markdown

What

Adds an opt-in sidebar=collapsed query parameter that opens the app with
the session sidebar collapsed on desktop. All other values are ignored and
keep the current default (sidebar open).

  • lib/initial-navigation.ts: parses the param alongside the existing
    cwd / session params
  • components/AppShell.tsx: initial sidebarOpen state respects the flag
    on first render only; no persistence, no settings entry

Why

Embedders (e.g. launching pi-web in an iframe from Spinup Dev Portal)
want the chat to be the primary surface on open. Today the sidebar always
starts expanded on desktop and there is no supported way to change that
from the launching URL.

Behavior

URL Sidebar on load (desktop)
/ or /?session=x or /?cwd=x open (unchanged)
/?sidebar=collapsed collapsed
/?cwd=x&sidebar=collapsed collapsed
/?session=x&sidebar=collapsed collapsed
/?sidebar=anything-else open (param ignored)

Mobile behavior is unchanged: the sidebar still auto-collapses once the
breakpoint resolves. The top-bar toggle works exactly as before in both
states.

For embedders: sidebar=collapsed contains only URL-safe characters, so
it survives both plain string concatenation and URLSearchParams-based
URL building. The app reads it with searchParams.get(), which decodes
one round of standard percent-encoding; only double-encoding the param
into another param's value would break detection.

Testing

  • node --test unit tests for getInitialNavigation covering all cases
    above plus a URL-encoded value; the four pre-existing assertions gained
    sidebarCollapsed: false (strict deepEqual)
  • tsc --noEmit clean
  • npm run lint: 15 errors, all pre-existing on main, none in changed
    files
  • next build intentionally not run locally per project convention
    (pollutes .next/ during dev); typecheck covers the change surface
  • Manually verified on a desktop viewport (1400x900): /?sidebar=collapsed
    loads with the sidebar closed and the top-bar toggle re-expands it;
    loading without the param or with sidebar=bogus is unchanged

Adds an opt-in sidebar=collapsed query parameter that opens the app with
the session sidebar collapsed on desktop. All other values are ignored
and keep the current default (sidebar open).

- lib/initial-navigation.ts: parses the param alongside the existing
  cwd / session params
- components/AppShell.tsx: initial sidebarOpen state respects the flag
  on first render only; no persistence, no settings entry

Embedders (e.g. launching pi-web in an iframe from a project launcher)
want the chat to be the primary surface on open. Today the sidebar
always starts expanded on desktop and there is no supported way to
change that from the launching URL.

Mobile behavior is unchanged: the sidebar still auto-collapses once the
breakpoint resolves. The top-bar toggle works exactly as before.
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.

1 participant