Skip to content

feat: add job manager support for background job execution [AP-68]#544

Open
dougmartin wants to merge 4 commits intomasterfrom
AP-68-add-job-manager-support
Open

feat: add job manager support for background job execution [AP-68]#544
dougmartin wants to merge 4 commits intomasterfrom
AP-68-add-job-manager-support

Conversation

@dougmartin
Copy link
Member

Implement IJobExecutor backed by Firebase so iframed interactives can create and track background jobs via the LARA interactive API. Includes a Firestore listener for real-time status updates, backfill on page reload via getJobs, and support for both authenticated and anonymous users. Wires JobManager into iframe-runtime.tsx following the existing PubSubManager pattern.

  • Add src/firebase-job-executor.ts with FirebaseJobExecutor singleton
  • Export getFirestoreDb() from firebase-db.ts; add emulator support
  • Wire JobManager into iframe-runtime.tsx (addInteractive/removeInteractive)
  • Call configure() in app.tsx for authenticated learners and anonymous users
  • Bump interactive-api-host to ^0.11.0-pre.0, lara-interactive-api to 1.13.0-pre.2
  • Add unit tests (21 tests covering all executor methods)

Implement IJobExecutor backed by Firebase so iframed interactives can
create and track background jobs via the LARA interactive API. Includes
a Firestore listener for real-time status updates, backfill on page
reload via getJobs, and support for both authenticated and anonymous
users. Wires JobManager into iframe-runtime.tsx following the existing
PubSubManager pattern.

- Add src/firebase-job-executor.ts with FirebaseJobExecutor singleton
- Export getFirestoreDb() from firebase-db.ts; add emulator support
- Wire JobManager into iframe-runtime.tsx (addInteractive/removeInteractive)
- Call configure() in app.tsx for authenticated learners and anonymous users
- Bump interactive-api-host to ^0.11.0-pre.0, lara-interactive-api to 1.13.0-pre.2
- Add unit tests (21 tests covering all executor methods)
… peer conflict

@concord-consortium/dynamic-text@1.0.6 requires lara-interactive-api@">=1.8.0"
as a peer dependency, but npm 7+ excludes pre-release versions from semver ranges,
causing CI to fail on npm ci. legacy-peer-deps restores the old resolution behavior
until stable versions of interactive-api-host and lara-interactive-api ship.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds host-side background job execution support to Activity Player by implementing an IJobExecutor backed by Firebase Cloud Functions + Firestore, and wiring it into the iframe runtime via the JobManager so iframed interactives can create/cancel/backfill jobs with real-time status updates.

Changes:

  • Add FirebaseJobExecutor (Cloud Function submit + Firestore onSnapshot listeners) and comprehensive unit tests.
  • Export getFirestoreDb() and add Firestore emulator support via ?emulator=true.
  • Wire JobManager into iframe-runtime.tsx and configure the executor from app.tsx for authenticated and anonymous learners; update related package versions.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/firebase-job-executor.ts New Firebase-backed IJobExecutor implementation with create/cancel/getJobs + Firestore listeners.
src/firebase-job-executor.test.ts Unit tests covering executor methods and listener behavior.
src/firebase-db.ts Exports getFirestoreDb() and enables Firestore emulator support.
src/components/app.tsx Configures the job executor once portal/anonymous data resolves.
src/components/activity-page/managed-interactive/managed-interactive.test.tsx Updates mocks to include JobManager.
src/components/activity-page/managed-interactive/iframe-runtime.tsx Creates a module-level JobManager, calls addInteractive/removeInteractive, and passes job context.
specs/AP-68-add-job-manager-support.md Design/requirements spec for AP-68 implementation.
package.json Bumps interactive-api-host and lara-interactive-api versions.
package-lock.json Lockfile updates to match dependency bumps.
.npmrc Adds legacy-peer-deps=true.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cypress
Copy link

cypress bot commented Mar 12, 2026

activity-player    Run #1875

Run Properties:  status check passed Passed #1875  •  git commit 17ddf4c6d9: fix: add platform_id and context_id to getJobs query for authenticated users
Project activity-player
Branch Review AP-68-add-job-manager-support
Run status status check passed Passed #1875
Run duration 05m 22s
Commit git commit 17ddf4c6d9: fix: add platform_id and context_id to getJobs query for authenticated users
Committer Doug Martin
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 96
View all changes introduced in this branch ↗︎

- Guard useEmulator with typeof window check for non-browser safety
- Return [] from getJobs when no valid user scope (user_type + identity
  field) is present to prevent cross-user job data exposure
- Filter out documents missing jobInfo before sorting in getJobs
- Guard snapshot handler against missing/incomplete jobInfo
- Add clear error message to getFirestoreDb when app not initialized
- Update tests to pass complete user context to getJobs
…d users

Firestore's emulator evaluates list security rules using query constraints
rather than document field values. The learnerOwner() rule checks
platform_user_id and platform_id; adding both (plus context_id to match the
getAnswerDocsQuery pattern) gives the emulator enough constraint to approve
the query without hitting "Property X is undefined" errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants