native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Consolidate reducer logging into LogActionsReducer

- DEBUG: prints action label and state diff
- Release: logs action label to Sentry breadcrumbs

khoi 6bbaf7e6 e0857047

+21 -15
+1 -9
supacode/App/supacodeApp.swift
··· 66 66 initialState: AppFeature.State(settings: SettingsFeature.State(settings: initialSettings)) 67 67 ) { 68 68 AppFeature() 69 - .logActions { action in 70 - #if DEBUG 71 - print("Action: \(action)") 72 - #else 73 - let breadcrumb = Breadcrumb(level: .debug, category: "action") 74 - breadcrumb.message = action 75 - SentrySDK.addBreadcrumb(breadcrumb) 76 - #endif 77 - } 69 + .logActions() 78 70 } withDependencies: { values in 79 71 values.terminalClient = TerminalClient( 80 72 send: { command in
+20 -6
supacode/Support/DebugCaseOutput.swift
··· 1 1 import Foundation 2 2 import ComposableArchitecture 3 + import CustomDump 4 + import Sentry 3 5 4 - extension Reducer { 6 + extension Reducer where State: Equatable { 5 7 @ReducerBuilder<State, Action> 6 - func logActions(_ log: @escaping (String) -> Void) -> some Reducer<State, Action> { 7 - LogActionsReducer(base: self, log: log) 8 + func logActions() -> some Reducer<State, Action> { 9 + LogActionsReducer(base: self) 8 10 } 9 11 } 10 12 11 - struct LogActionsReducer<Base: Reducer>: Reducer { 13 + struct LogActionsReducer<Base: Reducer>: Reducer where Base.State: Equatable { 12 14 let base: Base 13 - let log: (String) -> Void 14 15 15 16 func reduce(into state: inout Base.State, action: Base.Action) -> Effect<Base.Action> { 16 - log(debugCaseOutput(action)) 17 + let actionLabel = debugCaseOutput(action) 18 + #if DEBUG 19 + let previousState = state 20 + let effects = base.reduce(into: &state, action: action) 21 + print("Action: \(actionLabel)") 22 + if previousState != state, let diff = CustomDump.diff(previousState, state) { 23 + print(diff) 24 + } 25 + return effects 26 + #else 27 + let breadcrumb = Breadcrumb(level: .debug, category: "action") 28 + breadcrumb.message = actionLabel 29 + SentrySDK.addBreadcrumb(breadcrumb) 17 30 return base.reduce(into: &state, action: action) 31 + #endif 18 32 } 19 33 } 20 34