Fix fallback_admin missing workspaces after fresh login.

Wait for WS identity before emptying workspace.follow, and hard-reload after login so the first subscribe is not stuck with an anonymous empty baseline.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-08 11:27:05 +08:00
parent 3e5c1f846e
commit e479fe0833
2 changed files with 19 additions and 9 deletions

View file

@ -146,13 +146,10 @@ window.__ModuleLoader__.load({
} }
function reconnectAfterLogin() { function reconnectAfterLogin() {
try { // Soft WS reconnect often keeps a workspace.follow subscription that was
if (typeof window.__udsAuthReconnect === 'function') { // opened while anonymous (empty workspace list). Full reload makes the
window.__udsAuthReconnect() // first follow run with fallback/UDS cookies so historical workspaces show.
return try { window.location.reload() } catch { /* ignore */ }
}
} catch { /* fall through */ }
window.location.reload()
} }
function getAuthToken() { function getAuthToken() {

View file

@ -535,9 +535,22 @@ export function installDshAcl(ctx, {
const origFollow = wc.follow.bind(wc) const origFollow = wc.follow.bind(wc)
wc.follow = async function* (signal) { wc.follow = async function* (signal) {
const identity = getUserContext() let identity = getUserContext()
// Subscribe can race ahead of WS message-listener ALS bind (common right
// after fallback login / soft reconnect). Wait briefly before treating
// the stream as anonymous — otherwise every historical workspace is
// dropped and sessions collapse into 未分组.
if (!identity?.empNo) {
const deadline = Date.now() + 800
while (!identity?.empNo && Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 40))
identity = getUserContext()
}
}
// Super / fallback: passthrough — never drop historical workspaces. // Super / fallback: passthrough — never drop historical workspaces.
if (identity?.permissions?.canViewAllSessions) { if (identity?.permissions?.canViewAllSessions
|| identity?.role === 'fallback_admin'
|| identity?.role === 'super_admin') {
yield* origFollow(signal) yield* origFollow(signal)
return return
} }