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

Function startFreshRecording

modules/recording.js:162–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160 * Start a fresh recording session
161 */
162export async function startFreshRecording() {
163 // Check authentication status first
164 const authStatus = await checkAuth();
165
166 if (!authStatus.isAuthenticated) {
167 // Show notification that login is required
168 chrome.notifications.create({
169 type: 'basic',
170 iconUrl: chrome.runtime.getURL('icons/icon-48.png'),
171 title: 'Login Required',
172 message: 'Please log in to InverseUI to start recording.',
173 priority: 2
174 });
175
176 // Open login page
177 await openLoginPage();
178
179 // Don't set pendingRecording flag - let user manually start recording after login
180 return;
181 }
182
183 // Get current tab
184 const [currentTab] = await chrome.tabs.query({active: true, currentWindow: true});
185 if (!currentTab) return;
186
187 // Start recording immediately
188 actions.length = 0; // Clear actions array
189 console.log("Start recording...");
190 recState = true;
191 chrome.action.setBadgeText({ text: "rec" });
192
193 // Capture initial webpage state and create baseline actions
194 try {
195 initialState = await captureInitialState(currentTab.id);
196 createInitialActions(initialState, currentTab);
197 } catch (error) {
198 console.error('Failed to capture initial state:', error);
199 // Continue recording even if initial state capture fails
200 initialState = null;
201 }
202
203 // Broadcast state to all tabs
204 const tabs = await chrome.tabs.query({});
205 tabs.forEach(tab => {
206 chrome.tabs.sendMessage(tab.id, {
207 type: 'RECORDING_STATE_CHANGED',
208 recording: recState
209 }).catch(() => {});
210 });
211
212 // Show notification with instructions
213 chrome.notifications.create({
214 type: 'basic',
215 iconUrl: chrome.runtime.getURL('icons/icon-48.png'),
216 title: 'Recording Started',
217 message: 'For best results, please log out first to record the complete login flow. This ensures your test will work in Selenium.',
218 priority: 2,
219 requireInteraction: true

Callers 1

toggleRecFunction · 0.85

Calls 4

checkAuthFunction · 0.90
openLoginPageFunction · 0.90
captureInitialStateFunction · 0.85
createInitialActionsFunction · 0.85

Tested by

no test coverage detected