Astra: PO/GL actions, usage coverage, assisted sign-in, self-healing, recorder, new top navigation and theme (172a4e22a2bf)
fb62a97 verified Download web/src/domain/waiting.ts from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/domain/waiting.ts
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/domain/waiting.ts
-
curl -L -o waiting.ts https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/domain/waiting.ts
1.76 kB
| // Who a paused test run is waiting for. A run waits at a gate (approve_cases, human_review); only the roles holding the | |
| // gate's permission may answer it (consultant: approve the scenarios; QA approver: decide the failures; admin: both). | |
| // "Waiting for you" counts only the gates the signed-in user may answer; other runs say whom they wait for. | |
| import { useCallback } from 'react'; | |
| import { useAuthOptional } from '../auth/AuthContext'; | |
| const TERMINAL = ['completed', 'failed', 'killed', 'cancelled']; | |
| export const GATE_PERM: Record<string, string> = { approve_cases: 'gate.approve_cases', sign_in: 'gate.sign_in', human_review: 'gate.human_review' }; | |
| const GATE_WHO: Record<string, string> = { approve_cases: 'a consultant', sign_in: 'someone to sign in to the pod', human_review: 'a QA approver' }; | |
| type GateRun = { status: string; pending_gate?: string | null }; | |
| /** The run is paused at a gate that someone must answer. */ | |
| export const isWaiting = (r: GateRun) => !!r.pending_gate && !TERMINAL.includes(r.status); | |
| /** The run is paused at a gate this user may answer. */ | |
| export const waitsOn = (r: GateRun, can: (perm: string) => boolean) => isWaiting(r) && can(GATE_PERM[r.pending_gate ?? ''] ?? 'admin'); | |
| /** "Waiting for a QA approver" (no trailing full stop). */ | |
| export const waitingForWords = (gate?: string | null) => `Waiting for ${GATE_WHO[gate ?? ''] ?? 'someone with another role'}`; | |
| /** A predicate for the signed-in user: does this run wait for me? */ | |
| export function useWaitsOnMe(): (r: GateRun) => boolean { | |
| const can = useAuthOptional()?.can; | |
| // outside the signed-in app (isolated previews) every waiting run counts as yours, as before | |
| return useCallback((r: GateRun) => (can ? waitsOn(r, can) : isWaiting(r)), [can]); | |
| } | |