mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-10 05:53:24 +08:00
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:
parent
a0dc070372
commit
feae559fcf
3 changed files with 68 additions and 10 deletions
|
|
@ -13,11 +13,24 @@ export function canViewAllJobs(identity) {
|
|||
return !!identity?.permissions?.canViewAllSessions
|
||||
}
|
||||
|
||||
function empNoFromUserWorkspacePath(cwd) {
|
||||
const norm = String(cwd || '').replace(/\\/g, '/')
|
||||
const match = norm.match(/\/user-workspaces\/([^/]+)(?:\/|$)/)
|
||||
return match ? decodeURIComponent(match[1]) : null
|
||||
}
|
||||
|
||||
export function jobVisibleToIdentity(job, identity) {
|
||||
if (!identity?.empNo) return false
|
||||
if (canViewAllJobs(identity)) return true
|
||||
const owner = normalizeOwnerEmpNo(job?.ownerEmpNo)
|
||||
if (owner === UNASSIGNED_OWNER) return false
|
||||
// Legacy / tool-created rows often lack ownerEmpNo. Keep them visible so the
|
||||
// sidebar is not empty, then claimUnassignedForViewer can adopt them — unless
|
||||
// the cwd clearly belongs to another user.
|
||||
if (owner === UNASSIGNED_OWNER) {
|
||||
const pathOwner = empNoFromUserWorkspacePath(job?.cwd)
|
||||
if (pathOwner && pathOwner !== String(identity.empNo)) return false
|
||||
return true
|
||||
}
|
||||
return owner === String(identity.empNo)
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +140,23 @@ export function claimUnassignedForViewer(state, identity, deps = {}) {
|
|||
? job.origin.sessionId.trim()
|
||||
: ''
|
||||
let mine = false
|
||||
// Prefer explicit session ownership / user-workspaces path — do not trust a loose isUserPath.
|
||||
// Prefer session ownership / user-workspaces cwd. Adopt web/legacy orphans when
|
||||
// no other owner is known so chat-created jobs reappear in the sidebar.
|
||||
if (sessionId && typeof deps.getSessionOwner === 'function') {
|
||||
mine = deps.getSessionOwner(sessionId) === identity.empNo
|
||||
const sessionOwner = deps.getSessionOwner(sessionId)
|
||||
if (sessionOwner && sessionOwner !== identity.empNo) return job
|
||||
mine = !sessionOwner || sessionOwner === identity.empNo
|
||||
}
|
||||
if (!mine && job.cwd) {
|
||||
const norm = String(job.cwd).replace(/\\/g, '/')
|
||||
const match = norm.match(/\/user-workspaces\/([^/]+)(?:\/|$)/)
|
||||
mine = !!(match && decodeURIComponent(match[1]) === identity.empNo)
|
||||
if (match) {
|
||||
if (decodeURIComponent(match[1]) === identity.empNo) mine = true
|
||||
else return job
|
||||
}
|
||||
}
|
||||
if (!mine && job.origin?.kind !== 'im') {
|
||||
mine = true
|
||||
}
|
||||
if (!mine) return job
|
||||
changed = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue