Show who created each schedule and start with your own

Org admins see every Express schedule in the organization, so a shared
organization mixed everyone's schedules together. The Schedule page now
shows "Created by …" on each one and, when others' schedules are listed,
switches between Mine and Everyone in the organization.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Iqbal
2026-10-29 12:18:28 +07:00
parent bdae539e9e
commit bcd747721d
6 changed files with 96 additions and 7 deletions

View File

@@ -41,6 +41,7 @@ export interface ExpressAgent extends Agent {
run_budget: number
monthly_budget: number
created_at: string
created_by_user_id: number | null
}
export interface Schedule {
@@ -107,6 +108,23 @@ export async function expressAgents({ archived = false } = {}): Promise<Schedule
export const listSchedules = () => expressAgents()
// An organization admin sees every schedule in the organization, a member only their own (and any
// shared with them), so the Schedule page says who made each one and starts with the viewer's own.
export interface Owners { me: number; names: Map<number, string> }
/** The viewer's engine user id and the organization roster's names. The roster is admin-only;
* a member gets no names, which is fine: a member's list holds their own schedules. */
export async function scheduleOwners(): Promise<Owners> {
const [me, roster] = await Promise.all([
request<{ id: number }>('/auth/me'),
request<{ members: { user_id: number; name: string | null; email: string | null }[] }>('/organizations/current/dashboard/members')
.catch(() => ({ members: [] })),
])
return { me: me.id, names: new Map(roster.members.map(m => [m.user_id, m.name || m.email || `#${m.user_id}`])) }
}
export const isMine = (s: Schedule, owners: Owners) => s.agent.created_by_user_id === owners.me
/** Schedules made of one engine run per slot (research, video), rather than weekly production plans. */
export const isRunSchedule = (rule: Rule) => rule.type === 'research' || rule.kind === 'video'