native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import Foundationimport Testing
@testable import Prowl
struct AgentScreenDetectionTests { @Test func unmigratedDetectorsReturnTheirExistingStateWithAStableReason() { let screen = "screen without a live rule"
for agent in DetectedAgent.allCases where agent != .codex && agent != .claude && agent != .devin { let detection = agent.detectScreen(in: screen)
#expect(detection.state == agent.detectState(in: screen)) #expect(detection.reason == .legacyDetector) #expect(detection.reason.identifier == "legacy.detector") } }
@Test(arguments: [DetectedAgent.claude, .codex, .devin]) func typedDetectorsReturnAnExplicitFallbackWhenNoRuleMatches(agent: DetectedAgent) { let screen = "screen without a live rule" let detection = agent.detectScreen(in: screen)
#expect(detection.state == agent.detectState(in: screen)) #expect(detection.reason == .noRuleMatched) #expect(detection.reason.identifier == "fallback.noRuleMatched") }
@Test func transitionDiagnosticsIncludeTheStableReasonWithoutScreenText() { let diagnostic = AgentDetectionDiagnostic( tabId: TerminalTabID(rawValue: UUID()), childPID: nil, processGroupID: nil, job: nil, identified: nil, retainedAgent: .codex, raw: .blocked, reason: .matched(AgentScreenRuleID("codex.directoryTrust")), stabilized: .blocked )
#expect(diagnostic.summary.contains("reason=codex.directoryTrust")) #expect(!diagnostic.summary.contains("screen=")) }
@Test func reasonIdentifiersDistinguishMatchesAndFallbacks() { let ruleID = AgentScreenRuleID("codex.directoryTrust")
#expect(AgentScreenDetectionReason.matched(ruleID).identifier == "codex.directoryTrust") #expect(AgentScreenDetectionReason.noRuleMatched.identifier == "fallback.noRuleMatched") }}