mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-05 07:07:04 +00:00
Three H5 parity pieces for the chat surface: - Conversation outline: a sheet lists the user prompts loaded in the transcript, filters them by text, and scrolls/flashes the chosen prompt through the same tokenized transcript target as pending requests. - Plan quotas: a compact 5h/7d used-percent readout in the composer strip, fed by the runner's agent-quotas RPC through a new machine endpoint client. Hidden unless the machine advertises the capability and the active agent reports an OK account; refreshes every two minutes. - PR awareness: session metadata now decodes external refs (tolerantly for unknown kinds), the list row shows the primary GitHub PR number with a forge-state tint, and the row context menu opens the PR in Safari. Adds pure tests for outline filtering/truncation, quota selection and countdown formatting, and PR badge precedence plus wire decoding. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
49 lines
2.1 KiB
Swift
49 lines
2.1 KiB
Swift
import Foundation
|
|
import HapiProtocol
|
|
import Testing
|
|
|
|
@Suite("External refs")
|
|
struct ExternalRefTests {
|
|
private func summary(metadata: String) throws -> SessionSummary {
|
|
let row = """
|
|
{"id":"s1","active":true,"thinking":false,"activeAt":0,"updatedAt":0,"metadata":\(metadata),\
|
|
"metadataVersion":1,"agentStateVersion":1,"todosUpdatedAt":0,"pendingRequestsCount":0,\
|
|
"pendingRequestKinds":[],"pendingRequests":[],"backgroundTaskCount":0,\
|
|
"futureScheduledMessageCount":0}
|
|
"""
|
|
return try JSONDecoder().decode(SessionSummary.self, from: Data(row.utf8))
|
|
}
|
|
|
|
@Test func summaryMetadataDecodesPrimaryPullRequestAndUnknownKinds() throws {
|
|
let decoded = try summary(metadata: """
|
|
{"path":"/work/hapi","host":"mac","externalRefs":[\
|
|
{"kind":"github_pr","repo":"tiann/hapi","number":1163,\
|
|
"url":"https://github.com/tiann/hapi/pull/1163","role":"primary","source":"user",\
|
|
"openState":"open","checks":"pass","merge":"clean","statusCheckedAt":1},\
|
|
{"kind":"linear_issue","id":"abc"}]}
|
|
""")
|
|
let refs = decoded.metadata?.externalRefs
|
|
#expect(refs?.count == 2)
|
|
#expect(refs?[0].repo == "tiann/hapi")
|
|
#expect(refs?[0].number == 1163)
|
|
#expect(refs?[0].checks == "pass")
|
|
#expect(refs?[1].kind == "linear_issue")
|
|
#expect(decoded.metadata?.primaryGithubPullRequest?.number == 1163)
|
|
}
|
|
|
|
@Test func summaryWithoutRefsDecodes() throws {
|
|
let decoded = try summary(metadata: #"{"path":"/work/hapi","host":"mac"}"#)
|
|
#expect(decoded.metadata?.externalRefs == nil)
|
|
#expect(decoded.metadata?.primaryGithubPullRequest == nil)
|
|
}
|
|
|
|
@Test func nonPrimaryPullRequestIsNotTheRowChip() throws {
|
|
let decoded = try summary(metadata: """
|
|
{"path":"/work/hapi","host":"mac","externalRefs":[\
|
|
{"kind":"github_pr","repo":"tiann/hapi","number":1,\
|
|
"url":"https://github.com/tiann/hapi/pull/1","role":"secondary"}]}
|
|
""")
|
|
#expect(decoded.metadata?.primaryGithubPullRequest == nil)
|
|
}
|
|
}
|