( state: AttributionState, messageId: UUID, )
| 870 | * Convert attribution state to snapshot message for persistence. |
| 871 | */ |
| 872 | export function stateToSnapshotMessage( |
| 873 | state: AttributionState, |
| 874 | messageId: UUID, |
| 875 | ): AttributionSnapshotMessage { |
| 876 | const fileStates: Record<string, FileAttributionState> = {} |
| 877 | |
| 878 | for (const [path, fileState] of state.fileStates) { |
| 879 | fileStates[path] = fileState |
| 880 | } |
| 881 | |
| 882 | return { |
| 883 | type: 'attribution-snapshot', |
| 884 | messageId, |
| 885 | surface: state.surface, |
| 886 | fileStates, |
| 887 | promptCount: state.promptCount, |
| 888 | promptCountAtLastCommit: state.promptCountAtLastCommit, |
| 889 | permissionPromptCount: state.permissionPromptCount, |
| 890 | permissionPromptCountAtLastCommit: state.permissionPromptCountAtLastCommit, |
| 891 | escapeCount: state.escapeCount, |
| 892 | escapeCountAtLastCommit: state.escapeCountAtLastCommit, |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | /** |
| 897 | * Restore attribution state from snapshot messages. |
no outgoing calls
no test coverage detected