Fix cron cwd for super_admin and harden IM channel job isolation.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-10 10:00:59 +08:00
parent b35bfde557
commit b1bb0067a0
16 changed files with 714 additions and 49 deletions

View file

@ -139,6 +139,18 @@ export function viewerPayload(identity) {
}
}
/**
* Default cwd when creating a job in the sidebar.
* Prefer the viewer's provisioned workspace over whatever project the session
* happens to have open (admins often sit in an unrelated clone).
*/
export function preferredNewJobCwd({ viewer = null, sessionCwd = '' } = {}) {
const provisioned = String(viewer?.workspacePath || '').trim()
if (viewer?.mode === 'multi' && provisioned) return provisioned
if (provisioned) return provisioned
return String(sessionCwd || '').trim()
}
/**
* Claim unassigned jobs that clearly belong to the viewer (origin session / cwd).
* No-op in standalone / canViewAll. Returns { state, changed }.