| 138 | } |
| 139 | |
| 140 | func (f *fakeDesktop) StartRecording(_ context.Context, recordingID string) error { |
| 141 | f.recMu.Lock() |
| 142 | defer f.recMu.Unlock() |
| 143 | if f.recordings == nil { |
| 144 | f.recordings = make(map[string]string) |
| 145 | } |
| 146 | if path, ok := f.recordings[recordingID]; ok { |
| 147 | // Check if already stopped (file still exists but stop was |
| 148 | // called). For the fake, a stopped recording means its ID |
| 149 | // appears in stopCalls. In that case, remove the old file |
| 150 | // and start fresh. |
| 151 | stopped := slices.Contains(f.stopCalls, recordingID) |
| 152 | if !stopped { |
| 153 | // Active recording - no-op. |
| 154 | return nil |
| 155 | } |
| 156 | // Completed recording - discard old file, start fresh. |
| 157 | _ = os.Remove(path) |
| 158 | delete(f.recordings, recordingID) |
| 159 | } |
| 160 | f.startCount++ |
| 161 | tmpFile, err := os.CreateTemp("", "fake-recording-*.mp4") |
| 162 | if err != nil { |
| 163 | return err |
| 164 | } |
| 165 | _, _ = tmpFile.Write([]byte(fmt.Sprintf("fake-mp4-data-%s-%d", recordingID, f.startCount))) |
| 166 | _ = tmpFile.Close() |
| 167 | f.recordings[recordingID] = tmpFile.Name() |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (f *fakeDesktop) StopRecording(_ context.Context, recordingID string) (*agentdesktop.RecordingArtifact, error) { |
| 172 | f.recMu.Lock() |