fix: remove background image task, simplify post-auth to wait for redirects to settle

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ValueOn AG 2026-02-16 15:14:35 +01:00
parent b8402311cd
commit 6dea7e3e10

View file

@ -216,33 +216,20 @@ export class BotOrchestrator {
if (authSuccess) {
this._logger.info('Authentication via "Sign in" link succeeded');
// After the hybrid login flow (email on Teams modal, password on MS login),
// Teams redirects to /v2/ with the authenticated pre-join page.
// We must wait for the URL to contain "/v2/" — the light-meetings page
// also has a "Join now" button but that's the anonymous version!
this._logger.info('Waiting for redirect to authenticated /v2/ pre-join page...');
// After the hybrid login flow, Teams goes through a redirect chain.
// It may briefly visit /v2/ then land back on light-meetings (now authenticated).
// We just need to wait for the redirects to settle and for the page to stabilize.
// The Join button (#prejoin-join-button) will appear once the page is ready.
this._logger.info('Auth complete. Waiting for redirects to settle and Join button to appear...');
try {
await this._page!.waitForURL('**/v2/**', { timeout: 60000 });
const v2Url = this._page!.url();
this._logger.info(`Arrived at /v2/ page: ${v2Url.substring(0, 100)}`);
} catch {
const currentUrl = this._page!.url();
this._logger.warn(`Did not reach /v2/ page within 60s. URL: ${currentUrl.substring(0, 100)}`);
}
// Wait for the redirect chain to finish (URL stops changing)
await this._page!.waitForTimeout(5000);
// Now wait for the Join button on the authenticated /v2/ pre-join page
const joinButtonSelector = '#prejoin-join-button, button[data-tid="prejoin-join-button"]';
try {
await this._page!.waitForSelector(joinButtonSelector, { timeout: 30000, state: 'visible' });
const finalUrl = this._page!.url();
this._logger.info(`On authenticated pre-join page with Join button: ${finalUrl.substring(0, 100)}`);
} catch {
const finalUrl = this._page!.url();
const pageContent = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 300) || '');
this._logger.warn(`Join button not found. URL: ${finalUrl.substring(0, 100)}`);
this._logger.warn(`Page content: ${pageContent.substring(0, 200)}`);
}
const settledUrl = this._page!.url();
this._logger.info(`Post-auth settled URL: ${settledUrl.substring(0, 100)}`);
// The authenticated join flow will be handled by joinMeetingLobbyFlow() below,
// which will find the "Join now" button and click it.
} else {
this._logger.warn('Authentication via "Sign in" failed - continuing as anonymous');
}
@ -251,18 +238,8 @@ export class BotOrchestrator {
}
}
// Set virtual background if configured (only for anonymous joins on light-meetings pre-join)
// For authenticated joins, background is set after reaching the /v2/ pre-join page
// (the auth flow redirects through multiple pages, so background setup would interfere)
if (this._options.backgroundImageUrl && this._page && !authenticate) {
try {
const { BackgroundProcedure } = await import('./backgroundProcedure');
const bgProcedure = new BackgroundProcedure(this._page, this._logger);
await bgProcedure.setBackgroundFromUrl(this._options.backgroundImageUrl);
} catch (error) {
this._logger.warn(`Background image setup failed (non-fatal): ${error}`);
}
}
// Background image is managed via the user profile's default background.
// No background setup needed during the join flow.
// Join the meeting
await this._joinProcedure.joinMeetingLobbyFlow();