Skip to content

fix(workspace): reload the Workspace after the terms are accepted (#4515) - #4561

Merged
AndriiPasternak31 merged 1 commit into
devfrom
fix/4515-terms-accept-reload
Nov 13, 2026
Merged

AndriiPasternak31 merged 1 commit into
devfrom
fix/4515-terms-accept-reload

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

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() 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 accepted never reached bootstrap(). The roster's refusal message stayed in error, 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

  • New portalTermsAcceptReload.mount.spec.js mounts Portal.vue with the real PortalTerms, 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. With dev's clientPortal.js it fails 2 of 3 (no request after the accept); with the fix it passes.
  • Three existing specs asserted the clear itself; they now assert the screen emits while still mounted and the roster reload ends the refusal.
  • Validation: npm run test:unit (537 files, 8049 tests) and npm run build pass locally.
  • Mutation: swapping dev's clientPortal.js back in turns the new spec red (2 of 3 fail: expected 0 to be greater than 0 for the roster and sessions reads after the accept).

Unverified

  • Not exercised in a live browser yet. It will be re-tested on the next RC as part of release-test row B16 (Abilityai/trinity-enterprise#1189).
  • While the reload's roster request is in flight, Accept is clickable again; a second click sends another accept, which the server answers 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

)

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.
@AndriiPasternak31
AndriiPasternak31 marked this pull request as ready for review November 13, 2026 20:33
@AndriiPasternak31 AndriiPasternak31 self-assigned this Nov 13, 2026

@obasilakis obasilakis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/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.vue through 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 #4515 closing 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: dev currently has an open dev-ci red issue (#4566); hold the merge until dev is green again.

@AndriiPasternak31
AndriiPasternak31 merged commit 000d191 into dev Nov 13, 2026
24 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