Files
hapi/ios/Packages/HapiKit/Tests/HapiProtocolTests/SessionCitationTests.swift
T
14f2dd763e feat(ios): session citations, custom Claude models and chat status polish
- Copy a session citation from the list (native parity with the web
  reference text) and open the paired session list via
  hapicompanion://sessions.
- Load hub-wide custom Claude models in New Session with machine-catalog
  fallback, and show the transcript-resolved model in chat chrome.
- Render synthetic Claude API failures as error events instead of leaking
  the <synthetic> model or zero usage into the context meter.
- Refresh the session list returning from chat, request the list from Home,
  and update the home widget surfaces.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-08 20:24:30 +08:00

39 lines
1.4 KiB
Swift

import Foundation
import HapiProtocol
import Testing
@Suite("Session citation reference")
struct SessionCitationTests {
@Test func buildsTitledReferenceProse() {
let text = SessionCitation.referenceText(title: "Fix login", sessionId: "abc-123")
#expect(text == """
See session "Fix login" (/sessions/abc-123) for context. \
HAPI hub peer - call inspect_peer with that session id; \
do not Grep/Glob/Read /sessions/ as a local file.
""")
}
@Test func omitsTheTitleWhenEmpty() {
let text = SessionCitation.referenceText(title: " ", sessionId: "abc-123")
#expect(text.hasPrefix("See HAPI session /sessions/abc-123 for context."))
}
@Test func collapsesWhitespaceAndEscapesQuotes() {
let text = SessionCitation.referenceText(
title: " Fix\n\"login\" ",
sessionId: "abc-123"
)
#expect(text.contains("See session \"Fix \\\"login\\\"\" (/sessions/abc-123) for context."))
}
@Test func capsTheTitleAt120Characters() {
let title = String(repeating: "a", count: 130)
let text = SessionCitation.referenceText(title: title, sessionId: "abc-123")
#expect(text.contains("See session \"\(String(repeating: "a", count: 120))\" "))
}
@Test func encodesTheSessionIdAsOnePathSegment() {
#expect(SessionCitation.path(sessionId: "a/b c") == "/sessions/a%2Fb%20c")
}
}