MCPcopy Index your code
hub / github.com/InverseUI/InverseUI-Recorder / toggleRec

Function toggleRec

modules/recording.js:227–281  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

225 * Toggle recording on/off
226 */
227export async function toggleRec() {
228 if (recState) {
229 // Stop recording directly without checking success conditions
230 chrome.action.setBadgeText({ text: "" });
231 console.log("Stop recording");
232
233
234 // Only send to backend if not in action only mode and we have actions
235 if (!actionOnlyMode && actions.length > 0) {
236 processAndSendTrack(actions, initialState).catch(error => {
237 console.error('Failed to process and send track:', error);
238 });
239 } else {
240 console.log("Action only mode enabled - skipping backend submission");
241 }
242
243 console.log("🔄 Resetting recording state variables");
244 dimension_w = "";
245 dimension_h = "";
246 scroll_top = "";
247 scroll_left = "";
248 initialState = null;
249 recState = false;
250
251 // Broadcast recording stopped
252 const tabs = await chrome.tabs.query({});
253 tabs.forEach(tab => {
254 chrome.tabs.sendMessage(tab.id, {
255 type: 'RECORDING_STATE_CHANGED',
256 recording: recState
257 }).catch(() => {});
258 });
259
260 // Show notification
261 const message = actionOnlyMode ?
262 'Recording stopped. Action only mode - no backend submission or code generation.' :
263 actions.length > 0 ? 'Recording stopped and test code is being generated.' : 'Recording stopped (no actions recorded).';
264 chrome.notifications.create({
265 type: 'basic',
266 iconUrl: chrome.runtime.getURL('icons/icon-48.png'),
267 title: 'Recording Stopped',
268 message: message,
269 priority: 2
270 });
271
272 // Update context menu
273 chrome.contextMenus.update("recStateToggle", {
274 title: "Start Recording"
275 }).catch(() => {});
276
277 } else {
278 // Start recording with fresh session
279 startFreshRecording();
280 }
281}
282
283/**
284 * Add an action to the recording

Callers 1

background.jsFile · 0.90

Calls 2

processAndSendTrackFunction · 0.85
startFreshRecordingFunction · 0.85

Tested by

no test coverage detected