Skip to content

importing github project in offline app#11208

Merged
jwunderl merged 2 commits intomasterfrom
dev/jwunderl/import-while-github-disabled
Mar 23, 2026
Merged

importing github project in offline app#11208
jwunderl merged 2 commits intomasterfrom
dev/jwunderl/import-while-github-disabled

Conversation

@jwunderl
Copy link
Copy Markdown
Member

fix microsoft/pxt-arcade#7515 (but more generally, fix importing github projects when in situations github view is disabled); when you load in project it'll work, just will have github information scrapped:
image

@jwunderl jwunderl requested a review from a team March 23, 2026 21:27
@jwunderl jwunderl enabled auto-merge (squash) March 23, 2026 22:50
@abchatra abchatra requested a review from Copilot March 23, 2026 22:59
@jwunderl jwunderl merged commit f8e37e4 into master Mar 23, 2026
22 checks passed
@jwunderl jwunderl deleted the dev/jwunderl/import-while-github-disabled branch March 23, 2026 23:00
Copy link
Copy Markdown
Contributor

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

Enables importing GitHub-backed projects even when the GitHub editor UI is disabled (e.g., offline app / Electron), by proceeding with the import and stripping GitHub metadata before loading the project.

Changes:

  • Removes the early “GitHub import not supported” guard and introduces a githubEnabled flag.
  • Skips forced GitHub sign-in when GitHub UI is disabled.
  • Attempts to scrub GitHub metadata from the imported header before loading.

Comment on lines +6102 to +6105
if (!githubEnabled) {
hd.githubId = undefined;
hd.githubTag = undefined;
hd.githubCurrent = false;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

Clearing hd.githubId/githubTag/githubCurrent here is likely not enough to “scrap” GitHub info: during loadHeaderAsync, pkg.loadPkgAsync triggers workspace.recomputeHeaderFlagsAsync, which re-populates these fields from pxt.github.GIT_JSON (git.json) in the project files. This means the project may still be treated as a GitHub project (e.g., Save/Rename UI suppressed) even when githubEnabled is false. Consider removing the git.json file from the imported project (and persisting the updated header/files via workspace.saveAsync) when GitHub is disabled, or otherwise preventing recomputeHeaderFlagsAsync from rehydrating GitHub metadata for this import path.

Suggested change
if (!githubEnabled) {
hd.githubId = undefined;
hd.githubTag = undefined;
hd.githubCurrent = false;
if (!githubEnabled) {
// Scrub GitHub metadata from the header
hd.githubId = undefined;
hd.githubTag = undefined;
hd.githubCurrent = false;
// Also remove git.json from the project files so that
// workspace.recomputeHeaderFlagsAsync cannot rehydrate
// GitHub metadata from disk when the header is loaded.
try {
const files: pxt.workspace.ScriptText = await workspace.getTextAsync(hd.id);
if (files && files[pxt.github.GIT_JSON]) {
delete files[pxt.github.GIT_JSON];
await workspace.saveAsync(hd, files);
}
} catch (err) {
// Failing to scrub git.json should not prevent the project from loading.
// Log the error for diagnostics and continue.
console.error("Failed to remove git.json for imported GitHub project when GitHub is disabled", err);
}

Copilot uses AI. Check for mistakes.
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.

Offline app: “JetChamp” community game fails to open in editor

3 participants