mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-23 04:37:09 +00:00
feat(ios): new session flow (A-M3c)
Port of the tested Android NEW SESSION reference (B-M3d) to iOS: - HapiProtocol: NewSessionCatalogs (static claude models/efforts + codex reasoning-effort fallback, exact Android data) in Catalog/; CodexModelSummary + CodexModelsResponse wire types (shared/src/apiTypes.ts). - HapiClient: machineCodexModels endpoint (GET /api/machines/:id/codex-models, rpc_target_missing surfaces as APIError); NewSession/NewSessionForm.swift — typed Codable draft (tolerant decode) + NewSessionLogic: exact spawn body per SpawnSessionRequestSchema (yolo incl. false for non-grok/non-codex-family, permissionMode incl. 'default' for grok+codex-family, sessionType always, trimmed-or-absent worktreeName, serviceTier only while fast tier visible, collaborationMode only when plan, model only claude/codex), parent-path derivation, suggestion filtering, recent-path LRU(8), worktree-name validation, codex catalog helpers, draft sanitization. - App: Features/NewSession (NewSessionModel @Observable orchestration — machine preselect last-used, 250 ms debounced list-directory autocomplete with per-parent cache, exists probe with worktree-blocking / simple two-tap-create, codex catalog fetch + selection reconcile, UserDefaults draft/prefs per hub; NewSessionView Form UI with per-flavor option matrix); session-list "+" toolbar button on HomeView presents the sheet, success dismisses and pushes the chat. - Tests: spawn-body exactness (4 configs, canonical JSON), parent query, suggestions, LRU, worktree validation, fast-tier detection, reasoning-effort normalization, draft sanitize + tolerant decode; codex-models endpoint request/error construction.
This commit is contained in:
@@ -387,6 +387,57 @@ public struct MachinePathsExistsResponse: Codable, Equatable, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Codex model catalog
|
||||
|
||||
/// One row of `GET /api/machines/:id/codex-models` (also the session-level
|
||||
/// twin). Mirrors `CodexModelSummary` (`shared/src/apiTypes.ts`).
|
||||
public struct CodexModelSummary: Codable, Equatable, Sendable {
|
||||
public var id: String
|
||||
public var displayName: String
|
||||
public var isDefault: Bool
|
||||
public var defaultReasoningEffort: String?
|
||||
public var defaultServiceTier: String?
|
||||
public var supportedReasoningEfforts: [String]?
|
||||
/// Service tier ids advertised for this model in the current auth/plan
|
||||
/// context (e.g. `fast`).
|
||||
public var serviceTiers: [String]?
|
||||
|
||||
public init(
|
||||
id: String,
|
||||
displayName: String,
|
||||
isDefault: Bool,
|
||||
defaultReasoningEffort: String? = nil,
|
||||
defaultServiceTier: String? = nil,
|
||||
supportedReasoningEfforts: [String]? = nil,
|
||||
serviceTiers: [String]? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.displayName = displayName
|
||||
self.isDefault = isDefault
|
||||
self.defaultReasoningEffort = defaultReasoningEffort
|
||||
self.defaultServiceTier = defaultServiceTier
|
||||
self.supportedReasoningEfforts = supportedReasoningEfforts
|
||||
self.serviceTiers = serviceTiers
|
||||
}
|
||||
}
|
||||
|
||||
/// Body of `GET /api/machines/:id/codex-models` (RPC envelope — check
|
||||
/// `success`). A runner that does not expose the machine-scoped RPC answers
|
||||
/// HTTP 503 `{success:false, code:'rpc_target_missing'}`, which surfaces as
|
||||
/// the transport error, not this body. Added in A-M3c for the new-session
|
||||
/// codex model picker; mirrors `CodexModelsResponse` (`shared/src/apiTypes.ts`).
|
||||
public struct CodexModelsResponse: Codable, Equatable, Sendable {
|
||||
public var success: Bool
|
||||
public var models: [CodexModelSummary]?
|
||||
public var error: String?
|
||||
|
||||
public init(success: Bool, models: [CodexModelSummary]? = nil, error: String? = nil) {
|
||||
self.success = success
|
||||
self.models = models
|
||||
self.error = error
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Uploads
|
||||
|
||||
/// Body of `POST /api/sessions/:id/upload` (RPC envelope). `path` feeds the
|
||||
|
||||
Reference in New Issue
Block a user