fix(webapp): landing on / opens the project you last used (BEA-75) - #115
Open
ssowonny wants to merge 1 commit into
Open
fix(webapp): landing on / opens the project you last used (BEA-75)#115ssowonny wants to merge 1 commit into
ssowonny wants to merge 1 commit into
Conversation
Hitting the hub with no project in the URL always resolved to projects[0] — alphabetically first, unrelated to what you were doing — and HubApp then rewrote the address bar to it, so the wrong choice was the one that got bookmarked. The browser now remembers the project it last opened and prefers it. The precedence chain gains one clause between the just-joined org and the fallback; a remembered id is looked up in the project list, so one that was deleted, or that this account can no longer see, simply doesn't match and projects[0] takes over with nothing on screen to say so. localStorage, per browser and origin-scoped, so two hubs never share an answer. Both helpers swallow — storage throws in Safari private mode, and a preference is never worth a broken page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
localStorage, per browser. Not synced across devices, not per account — deliberately (see below).What changed
HubAppresolves the current project from a precedence chain. This adds one clause to it:flowchart TB U["landing with no project in the URL"] R1["1. URL names a visible project"] R2["2. an org was joined this page-load"] R3["3. remembered id, still in the list"] R4["4. projects[0]"] U --> R1 --> R2 --> R3 --> R4 classDef added fill:#22c55e22,stroke:#22c55e,stroke-width:2px class R3 addedRule 3 is the whole feature. Deep links still win, the invite flow still lands you in the org you just joined, and an empty or unrecognized memory falls through to rule 4 exactly as before.
The membership check is free: the remembered id is looked up in the project list the server just sent. Deleted project, revoked membership, or a different account signed in on the same browser — none of them match, so rule 4 takes over silently. That's one
.find, not a code path.src/util.tslastProject()/rememberProject(id), keybdrive.lastProject. Both swallow —localStoragethrows in Safari private mode and wherever storage is disabled, and a preference is never worth a broken page.HubApp.tsxcurrentuseMemo; onerememberProject(current.id)in the effect that already setsdocument.title. That effect fires on exactly the events that matter — sidebar, deep link, palette, post-create navigate — so the memory needs no subscription of its own.src/util.test.tslocalStorage, so the bare run is the storage-missing case; the other two stub a Map-backed store and a throwing one.e2e/hub.spec.tsinternal/webapp/static/What it looks like
Both shots: create a project named
zz-last(so it can never beprojects[0]), open it, then load bare/— the way a bookmark or a new tab arrives.wiki— alphabetically first, and not what you openedzz-last— where you actually wereWhat you're accepting
onHomenavigates to/, which used to mean "project A" from anywhere. On project B it now stays on B. That is whate2e/home.spec.ts:124always claimed it did; it only passed becausewikihappens to sort first. Strictly better, but visible./orgs/<id>and/billingresolve acurrenttoo, so visiting them re-remembers a project you didn't explicitly open. In practice it rewrites the id that was already there, or seedsprojects[0]on a first-ever visit — which is today's behavior. Not worth a route guard.localStoragefor no gain. This is the spec author's inference, not a stated requirement.HubApponly mounts whenconfig.mode === "hub", andVolumeAppshares none of this code. No guard, no test.Verified
go build ./...,go vet ./...go test ./...npm testnpm run e2e./check-dist.shinternal/webapp/static is freshArchitecture changes
architecture/webapp-frontend.md—HubAppgains one member: it now holds a persisted preference (the last opened project, inlocalStorage). No new types, no new edges; every relationship it already had is unchanged.✅ added · ❌ removed (strikethrough) · unmarked = unchanged
flowchart TB App["App"] HubApp["<div style='text-align:left'><b>HubApp</b><br/>project list, org walls<br/>admin panels, invites<br/><span style='background:#22c55e55;padding:0 4px;border-radius:3px'>✅ remembers last opened project (localStorage)</span></div>"] Browser["Browser"] router["router"] components["components"] hooks["hooks"] App --> HubApp HubApp --> Browser HubApp --> router HubApp --> components HubApp --> hooksThe one open loop
Rule 3 remembers the project but not the view inside it — land on
/and you get the project's root, never the History tab you were reading. Explicitly out of scope for BEA-75; worth a follow-up if anyone actually misses it.Closes BEA-75.
Build session
(only works on the machine this branch was built on)
🤖 Generated with Claude Code