( state: AttributionState, messageId: UUID, )
| 811 | * Convert attribution state to snapshot message for persistence. |
| 812 | */ |
| 813 | export function stateToSnapshotMessage( |
| 814 | state: AttributionState, |
| 815 | messageId: UUID, |
| 816 | ): AttributionSnapshotMessage { |
| 817 | const fileStates: Record<string, FileAttributionState> = {} |
| 818 | |
| 819 | for (const [path, fileState] of state.fileStates) { |
| 820 | fileStates[path] = fileState |
| 821 | } |
| 822 | |
| 823 | return { |
| 824 | type: 'attribution-snapshot', |
| 825 | messageId, |
| 826 | surface: state.surface, |
| 827 | fileStates, |
| 828 | promptCount: state.promptCount, |
| 829 | promptCountAtLastCommit: state.promptCountAtLastCommit, |
| 830 | permissionPromptCount: state.permissionPromptCount, |
| 831 | permissionPromptCountAtLastCommit: state.permissionPromptCountAtLastCommit, |
| 832 | escapeCount: state.escapeCount, |
| 833 | escapeCountAtLastCommit: state.escapeCountAtLastCommit, |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * Restore attribution state from snapshot messages. |
no outgoing calls
no test coverage detected