Skip to content

feat(build): add no-terminal flag to omit embedded terminal assets - #2916

Closed
xaniexane wants to merge 1 commit into
Acode-Foundation:mainfrom
xaniexane:feat/build-no-terminal-assets
Closed

xaniexane wants to merge 1 commit into
Acode-Foundation:mainfrom
xaniexane:feat/build-no-terminal-assets

Conversation

@xaniexane

Copy link
Copy Markdown

Problem

Fixes #2897.

With the Alpine → Ubuntu terminal migration (#2699), the embedded rootfs payload grows from ~15MB to ~90MB, pushing test APKs to ~113MB. For developers on capped/metered connections, every fork-test build is a heavy download, and the F-Droid build workaround targets legacy API 28 — unsuitable for testing modern behavior.

Change

Adds a no-terminal argument to the build script:

npm run build paid dev apk no-terminal

When set, the build skips the com.foxdebug.acode.rk.exec.proot plugin (which bundles the per-arch alpine.rootfs assets), so the rootfs is never copied into the APK. This follows the exact pattern the fdroid flag already uses for plugin add/remove, and a subsequent normal build re-adds the plugin automatically — no manual cleanup.

Deliberately untouched:

  • Runtime $FDROID handling — a no-terminal build behaves like a normal build at runtime; the terminal simply fails fast on open (existing extract-asset error path) since its payload isn't bundled.
  • The fdroid flag semantics — combining both flags still works (fdroid wins on runtime behavior).

Testing

  • bash -n syntax check passes.
  • Exercised the argument/plugin logic in isolation with a stubbed cordova across all four states:
    • no-terminal + plugin present → plugin removed, notice printed
    • normal + plugin present → no plugin churn
    • no-terminal + plugin absent → no-op
    • normal + plugin absent → plugin re-added (self-healing)
  • Full APK build not run here (needs Android SDK/Cordova toolchain); the change only gates plugin add/remove, which is the same mechanism fdroid has used in this script.

Adds a 'no-terminal' build argument (npm run build paid dev apk
no-terminal) that skips the proot plugin, so the heavy per-arch terminal
rootfs (~90MB with Ubuntu) is never copied into the APK. For developers
on capped/metered connections and fast fork CI iteration when testing
non-terminal features; the terminal is unavailable in such builds.

Follows the existing fdroid plugin add/remove pattern; a subsequent
normal build re-adds the plugin automatically. Runtime $FDROID handling
is untouched.

Fixes Acode-Foundation#2897
@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR is not safe to merge until format-on-save prevents a delayed formatter dispatch from modifying a different tab after a same-pane switch.

Findings

  1. P1 Tab switch corrupts content

Summary

This PR adds a no-terminal build argument that removes the proot Cordova plugin before packaging and restores it on a subsequent normal build. It also changes format-on-save to await formatting, propagate formatter results, and avoid initially formatting a file that is no longer active.

  • Adds conditional proot plugin removal to produce smaller development APKs without embedded terminal rootfs assets.
  • Introduces a true/false/null formatting result contract and propagates it through the format command.
  • Makes save operations wait for formatting before reading and writing document content.
  • The new format-on-save sequencing does not protect against switching tabs while the formatter itself is awaiting work, leaving a cross-file content corruption race.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Save file A with format-on-save] --> B{A is currently active?}
  B -->|No| F[Skip formatting and save A]
  B -->|Yes| C[Await asynchronous formatter]
  C --> D{User switches pane to file B?}
  D -->|No| E[Apply formatted state to A and save]
  D -->|Yes| G[Pane reuses EditorView for B]
  G --> H[Late formatter dispatch updates B]
  H --> I[Save writes stale content from A]
Loading

Reviews (1) · Last reviewed commit: "feat(build): add no-terminal flag to omi..."

Comment thread src/lib/saveFile.js Outdated
Comment on lines +181 to +187
if (editorManager.activeFile === file) {
// Await the formatter so the write below captures the
// formatted document. A failed format aborts the save;
// `null` means no formatter is configured, which is not
// a failure.
const formatted = await acode.exec("format", false);
if (formatted === false) return false;

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.

P1 Tab switch corrupts content

If file A starts format-on-save and the user switches the same pane to file B while formatting is still running, the formatter later applies A's formatted output through the pane's reused editor. The document listener assigns that update to file B because B is active by then. This can replace B's in-memory content, mark or autosave B as edited, and save stale unformatted content for A. Re-check the file identity before applying formatter changes, or bind formatting to A's document instead of the pane's mutable active editor.

Knowledge Base Used:

@xaniexane
xaniexane force-pushed the feat/build-no-terminal-assets branch from 9f01cc3 to 7d828e9 Compare September 19, 2026 18:07
@xaniexane

Copy link
Copy Markdown
Author

Thanks for the review! One correction: the "Tab switch corrupts content" finding doesn't apply to this branch as it exists now. It was written against commit 9f01cc3, which still contained the format-on-save work — that has since been moved to its own branch (PR #2915). This branch is now exactly 7d828e9, which only touches utils/scripts/build.sh to add the no-terminal flag. No editor, formatter, or save-path code exists on this branch, so the finding can't apply here. No code change needed on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CLI build option to omit embedded terminal assets

2 participants