Make the launcher a standalone repo

Moved out of codegod100/ultra with its history (examples/launcher is now web/).
ultra is a git submodule; pixi tasks build web/app.wasm with it and run the
browser test. CI runs that test and builds the APK, signed with the same
committed debug key, and republishes the launcher-latest release.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TQdaz3C1f3xEJM6PFzWE6
This commit is contained in:
Claude committed 2026-10-21 20:49:40 +00:00
1 parent ab03efd389
commit 075d97b5b4
11 files changed
+2082 -178

No files matched your search

@@ -1,17 +1,29 @@
name: Android launcher name: Launcher
on: on:
push: push:
branches: [main] branches: [main]
paths: ["android/**", "examples/launcher/**", ".github/workflows/android.yml"]
pull_request: pull_request:
paths: ["android/**", "examples/launcher/**", ".github/workflows/android.yml"]
workflow_dispatch: workflow_dispatch:
permissions: permissions:
contents: write contents: write
jobs: jobs:
web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: true
- uses: prefix-dev/setup-pixi@v0.9.3
- name: Fetch Playwright
run: pixi run install-playwright
- name: Build the wasm and run the browser test
run: pixi run test
- name: Check the committed web/app.wasm is up to date
run: git diff --exit-code --stat web/
apk: apk:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+7
View File
@@ -0,0 +1,7 @@
__pycache__/
node_modules/
.pixi/
android/.gradle/
android/build/
android/app/build/
android/local.properties
+3
View File
@@ -0,0 +1,3 @@
[submodule "ultra"]
path = ultra
url = https://github.com/codegod100/ultra
+29
View File
@@ -0,0 +1,29 @@
# ultra launcher
An Android home screen written as an [ultra](https://github.com/codegod100/ultra) app (LPython compiled to WebAssembly, Elm-style). The home starts blank with a clock: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to move or remove it. Swipe down for the drawer with every app and a search (Enter opens the first match); long-press an app there to put it on the home screen, and swipe up to close it. The panel under the clock has a **Windows** button that opens Recents. The layout is saved in localStorage.
## Install
Get the APK from the [`launcher-latest` release](https://github.com/codegod100/launcher/releases/tag/launcher-latest), which CI rebuilds on every push to `main`. Open it once, press Home, and pick **ultra Home** as the default. Builds are signed with the committed `android/app/debug.keystore`, so each one installs over the last.
The **Windows** button uses an accessibility service (`RecentsService`, which only performs the Recents action). Enable it once under Settings → Accessibility; on Android 13+ a sideloaded APK may first need App info → ⋮ → Allow restricted settings.
## Layout
- `web/` is the UI: `app.py` is the ultra app and `app.wasm` its committed build, with `index.html`, `style.css` and the `ultra.js` / `ui.css` runtime the build copies in. `apps.json` and `widgets.json` are demo data for desktop browsers.
- `android/` is a small native shell (Java, no dependencies) that serves `web/` to a transparent WebView over the wallpaper. It answers `apps.json` from `LauncherApps` and `widgets.json` from the installed widget providers, hands icons to the page through the `window.Android` bridge, and draws real `AppWidgetHostView`s over the slots the page reports.
- `ultra/` is the ultra framework, as a git submodule.
- `tests/e2e.cjs` is a Playwright test of the browser demo.
## Build
```sh
git submodule update --init
pixi run build # web/app.py -> web/app.wasm
pixi run install-playwright && pixi run test
cd android && ./gradlew assembleDebug # needs JDK 17 and the Android SDK
```
`pixi run serve` serves `web/` on http://localhost:8000. In a desktop browser the launcher runs against the demo JSON files, shows a toast instead of launching, and draws widgets as labelled placeholders. Click the bar at the top to open the drawer.
To pick up a newer ultra, update the submodule (`cd ultra && git pull origin main`), rebuild, and commit `ultra` together with the rebuilt `web/` files.
+2 -2
View File
@@ -20,8 +20,8 @@ android {
} }
sourceSets { sourceSets {
// The home screen UI is the ultra app in examples/launcher, served from assets. // The home screen UI is the ultra app in web/, served from assets.
main.assets.srcDirs = ["$rootDir/../examples/launcher"] main.assets.srcDirs = ["$rootDir/../web"]
} }
androidResources { androidResources {
@@ -62,7 +62,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
/** /**
* The home screen activity. The UI is the ultra app in examples/launcher (LPython compiled * The home screen activity. The UI is the ultra app in web/ (LPython compiled
* to wasm), packaged as assets and served to a transparent WebView from a virtual https * to wasm), packaged as assets and served to a transparent WebView from a virtual https
* origin. This class answers the two dynamic URLs the app fetches: * origin. This class answers the two dynamic URLs the app fetches:
* *
+1985
View File
File diff suppressed because it is too large. Load diff
+17
View File
@@ -0,0 +1,17 @@
[workspace]
name = "launcher"
description = "Android home-screen launcher written as an ultra app (LPython -> wasm)"
channels = ["https://conda.anaconda.org/conda-forge"]
platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"]
[dependencies]
python = "3.12.*"
lpython = "0.22.*"
nodejs = ">=22"
# The ultra framework is the git submodule in ultra/ (`git submodule update --init`).
[tasks]
build = { cmd = "python ultra/tools/ultra.py build web/app.py", description = "Compile web/app.py to web/app.wasm" }
serve = { cmd = "python ultra/tools/ultra.py serve web", description = "Serve the launcher's browser demo on http://localhost:8000" }
install-playwright = { cmd = "npm install --no-save --no-package-lock playwright@1.56.1 && npx playwright install chromium", description = "Fetch Playwright and Chromium for the browser test" }
test = { cmd = "python tests/run.py", depends-on = ["build"], description = "Build, then run the browser test against a local server" }
+2 -172
View File
@@ -1,4 +1,4 @@
// Browser smoke test for the example apps. // Browser smoke test for the launcher's web UI, against the demo apps.json and widgets.json.
// pixi run test (or: pixi run serve & then node tests/e2e.cjs) // pixi run test (or: pixi run serve & then node tests/e2e.cjs)
const assert = require("assert"); const assert = require("assert");
const { chromium } = require(process.env.PLAYWRIGHT || "playwright"); const { chromium } = require(process.env.PLAYWRIGHT || "playwright");
@@ -8,180 +8,10 @@ const BASE = process.env.BASE || "http://localhost:8000";
const b = await chromium.launch(); const b = await chromium.launch();
const p = await b.newPage(); const p = await b.newPage();
p.on("pageerror", (e) => { console.error("page error:", e.message); process.exitCode = 1; }); p.on("pageerror", (e) => { console.error("page error:", e.message); process.exitCode = 1; });
const tick = () => p.waitForTimeout(40);
const labels = () => p.$$eval(".item label", (ls) => ls.map((l) => l.textContent));
// counter
await p.goto(BASE + "/examples/counter/");
await p.waitForSelector(".count");
const count = async () => Number((await p.textContent(".count")).replace("−", "-"));
assert.equal(await count(), 0);
await p.click("text=+"); await p.click("text=+"); await tick();
assert.equal(await count(), 2);
await p.click("text=×10"); await p.click("text=−"); await tick();
assert.equal(await count(), -8);
assert.ok(await p.$(".count.neg"));
await p.click("text=Auto-increment"); await p.waitForTimeout(1200);
assert.ok((await count()) > -8);
assert.equal(await p.getAttribute(".switch", "aria-checked"), "true");
await p.click("text=Auto-increment"); await tick();
assert.equal(await p.getAttribute(".switch", "aria-checked"), "false");
console.log("counter ok");
// todo
await p.goto(BASE + "/examples/todo/");
await p.evaluate(() => localStorage.clear());
await p.reload();
await p.waitForSelector("input.new");
for (const s of ["Write LPython", "Compile to wasm", "Ship it"]) {
await p.fill("input.new", s);
await p.press("input.new", "Enter");
}
await tick();
assert.deepEqual(await labels(), ["Write LPython", "Compile to wasm", "Ship it"]);
assert.equal(await p.inputValue("input.new"), "");
await p.click(".item:nth-child(2) .checkbox"); await tick();
assert.equal(await p.textContent(".footer .badge"), "2 left");
await p.click("text=Active"); await tick();
assert.deepEqual(await labels(), ["Write LPython", "Ship it"]);
await p.click("text=All"); await tick();
await p.reload(); await p.waitForSelector(".item");
assert.deepEqual(await labels(), ["Write LPython", "Compile to wasm", "Ship it"]);
assert.ok(await p.$(".item:nth-child(2).done"));
await p.click(".item:first-child .x", { force: true }); await tick();
await p.click("text=Clear done"); await tick();
assert.deepEqual(await labels(), ["Ship it"]);
console.log("todo ok");
// bench: keyed rows
await p.goto(BASE + "/examples/bench/");
await p.waitForSelector("#run");
const rows = () => p.$$eval("tbody tr", (rs) => rs.length);
const ids = () => p.$$eval("tbody td.id", (ts) => ts.map((t) => Number(t.textContent)));
const op = async (sel) => { await p.click(sel); await p.waitForTimeout(60); };
await op("#run");
assert.equal(await rows(), 1000);
assert.equal(await p.textContent(".rows"), "1000 rows");
await op("#update");
assert.match(await p.textContent("tbody tr:nth-child(1) td.lbl"), / !!!$/);
assert.doesNotMatch(await p.textContent("tbody tr:nth-child(2) td.lbl"), /!!!/);
// keyed patching must reuse row nodes: tag them, swap, and check identity
await p.$$eval("tbody tr", (rs) => rs.forEach((r, i) => { r.__tag = i; }));
const before = await ids();
await op("#swaprows");
const after = await ids();
assert.equal(after[1], before[998]);
assert.equal(after[998], before[1]);
assert.deepEqual(await p.$$eval("tbody tr", (rs) => [rs[0].__tag, rs[1].__tag, rs[2].__tag, rs[998].__tag]), [0, 998, 2, 1]);
await op("tbody tr:nth-child(3) td.lbl a");
assert.ok(await p.$("tbody tr:nth-child(3).danger"));
assert.equal(await p.$$eval("tr.danger", (rs) => rs.length), 1);
await op("tbody tr:nth-child(5) a.x");
assert.equal(await rows(), 999);
assert.deepEqual(await ids(), after.filter((_, i) => i !== 4));
assert.equal(await p.$eval("tbody tr:nth-child(5)", (r) => r.__tag), 5);
await op("#runlots");
assert.equal(await rows(), 10000);
await op("#add");
assert.equal(await rows(), 11000);
await op("#clear");
assert.equal(await rows(), 0);
const suite = await p.evaluate(() => window.ultraBench.runSuite(1));
assert.equal(suite.length, 9);
assert.ok(suite.every((r) => r.ms > 0));
console.log("bench ok:", suite.map((r) => `${r.name} ${r.ms.toFixed(0)}ms`).join(", "));
// life: animation loop via frame()
await p.goto(BASE + "/examples/life/");
await p.waitForSelector(".grid i");
const gen = async () => Number((await p.textContent(".stats")).match(/gen (\d+)/)[1]);
const g0 = await gen();
await p.waitForTimeout(500);
assert.ok((await gen()) > g0 + 5, "animation should advance");
assert.equal(await p.$$eval(".grid i", (cs) => cs.length), 10000);
await op("#play");
const g1 = await gen();
await p.waitForTimeout(200);
assert.equal(await gen(), g1, "paused");
await op("#step");
assert.equal(await gen(), g1 + 1);
await op("text=Glider guns");
assert.match(await p.textContent(".stats"), /gen 0 · pop 72 ·/);
await op("text=50²");
assert.equal(await p.$$eval(".grid i", (cs) => cs.length), 2500);
console.log("life ok");
// ui: component gallery, every widget wired to live state
await p.goto(BASE + "/examples/ui/");
await p.evaluate(() => localStorage.clear());
await p.reload();
await p.waitForSelector(".card");
await p.click("text=Destructive"); await p.click("text=Large"); await tick();
assert.equal(await p.getAttribute("#preview", "class"), "btn destructive lg");
await p.click("#preview"); await p.click("#preview"); await tick();
assert.equal(await p.textContent(".preview .badge"), "2");
// profile: Save is disabled until there is a name and the terms are accepted
assert.ok(await p.$("#save[disabled]"));
await p.fill("input[placeholder='Ada Lovelace']", "Ada"); await tick();
assert.equal(await p.textContent(".hello-name"), "Ada");
assert.ok(await p.$("#save[disabled]"));
await p.click("text=Accept terms"); await tick();
assert.ok(!(await p.$("#save[disabled]")));
await p.press("input[placeholder='Ada Lovelace']", "Enter"); await tick();
assert.match(await p.textContent(".toast"), /Saved Ada\./);
await p.waitForTimeout(2700);
assert.ok(!(await p.$(".toast")), "toast hides itself");
await p.click(".field >> text=Email notifications"); await tick();
assert.match(await p.textContent(".hello"), /muted/);
// tabs
await p.click("[role=tab] >> text=Password"); await tick();
await p.fill("input[type=password]", "abc"); await tick();
assert.equal(await p.textContent("[role=tabpanel] .badge"), "Weak");
await p.fill("input[type=password]", "correct horse"); await tick();
assert.equal(await p.textContent("[role=tabpanel] .badge"), "Strong");
await p.click("[role=tab] >> text=Billing"); await tick();
assert.equal(await p.textContent(".total"), "$36 / month");
await p.click("text=Yearly"); await p.click("[role=tabpanel] >> text=+"); await tick();
assert.equal(await p.textContent(".total"), "$480 / year");
// progress animation
await p.click("#play"); await p.waitForTimeout(400);
const lvl = Number(await p.textContent("#play + .badge"));
assert.ok(lvl > 30, "progress should advance");
await p.click("#play");
// table: search, filter, sort, select, delete with undo
const invs = () => p.$$eval("tbody td.mono", (ts) => ts.map((t) => t.textContent));
await p.fill("input[placeholder^=Search]", "pay"); await tick();
assert.deepEqual(await invs(), ["INV002", "INV005"]);
await p.fill("input[placeholder^=Search]", ""); await p.click('.toggle >> text="Pending"'); await tick();
assert.deepEqual(await invs(), ["INV002", "INV006"]);
await p.click('text="All"'); await p.click("#sort"); await tick();
assert.deepEqual(await invs(), ["INV004", "INV003", "INV001", "INV006", "INV002", "INV005"]);
assert.equal(await p.textContent("tfoot td.num"), "$1450.00");
await p.click("tbody td >> text=INV005"); await p.click("tbody tr:nth-child(6) button.badge"); await tick();
assert.equal(await p.textContent("tbody tr:nth-child(6) .badge"), "Pending");
assert.equal(await p.getAttribute("tbody tr:nth-child(6)", "aria-selected"), "true");
await p.click("#delete"); await tick();
await p.keyboard.press("Escape"); await tick();
assert.ok(!(await p.$(".dialog")), "Escape closes the dialog");
await p.click("#delete"); await tick();
await p.click(".dialog-overlay", { position: { x: 10, y: 10 } }); await tick();
assert.ok(!(await p.$(".dialog")), "backdrop closes the dialog");
await p.click("#delete"); await tick();
await p.click(".dialog .btn.destructive"); await tick();
assert.equal((await invs()).length, 5);
assert.ok(await p.$("#delete[disabled]"));
await p.click("text=Undo delete of INV005"); await tick();
assert.equal((await invs()).length, 6);
// theme persists
await p.click("text=Dark"); await tick();
await p.reload(); await p.waitForSelector(".page");
assert.ok(await p.$(".page.dark"));
console.log("ui ok");
// launcher: the Android home screen, against the demo apps.json and widgets.json
const settle = () => p.waitForTimeout(250); // renders land on the next frame, which can lag here const settle = () => p.waitForTimeout(250); // renders land on the next frame, which can lag here
await p.emulateMedia({ reducedMotion: "reduce" }); // no sliding drawer under the pointer await p.emulateMedia({ reducedMotion: "reduce" }); // no sliding drawer under the pointer
await p.goto(BASE + "/examples/launcher/"); await p.goto(BASE + "/");
await p.evaluate(() => localStorage.clear()); await p.evaluate(() => localStorage.clear());
await p.reload(); await p.reload();
await p.waitForSelector(".hint"); await p.waitForSelector(".hint");
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
"""Serve web/ on a free port and run tests/e2e.cjs against it (`pixi run test`)."""
import importlib.util
import os
import subprocess
import sys
import threading
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
spec = importlib.util.spec_from_file_location("ultra_tool", os.path.join(ROOT, "ultra", "tools", "ultra.py"))
ultra = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ultra)
srv = ultra.make_server(os.path.join(ROOT, "web"), 0, quiet=True)
threading.Thread(target=srv.serve_forever, daemon=True).start()
r = subprocess.run(["node", os.path.join(ROOT, "tests", "e2e.cjs")], cwd=ROOT,
env={**os.environ, "BASE": f"http://localhost:{srv.server_address[1]}"})
srv.shutdown()
sys.exit(r.returncode)
Submodule
+1
Submodule ultra added at 771ee03499.