mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 11:40:48 +08:00
Speed up uds-auth login: paint badge first, lazy /api/me.
Skip startup /api/me until QR load, stop blocking me on workspace provision, and register the footer login entry before heavy ACL gates so login appears immediately. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1c461285fc
commit
81ff8eb19f
4 changed files with 104 additions and 134 deletions
|
|
@ -724,7 +724,14 @@ function handleRequest(req, res) {
|
|||
// 基础端点
|
||||
if (url === '/api/me' && method === 'GET') {
|
||||
if (ctx2.empNo) {
|
||||
try { ctx2.provisionedWorkspace = await ensureUserWorkspace(ctx2.empNo) } catch { ctx2.provisionedWorkspace = null }
|
||||
// Never block login badge / ACL on workspaceRegistry (can wait up to 30s).
|
||||
// Serve cached mapping immediately; provision in background.
|
||||
try {
|
||||
ctx2.provisionedWorkspace = _userWorkspaces?.get?.(ctx2.empNo) || null
|
||||
} catch {
|
||||
ctx2.provisionedWorkspace = null
|
||||
}
|
||||
void ensureUserWorkspace(ctx2.empNo).catch(() => {})
|
||||
}
|
||||
await _apiHandlers.getCurrentUser(ctx2); return
|
||||
}
|
||||
|
|
@ -788,7 +795,7 @@ function notifyWorkspaceRegistryReady(registry) {
|
|||
}
|
||||
|
||||
/** Wait until workspaceRegistry inject fires (or timeout). */
|
||||
function whenWorkspaceRegistry(timeoutMs = 30000) {
|
||||
function whenWorkspaceRegistry(timeoutMs = 2500) {
|
||||
if (_workspaceRegistry) return Promise.resolve(_workspaceRegistry)
|
||||
return new Promise((resolve) => {
|
||||
const entry = {
|
||||
|
|
@ -808,7 +815,7 @@ async function ensureUserWorkspace(empNo) {
|
|||
try {
|
||||
let registry = _workspaceRegistry
|
||||
if (!registry) {
|
||||
registry = await whenWorkspaceRegistry(30000)
|
||||
registry = await whenWorkspaceRegistry(2500)
|
||||
}
|
||||
const root = _currentConfig?.workspaceRoot
|
||||
if (!registry) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue