diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a55b21d..53080db 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -31,8 +31,11 @@ jobs: - run: npm install --ignore-scripts --no-audit --no-fund - run: npm --prefix apps/android/ui ci --legacy-peer-deps --no-audit --no-fund - run: npm run build - - run: apps/android/gradlew -p apps/android --no-daemon assembleDebug assembleRelease lintDebug testDebugUnitTest - - name: Verify signed Release APK size + - name: Build and lint aBridge Android + run: apps/android/gradlew -p apps/android --no-daemon assembleDebug assembleRelease lintDebug testDebugUnitTest + - name: Build and lint AI Home Android + run: apps/controller/gradlew -p apps/controller --no-daemon assembleDebug assembleRelease lintDebug testDebugUnitTest + - name: "Verify signed APK sizes (aBridge: 300,000 B; AI Home: 2,000,000 B)" run: | work=$(mktemp -d) trap 'rm -rf "$work"' EXIT @@ -40,9 +43,11 @@ jobs: "$work/python/bin/python" -m pip install -r tools/android-apk-requirements.txt keytool -genkeypair -keystore "$work/check.keystore" -alias android -storepass sizecheck -keypass sizecheck \ -keyalg RSA -keysize 2048 -validity 1 -dname "CN=Android size check" - ANDROID_KEYSTORE_BASE64="$(openssl base64 -A -in "$work/check.keystore")" \ - ANDROID_KEYSTORE_PASSWORD=sizecheck ANDROID_KEY_ALIAS=android ANDROID_KEY_PASSWORD=sizecheck \ - ANDROID_APK_PYTHON="$work/python/bin/python" bash tools/sign-android-release.sh + export ANDROID_KEYSTORE_BASE64="$(openssl base64 -A -in "$work/check.keystore")" + export ANDROID_KEYSTORE_PASSWORD=sizecheck ANDROID_KEY_ALIAS=android ANDROID_KEY_PASSWORD=sizecheck + export ANDROID_APK_PYTHON="$work/python/bin/python" + bash tools/sign-android-release.sh abridge + bash tools/sign-android-release.sh aihome - name: Upload installable Debug APK uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -50,3 +55,10 @@ jobs: path: apps/android/build/outputs/apk/debug/*.apk if-no-files-found: error retention-days: 14 + - name: Upload installable AI Home Debug APK + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: aihome-android-debug + path: apps/controller/build/outputs/apk/debug/*.apk + if-no-files-found: error + retention-days: 14 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21e7407..3232cef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,9 +86,12 @@ jobs: run: | npm --prefix apps/android/ui ci --legacy-peer-deps --no-audit --no-fund apps/android/gradlew -p apps/android --no-daemon assembleRelease + apps/controller/gradlew -p apps/controller --no-daemon assembleRelease python3 -m venv "$RUNNER_TEMP/android-apk-build" "$RUNNER_TEMP/android-apk-build/bin/python" -m pip install -r tools/android-apk-requirements.txt - ANDROID_APK_PYTHON="$RUNNER_TEMP/android-apk-build/bin/python" bash tools/sign-android-release.sh + export ANDROID_APK_PYTHON="$RUNNER_TEMP/android-apk-build/bin/python" + bash tools/sign-android-release.sh abridge + bash tools/sign-android-release.sh aihome - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 if: runner.os == 'Linux' with: @@ -99,6 +102,7 @@ jobs: dist/releases/abridge-client-browser-*.tar.gz* dist/releases/install-browser-client.sh* dist/releases/aBridge-*-android.apk + dist/releases/AIHome-*-android.apk if-no-files-found: error retention-days: 14 - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 diff --git a/apps/android/README.md b/apps/android/README.md index 017b626..c12bb4e 100644 --- a/apps/android/README.md +++ b/apps/android/README.md @@ -28,7 +28,7 @@ The Android build requires JDK 17 and Android SDK Platform 36. Gradle consumes t The [Android App workflow](../../.github/workflows/android.yml) builds Debug and Release APKs and runs Android Lint on pull requests and pushes to `main`. Download the installable Debug APK from the run's **abridge-android-debug** artifact. -Debug and Release APKs use R8 to remove unused code and compress the remaining DEX bytecode. Release packaging recompresses the APK before signing and checks the complete signed file against a 200,000-byte budget. Android extracts the bytecode during installation, so the APK size and installed storage usage differ. +Debug and Release APKs use R8 to remove unused code and compress the remaining DEX bytecode. Release packaging recompresses the APK before signing and checks the complete signed file against a 300,000-byte budget. Android extracts the bytecode during installation, so the APK size and installed storage usage differ. ## Tools diff --git a/apps/controller/README.md b/apps/controller/README.md index 9d62369..01ad9e4 100644 --- a/apps/controller/README.md +++ b/apps/controller/README.md @@ -14,6 +14,8 @@ cd apps/controller adb install -r build/outputs/apk/debug/AIHome-debug.apk ``` +APK 压缩 DEX 字节码,由 Android 在安装时解压。正式 APK 重新压缩、对齐并签名后,上限为 2,000,000 字节(2 MB,十进制);CI 和发布流程通过 `bash tools/sign-android-release.sh aihome` 检查。aBridge 接收端仍使用独立的 300,000 字节上限。 + APK 不包含前端资源。前端由 Server 同源托管,更新后需重新构建并部署 `ui/dist`。安装控制端不会安装或替换接收任务的 aBridge 客户端。 ## Server 与工作进程 diff --git a/apps/controller/build.gradle b/apps/controller/build.gradle index ab3d729..084a110 100644 --- a/apps/controller/build.gradle +++ b/apps/controller/build.gradle @@ -14,6 +14,10 @@ android { versionName upstream versionCode parts[0] * 1000000 + parts[1] * 1000 + parts[2] } + packaging { + // Compress DEX in the download; Android extracts it during installation. + dex.useLegacyPackaging = true + } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 diff --git a/apps/web/src/app/app.tsx b/apps/web/src/app/app.tsx index bb6e351..d984ece 100644 --- a/apps/web/src/app/app.tsx +++ b/apps/web/src/app/app.tsx @@ -2,7 +2,7 @@ import { LayoutDashboard, Monitor, Link2, ListFilter, ShieldCheck } from "lucide import { VERSION } from "@abridge/protocol"; import { useCallback, useEffect, useState } from "preact/hooks"; import { api, objectResultSchema } from "../lib/api.js"; -import { Authentication, ExternalLogin } from "../features/auth/page.js"; +import { Authentication, ExternalLogin, SessionLoading } from "../features/auth/page.js"; import { ActionMenu } from "../components/actions.js"; import { Brand } from "../components/brand.js"; import { Field, Form, Modal } from "../components/forms.js"; @@ -330,7 +330,8 @@ function AdministratorApp() { return () => window.removeEventListener("hashchange", navigate); }, []); const section = parseRoute(hash).id; - if (admin.phase !== "ready") + if (admin.phase === "loading") return ; + if (admin.phase === "none") return (
- {admin.phase === "loading" ? ( -

正在验证管理员身份…

- ) : ( - <> -
{ - setNotice(""); - location.hash = new URLSearchParams({ - admin_token: String(data.get("token")).trim(), - }).toString(); - }} - > - - - {notice && ( - - )} - +
{ + setNotice(""); + location.hash = new URLSearchParams({ + admin_token: String(data.get("token")).trim(), + }).toString(); + }} + > + + + {notice && ( + )} diff --git a/apps/web/src/features/admin/console.tsx b/apps/web/src/features/admin/console.tsx index 70bdef2..530588b 100644 --- a/apps/web/src/features/admin/console.tsx +++ b/apps/web/src/features/admin/console.tsx @@ -179,6 +179,13 @@ export function InstanceAdminPage({ {!rows.length &&

没有符合条件的任务

} ); + if (section === "users" || section === "groups") + return ( + <> + {!sidebar && } + {section === "users" ? : groups} + + ); return ( <>
@@ -395,8 +402,6 @@ export function InstanceAdminPage({ )} )} - {section === "users" && } - {section === "groups" && groups} {section === "audit" && (
diff --git a/apps/web/src/features/admin/groups.tsx b/apps/web/src/features/admin/groups.tsx index 8012510..c32bd2e 100644 --- a/apps/web/src/features/admin/groups.tsx +++ b/apps/web/src/features/admin/groups.tsx @@ -11,35 +11,36 @@ import { } from "@abridge/protocol"; import { api, objectResultSchema } from "../../lib/api.js"; import { Field, Form, Modal } from "../../components/forms.js"; +import { RefreshButton } from "./refresh-button.js"; export function GroupsPage({ notify }: { notify: (message: string) => void }) { const base = "/api/admin/groups"; const [groups, setGroups] = useState([]); const [error, setError] = useState(""); + const [loading, setLoading] = useState(true); const [creating, setCreating] = useState(false); const [selected, setSelected] = useState(null); const refresh = useCallback(async () => { - const result = await api(base, groupsListSchema); - setGroups(result.groups); + setLoading(true); + try { + const result = await api(base, groupsListSchema); + setGroups(result.groups); + setError(""); + } catch (caught) { + setError(caught instanceof Error ? caught.message : "读取小组失败"); + } finally { + setLoading(false); + } }, [base]); useEffect(() => { - let alive = true; - void api(base, groupsListSchema) - .then((r) => { - if (alive) setGroups(r.groups); - }) - .catch((e) => { - if (alive) setError(e instanceof Error ? e.message : "读取小组失败"); - }); - return () => { - alive = false; - }; - }, [base]); + void refresh(); + }, [refresh]); return ( <> -
-

全部小组

+
+

小组

+ @@ -49,13 +50,7 @@ export function GroupsPage({ notify }: { notify: (message: string) => void }) { {error && ( @@ -72,7 +67,7 @@ export function GroupsPage({ notify }: { notify: (message: string) => void }) {
))} - {!groups.length && !error &&

暂无小组

} + {!groups.length && !error && !loading &&

暂无小组

}
{creating && ( setCreating(false)}> diff --git a/apps/web/src/features/admin/page.tsx b/apps/web/src/features/admin/page.tsx index 88161a8..b767927 100644 --- a/apps/web/src/features/admin/page.tsx +++ b/apps/web/src/features/admin/page.tsx @@ -96,7 +96,7 @@ export function UserAdminPage({ return ( <>
-

实例管理

+

用户