Repository navigation
fix(workspace): reload the Workspace after the terms are accepted (#4515) - #4561
Conversation
) A Workspace person who had not accepted the terms got the in-place terms screen, accepted, and was then told "Couldn't load your agents — Accept the current terms to continue." beside "No agents shared with you yet". The accept was recorded (200, created:true), but no roster or chat read followed it, so every new portal client hit this on their first sign-in. The cause is an ordering one. `acceptTerms()` cleared `termsRefusal`, the state `Portal.vue` mounts `PortalTerms` under. The scheduler flush that ran before `PortalTerms.onAccept()` resumed from its `await` unmounted the screen, and Vue's `emit()` returns early for an unmounted instance, so the `accepted` event never reached `bootstrap()`. The roster's refusal message stayed in `error`, and the chat reads that the gate had refused kept their failure flag; "Try again" re-read only the roster, so the Inbox still said it could not refresh the chats until a reload. The store no longer clears the refusal on accept. The screen stays mounted until it has emitted, the shell re-bootstraps, and the roster read clears the refusal on success, so the roster, the thread list and the chat state are all read again with the accept in place. The existing specs drove `PortalTerms` alone, or emitted `accepted` by hand right after clearing the refusal, so none saw the unmount-before-emit order; three of them asserted the clear itself and now assert the contract instead. The new mount spec drives `Portal.vue` with the real `PortalTerms` through a click on Accept against a stub server that refuses every gated call until the accept is recorded.
obasilakis
left a comment
There was a problem hiding this comment.
/review + /validate-pr — APPROVE
Lane B (frontend store + specs). Scope clean: one deleted line in clientPortal.js::acceptTerms plus tests. No markup/style change.
Root cause / fix
Confirmed against the code: Portal.vue mounts <PortalTerms v-else-if="store.termsRefusal && store.portalToken" @accepted="bootstrap()">; PortalTerms.onAccept does await store.acceptTerms(...) then emit('accepted'). Clearing termsRefusal inside the action unmounts the screen before the emit runs, so bootstrap() never fires. With the clear removed, bootstrap() → fetchRoster() clears termsRefusal on success (clientPortal.js success branch) and resets it from the error on failure (isTermsRefusal(err) ? code : null), so no path leaves a stale refusal. acceptTerms has no other caller (only PortalTerms.vue).
Execution coverage
| changed symbol / test | executed by | live consumer | verdict |
|---|---|---|---|
acceptTerms (no longer clears termsRefusal) |
portalTermsAcceptReload.mount.spec.js (mounts real Portal.vue + real PortalTerms, clicks Accept) |
PortalTerms.vue::onAccept |
✅ executed |
updated portalTerms.mount, portalTermsRefusal(.mount) specs |
themselves | same | ✅ executed (behaviour assertions, no source-text reads) |
Fix mutation (run locally): restoring the merge-base clientPortal.js turns 4 tests red, including both behaviour tests in the new spec (roster re-read + Inbox chat state). With the fix: 4 files / 34 tests pass.
Acceptance criteria (#4515)
- Roster reloads after accept, agent shown — DONE (new spec, test 2)
- No "Couldn't load your agents" / terms message after accept — DONE (test 2 asserts text +
store.error === null) - Test mounts
Portal.vuethrough accept — DONE - Light/dark check — UNVERIFIABLE from the diff; PR defers to RC row B16. No markup changed, so low risk.
Informational
- Accept is clickable again while the reload's roster read is in flight; a second click re-posts and gets
created: false. Harmless; documented in the PR.
Process / security
- Commit conventional;
Fixes #4515closing keyword present (issue: P2, type-bug). - No secrets, emails, IPs, mode changes or host paths in the diff.
- Tier 1 checks green (incl.
build,regression diff,pytest (head)). - Merge gate note:
devcurrently has an opendev-ci redissue (#4566); hold the merge untildevis green again.
Fixes #4515
Problem
A Workspace person who had not accepted the terms got the in-place terms screen, accepted, and was then shown "Couldn't load your agents — Accept the current terms to continue." and "No agents shared with you yet". The accept was recorded (200,
created: true), but no roster or chat read followed. "Try again" brought the agents back, but the Inbox kept its chat-read failure until a reload.Cause
acceptTerms()clearedtermsRefusal, the statePortal.vuemountsPortalTermsunder. The scheduler flush that ran beforePortalTerms.onAccept()resumed from itsawaitunmounted the screen, and Vue'semit()returns early for an unmounted instance, soacceptednever reachedbootstrap(). The roster's refusal message stayed inerror, and the chat reads the gate had refused kept their failure flag; "Try again" re-reads only the roster.Fix
The store no longer clears the refusal on accept. The screen stays mounted until it has emitted, the shell re-bootstraps, and the roster read clears the refusal on success (
fetchRoster), so the roster, the thread list and the chat state are all read again. No markup or styling changed.Tests
portalTermsAcceptReload.mount.spec.jsmountsPortal.vuewith the realPortalTerms, ticks the box and clicks Accept against a stub server that refuses every gated call until the accept is recorded. It asserts the roster, sessions and chat state are read after the accept, the agent is shown, no refusal or error remains, and the Inbox carries no failure. Withdev'sclientPortal.jsit fails 2 of 3 (no request after the accept); with the fix it passes.npm run test:unit(537 files, 8049 tests) andnpm run buildpass locally.dev'sclientPortal.jsback in turns the new spec red (2 of 3 fail:expected 0 to be greater than 0for the roster and sessions reads after the accept).Unverified
created: false. Left as is on purpose, because holding the button at "Accepting…" would strand it if the reload hit the terms gate again.Journey Impact
Journey Impact: none: restores the documented first sign-in (accept, then the Workspace loads); no journey promise changes