Restore cron sidebar UX: sync mode to editor and show orphan jobs.

DOM cron mode and React overlay could desync so the right pane stayed on the workspace chat; unassigned legacy jobs were also filtered out for normal users. Re-sync mode from the sidebar attribute and adopt/show reclaimable orphans again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-09-08 16:39:21 +08:00
parent a0dc070372
commit feae559fcf
3 changed files with 68 additions and 10 deletions

View file

@ -18,7 +18,8 @@ test('jobVisibleToIdentity respects canViewAll and owner', () => {
const admin = { empNo: 'a1', permissions: { canViewAllSessions: true } }
assert.equal(jobVisibleToIdentity({ ownerEmpNo: 'u1' }, user), true)
assert.equal(jobVisibleToIdentity({ ownerEmpNo: 'u2' }, user), false)
assert.equal(jobVisibleToIdentity({ ownerEmpNo: UNASSIGNED_OWNER }, user), false)
assert.equal(jobVisibleToIdentity({ ownerEmpNo: UNASSIGNED_OWNER }, user), true)
assert.equal(jobVisibleToIdentity({ ownerEmpNo: UNASSIGNED_OWNER, cwd: '/data/user-workspaces/u2/x' }, user), false)
assert.equal(jobVisibleToIdentity({ ownerEmpNo: UNASSIGNED_OWNER }, admin), true)
assert.equal(canViewAllJobs(admin), true)
})
@ -82,14 +83,23 @@ test('claimUnassignedForViewer claims by session owner or user-workspaces cwd',
{ id: 'b', ownerEmpNo: UNASSIGNED_OWNER, cwd: '/data/user-workspaces/u1/proj' },
{ id: 'c', ownerEmpNo: UNASSIGNED_OWNER, cwd: '/data/user-workspaces/u2/proj' },
{ id: 'd', ownerEmpNo: 'u2', cwd: '/data/user-workspaces/u1/x' },
{ id: 'e', ownerEmpNo: UNASSIGNED_OWNER, origin: { kind: 'im', peer: { botId: 'b' } } },
{ id: 'f', ownerEmpNo: UNASSIGNED_OWNER, origin: { kind: 'web', sessionId: 'foreign' } },
],
}
const { changed, state: next } = claimUnassignedForViewer(state, user, {
getSessionOwner: (id) => (id === 's1' ? 'u1' : null),
getSessionOwner: (id) => {
if (id === 's1') return 'u1'
if (id === 'foreign') return 'u2'
return null
},
})
assert.equal(changed, true)
assert.equal(next.jobs[0].ownerEmpNo, 'u1')
assert.equal(next.jobs[1].ownerEmpNo, 'u1')
// Foreign user-workspaces path must not be stolen.
assert.equal(next.jobs[2].ownerEmpNo, UNASSIGNED_OWNER)
assert.equal(next.jobs[3].ownerEmpNo, 'u2')
assert.equal(next.jobs[4].ownerEmpNo, UNASSIGNED_OWNER)
assert.equal(next.jobs[5].ownerEmpNo, UNASSIGNED_OWNER)
})