mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 03:03:18 +08:00
Stamp and reclaim chat-created cron jobs for the current user.
Tool creates often left ownerEmpNo unassigned so the sidebar hid them while runs still fired; infer identity from session/cwd, claim legacy orphans on list, and keep cron rows visible without leaking run sessions into the workspace list. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d298c77f3f
commit
a0dc070372
7 changed files with 254 additions and 25 deletions
|
|
@ -3,6 +3,7 @@ import { test } from 'node:test'
|
|||
import {
|
||||
assertCanAccessJob,
|
||||
canViewAllJobs,
|
||||
claimUnassignedForViewer,
|
||||
filterJobsForIdentity,
|
||||
filterRunsForJobs,
|
||||
inferOwnerEmpNo,
|
||||
|
|
@ -72,3 +73,23 @@ test('viewerPayload', () => {
|
|||
assert.equal(v.canViewAll, false)
|
||||
assert.equal(v.workspacePath, '/w/u1')
|
||||
})
|
||||
|
||||
test('claimUnassignedForViewer claims by session owner or user-workspaces cwd', () => {
|
||||
const user = { empNo: 'u1', displayName: 'U1', permissions: { canViewAllSessions: false } }
|
||||
const state = {
|
||||
jobs: [
|
||||
{ id: 'a', ownerEmpNo: UNASSIGNED_OWNER, origin: { kind: 'web', sessionId: 's1' }, cwd: '/tmp/other' },
|
||||
{ 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' },
|
||||
],
|
||||
}
|
||||
const { changed, state: next } = claimUnassignedForViewer(state, user, {
|
||||
getSessionOwner: (id) => (id === 's1' ? 'u1' : null),
|
||||
})
|
||||
assert.equal(changed, true)
|
||||
assert.equal(next.jobs[0].ownerEmpNo, 'u1')
|
||||
assert.equal(next.jobs[1].ownerEmpNo, 'u1')
|
||||
assert.equal(next.jobs[2].ownerEmpNo, UNASSIGNED_OWNER)
|
||||
assert.equal(next.jobs[3].ownerEmpNo, 'u2')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue