Files
hapi/ios/Hapi/Features/Home/SessionNavigationState.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

41 lines
1.3 KiB
Swift

import Observation
import SwiftUI
/// In-memory navigation for one hub's iPad workspace. Window geometry never
/// owns selection: filtering, collapsing and reopening the sidebar must not
/// discard the selected chat or its nested file/process navigation.
@MainActor @Observable
final class SessionNavigationState {
private(set) var selectedSessionId: String?
var detailPath = NavigationPath()
var columnVisibility: NavigationSplitViewVisibility = .all
var preferredCompactColumn: NavigationSplitViewColumn = .sidebar
func open(_ sessionId: String) {
if selectedSessionId != sessionId {
detailPath = NavigationPath()
selectedSessionId = sessionId
}
// Also works for notifications/new sessions not yet in the list.
preferredCompactColumn = .detail
}
func showList() {
detailPath = NavigationPath()
selectedSessionId = nil
preferredCompactColumn = .sidebar
}
func supersede(_ sessionId: String, with replacement: String) {
guard selectedSessionId == sessionId else { return }
open(replacement)
}
func remove(_ sessionId: String) {
guard selectedSessionId == sessionId else { return }
detailPath = NavigationPath()
selectedSessionId = nil
preferredCompactColumn = .sidebar
}
}