Skip to content

Render the K2 dashboard on GitHub's React repository page - #391

Merged
tgolen merged 2 commits into
mainfrom
nicolasbonet-k2-dashboard-react-ui
Oct 1, 2026
Merged

tgolen merged 2 commits into
mainfrom
nicolasbonet-k2-dashboard-react-ui

Conversation

@NicolasBonet

@NicolasBonet NicolasBonet commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The K2 dashboard no longer loads. https://github.com/Expensify/Expensify#k2 shows GitHub's file view, and the console shows Uncaught (in promise) Error: Minified React error #299, which is createRoot(...): Target container is not a DOM element.

Cause

GitHub moved the repository homepage to its React UI. The page has no .repository-content anymore. Everything below the repository tabs now lives in <main id="ui-service-main-content">, and its children are a React tree with hashed Primer class names.

src/js/module/dashboard/index.js appended .k2dashboard to .repository-content. With no container, the append did nothing and createRoot received undefined. The call runs in the Onyx preferences callback, so the error surfaced as an unhandled promise rejection.

Fixing that exposed a second problem. About a second after the page loads, GitHub rebuilds parts of body outside its React tree. That removes the K2 tab, which all.js appends to body, and clears k2-page-active from body. K2 never drew itself again, so the dashboard showed for a moment and then GitHub's file view came back.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/687575

Tests

  1. Run npm run build and load dist/ as an unpacked extension.
  2. Open https://github.com/Expensify/Expensify#k2.
  3. Confirm the K2 dashboard shows and GitHub's file list is hidden.
  4. Wait 10 seconds. Confirm the K2 tab and the dashboard are still there.
  5. Reload the page 3 times. Confirm the dashboard stays after each reload.
  6. Open the browser console. Confirm there is no React error Revert "feat: Dynamic K2 button URL based on repository access" #299.
  7. Click the Pull requests tab. Confirm GitHub's pull request list shows and the dashboard is hidden.
  8. Click the K2 tab. Confirm the dashboard shows again.
  9. Sign out of K2 from the dashboard. Confirm the K2 login form shows in the same place.

GitHub's repository homepage no longer has .repository-content, so the
dashboard passed undefined to createRoot and crashed with React error #299.
Render into #ui-service-main-content when .repository-content is missing and
draw the K2 pages again when GitHub rebuilds the body and drops the K2 tab.
GitHub's repository page renders everything below the tabs in
#ui-service-main-content, so the dashboard only looks for that container.
@NicolasBonet
NicolasBonet requested a review from a team October 1, 2026 14:17
@melvin-bot
melvin-bot Bot requested review from marcaaron and removed request for a team October 1, 2026 14:17
Comment on lines +11 to +12
let host = null;
let root = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB: These variable names are confusing. I'd prefer more verbose and intuitive names.

@tgolen
tgolen merged commit 38ec346 into main Oct 1, 2026
5 of 6 checks passed
@tgolen
tgolen deleted the nicolasbonet-k2-dashboard-react-ui branch October 1, 2026 14:40
@os-botify

os-botify Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Released in version 1.5.68 🚀

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