Skip to content

Refactor Mirabuf Loading System [AARD-2060] #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7f44043
feat: refactor mirabuf caching service
rutmanz Aug 8, 2025
eb31c16
fix: make old caches not die
rutmanz Aug 8, 2025
5c34a75
fix: also remove old localstorage keys
rutmanz Aug 8, 2025
003d471
fix: unit tests
rutmanz Aug 8, 2025
b5e1bef
feat: allow loading directly from memory cache as fallback
rutmanz Aug 11, 2025
18df571
fix: make memory cache actually used
rutmanz Aug 12, 2025
32bec03
Merge remote-tracking branch 'origin/dev' into zachr/2060/mirabuf-ref…
rutmanz Aug 14, 2025
42d1497
fix: unit tests
rutmanz Aug 14, 2025
4d0ae09
fix: merge conflicts
rutmanz Aug 14, 2025
1c45f2f
feat: prevent uploading local files as wrong mira type
rutmanz Aug 14, 2025
57a8c4c
feat: remove files that don't exist in OPFS on load
rutmanz Aug 14, 2025
82e8fdf
feat: allow mirabuf caching service to work in insecure contexts
rutmanz Aug 14, 2025
bf6c3bf
refactor: early return
rutmanz Aug 14, 2025
8c58465
feat: make manifest system more robust
rutmanz Aug 18, 2025
131041b
Merge remote-tracking branch 'origin/dev' into zachr/2060/mirabuf-ref…
rutmanz Aug 18, 2025
edee81d
fix: ts configs
rutmanz Aug 18, 2025
e7bb1e1
fix: undo import sorting
rutmanz Aug 20, 2025
a4a7174
Update fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
rutmanz Aug 20, 2025
563f0ec
Update fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx
rutmanz Aug 20, 2025
fc3bb1b
fix: prevent unit tests timing out
rutmanz Aug 21, 2025
fe7d102
Merge remote-tracking branch 'origin/dev' into zachr/2060/mirabuf-ref…
rutmanz Aug 21, 2025
ef509f5
fix: don't run hash tests, add test for removal
rutmanz Aug 21, 2025
ce6e743
fix: remove debug tool
rutmanz Aug 21, 2025
87bc42b
Merge remote-tracking branch 'origin/dev' into zachr/2060/mirabuf-ref…
rutmanz Aug 21, 2025
4593cd0
fix: make unit tests pass
rutmanz Aug 21, 2025
f0c87ce
feat: add tests for assetpack as separate workflow
rutmanz Aug 21, 2025
468cc8a
Downgrade playwight version because github actions doesn't know about…
rutmanz Aug 21, 2025
b6dac0a
fix: make env variable be exposed
rutmanz Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion .github/workflows/FissionUnitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runUnitTests:
name: Playwright Unit Tests
container:
image: mcr.microsoft.com/playwright:v1.54.0-noble
image: mcr.microsoft.com/playwright:v1.54.2-noble
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -57,3 +57,41 @@ jobs:

- name: Run Tests
run: HOME=/root npm run test

runAssetpackTests:
name: Assetpack Tests
needs: runUnitTests
container:
image: mcr.microsoft.com/playwright:v1.54.2-noble
runs-on: ubuntu-latest
defaults:
run:
working-directory: "fission"
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: JavaScript Setup
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache Unzipped Synthesis Assets
id: cache-assets
uses: actions/cache@v3
with:
path: fission/public/Downloadables
key: ${{ runner.os }}-assets-${{hashFiles('fission/public/assetpack.zip')}}

- name: Cache Node Dependencies
uses: actions/cache@v3
with:
key: "${{runner.os}}-npm-fission-${{hashFiles('fission/package.json')}}"
path: "fission/node_modules"
restore-keys: |
${{runner.os}}-npm-fission-
${{runner.os}}-npm

- name: Run Assetpack Tests
run: HOME=/root npm run test src/test/mirabuf/DefaultAssets.test.ts
env:
VITE_RUN_ASSETPACK_TEST: true
1 change: 1 addition & 0 deletions fission/manifest.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type ManifestFileType = Record<"robots"|"private"|"fields", { filename: string, hash: string }[]>
4 changes: 2 additions & 2 deletions fission/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"fmt:fix": "bunx biome format src --write",
"style": "bunx biome check src",
"style:fix": "bunx biome check src --write",
"assetpack": "git lfs pull && tar -xf public/assetpack.zip -C public/",
"assetpack:update": "cd public && zip -FS -r assetpack.zip Downloadables",
"assetpack": "git lfs pull && (rm -rf public/Downloadables;tar -xf public/assetpack.zip -C public/)",
"assetpack:update": "bun update_manifest.ts && cd public && zip -FS -r assetpack.zip Downloadables",
"playwright:install": "bun x playwright install",
"electron:start": "electron-forge start",
"electron:package": "electron-forge package",
Expand Down
4 changes: 2 additions & 2 deletions fission/public/assetpack.zip
Git LFS file not shown
51 changes: 51 additions & 0 deletions fission/src/mirabuf/DefaultAssetLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { type MirabufCacheInfo, MiraType } from "@/mirabuf/MirabufLoader.ts"
import type { ManifestFileType } from "../../manifest.d.ts"
import { API_URL } from "@/util/Consts.ts"

export type DefaultAssetInfo = Required<Pick<MirabufCacheInfo, "hash" | "remotePath" | "miraType" | "name">>

class DefaultAssetLoader {
private static _assets: DefaultAssetInfo[] = []
private static _hasLoaded = false
static {
setTimeout(() => {
if (!this._hasLoaded) this.refresh().catch(console.error)
}, 1000)
}

public static async refresh() {
this._hasLoaded = true
this._assets = []
const baseUrl = `${API_URL}/mira`
const manifest: ManifestFileType = await fetch(`${baseUrl}/manifest.json`).then(x => x.json())

const miraTypeMap: Partial<Record<keyof ManifestFileType, MiraType>> = {
robots: MiraType.ROBOT,
fields: MiraType.FIELD,
}

Object.entries(manifest).forEach(([dir, assets]) => {
const miraType = miraTypeMap[dir as keyof ManifestFileType]
if (miraType == undefined) return

assets.forEach(obj => {
this._assets.push({
remotePath: `${baseUrl}/${dir}/${obj.filename}`,
hash: obj.hash,
miraType,
name: obj.filename,
})
})
})
}

public static get robots() {
return this._assets.filter(obj => obj.miraType == MiraType.ROBOT)
}

public static get fields() {
return this._assets.filter(obj => obj.miraType == MiraType.FIELD)
}
}

export default DefaultAssetLoader
Loading