Skip to content

Commit 60a2a48

Browse files
author
Ivo Bellin Salarin
committed
fix: display transcription-only recaps
1 parent 6f85bcf commit 60a2a48

File tree

5 files changed

+58
-19
lines changed

5 files changed

+58
-19
lines changed

Recap.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Recap/DependencyContainer/DependencyContainer.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ final class DependencyContainer {
8585
func createSummaryViewModel() -> SummaryViewModel {
8686
SummaryViewModel(
8787
recordingRepository: recordingRepository,
88-
processingCoordinator: processingCoordinator
88+
processingCoordinator: processingCoordinator,
89+
userPreferencesRepository: userPreferencesRepository
8990
)
9091
}
9192
}

Recap/UseCases/Summary/SummaryView.swift

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct SummaryView<ViewModel: SummaryViewModelType>: View {
3333
noRecordingView
3434
} else if viewModel.isProcessing {
3535
processingView(geometry: geometry)
36-
} else if viewModel.hasSummary {
36+
} else if viewModel.isRecordingReady {
3737
summaryView
3838
} else {
3939
errorView(viewModel.currentRecording?.errorMessage ?? "Recording is in an unexpected state")
@@ -147,22 +147,21 @@ struct SummaryView<ViewModel: SummaryViewModelType>: View {
147147
VStack(spacing: 0) {
148148
ScrollView {
149149
VStack(alignment: .leading, spacing: UIConstants.Spacing.cardSpacing) {
150-
if let recording = viewModel.currentRecording,
151-
let summaryText = recording.summaryText,
152-
let transcriptionText = recording.transcriptionText {
153-
150+
if let recording = viewModel.currentRecording {
151+
154152
VStack(alignment: .leading, spacing: UIConstants.Spacing.cardInternalSpacing) {
155-
if !transcriptionText.isEmpty {
153+
if let transcriptionText = recording.transcriptionText, !transcriptionText.isEmpty {
156154
TranscriptDropdownButton(
157155
transcriptText: transcriptionText
158156
)
159157
}
160-
161-
Text("Summary")
162-
.font(UIConstants.Typography.infoCardTitle)
163-
.foregroundColor(UIConstants.Colors.textPrimary)
164-
165-
Markdown(summaryText)
158+
159+
if let summaryText = recording.summaryText, !summaryText.isEmpty {
160+
Text("Summary")
161+
.font(UIConstants.Typography.infoCardTitle)
162+
.foregroundColor(UIConstants.Colors.textPrimary)
163+
164+
Markdown(summaryText)
166165
.markdownTheme(.docC)
167166
.markdownTextStyle {
168167
ForegroundColor(UIConstants.Colors.textSecondary)
@@ -202,6 +201,14 @@ struct SummaryView<ViewModel: SummaryViewModelType>: View {
202201
}
203202
}
204203
.textSelection(.enabled)
204+
}
205+
206+
if recording.summaryText == nil && recording.transcriptionText == nil {
207+
Text("Recording completed without transcription or summary")
208+
.font(UIConstants.Typography.bodyText)
209+
.foregroundColor(UIConstants.Colors.textSecondary)
210+
.padding(.vertical, 20)
211+
}
205212
}
206213
.padding(.horizontal, UIConstants.Spacing.contentPadding)
207214
.padding(.vertical, UIConstants.Spacing.cardSpacing)

Recap/UseCases/Summary/ViewModel/SummaryViewModel.swift

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,41 @@ final class SummaryViewModel: SummaryViewModelType {
77
@Published private(set) var isLoadingRecording = false
88
@Published private(set) var errorMessage: String?
99
@Published var showingCopiedToast = false
10-
10+
@Published private(set) var userPreferences: UserPreferencesInfo?
11+
1112
private let recordingRepository: RecordingRepositoryType
1213
private let processingCoordinator: ProcessingCoordinatorType
14+
private let userPreferencesRepository: UserPreferencesRepositoryType
1315
private var cancellables = Set<AnyCancellable>()
1416
private var refreshTimer: Timer?
15-
17+
1618
init(
1719
recordingRepository: RecordingRepositoryType,
18-
processingCoordinator: ProcessingCoordinatorType
20+
processingCoordinator: ProcessingCoordinatorType,
21+
userPreferencesRepository: UserPreferencesRepositoryType
1922
) {
2023
self.recordingRepository = recordingRepository
2124
self.processingCoordinator = processingCoordinator
25+
self.userPreferencesRepository = userPreferencesRepository
26+
27+
Task {
28+
await loadUserPreferences()
29+
}
2230
}
2331

32+
func loadUserPreferences() async {
33+
do {
34+
userPreferences = try await userPreferencesRepository.getOrCreatePreferences()
35+
} catch {
36+
// If we can't load preferences, assume defaults (auto-summarize enabled)
37+
userPreferences = nil
38+
}
39+
}
40+
2441
func loadRecording(withID recordingID: String) {
2542
isLoadingRecording = true
2643
errorMessage = nil
27-
44+
2845
Task {
2946
do {
3047
let recording = try await recordingRepository.fetchRecording(id: recordingID)
@@ -75,6 +92,19 @@ final class SummaryViewModel: SummaryViewModelType {
7592
guard let recording = currentRecording else { return false }
7693
return recording.state == .completed && recording.summaryText != nil
7794
}
95+
96+
var isRecordingReady: Bool {
97+
guard let recording = currentRecording else { return false }
98+
guard recording.state == .completed else { return false }
99+
100+
// If auto-summarize is enabled, we need summary text
101+
if userPreferences?.autoSummarizeEnabled == true {
102+
return recording.summaryText != nil
103+
}
104+
105+
// If auto-summarize is disabled, the recording is valid when completed
106+
return true
107+
}
78108

79109
func retryProcessing() async {
80110
guard let recording = currentRecording else { return }

Recap/UseCases/Summary/ViewModel/SummaryViewModelType.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ protocol SummaryViewModelType: ObservableObject {
88
var processingStage: ProcessingStatesCard.ProcessingStage? { get }
99
var isProcessing: Bool { get }
1010
var hasSummary: Bool { get }
11+
var isRecordingReady: Bool { get }
1112
var showingCopiedToast: Bool { get }
12-
13+
1314
func loadRecording(withID recordingID: String)
1415
func loadLatestRecording()
1516
func retryProcessing() async

0 commit comments

Comments
 (0)