Skip to content

Instantly share code, notes, and snippets.

@voltcrash
Created November 4, 2026 12:50
Show Gist options
  • Select an option

  • Save voltcrash/3a7bcf9aa0e349a4ffdf4be0e343f453 to your computer and use it in GitHub Desktop.

Select an option

Save voltcrash/3a7bcf9aa0e349a4ffdf4be0e343f453 to your computer and use it in GitHub Desktop.
T3 Code Linux desktop registration: native filesystem and subprocess fixture evidence
Linux registration fixture proof
Environment: Linux ARM64, Node v26.12.1, xdg-utils 1.2.1, real native filesystem and real update-desktop-database / xdg-mime. The harness imports the actual pre-ready and URL registration service modules, stubs only Electron shell APIs, and creates/removes a private temporary HOME with custom XDG_DATA_HOME and XDG_CONFIG_HOME. No server or real user state is used. Theme icon behavior remains covered by the existing tests; the fixture focuses on the hidden URL entry and its 549578-byte icon.
To reproduce from the PR checkout with dependencies installed:
mkdir -p /tmp/t3-linux-registration-evidence
# Download native.mjs from this gist into that directory.
git show 8b44f42b14c8e273156474a924ccf29680dd7857:apps/desktop/src/app/DesktopPreReadyPlatform.ts > /tmp/t3-linux-registration-evidence/base-Pre.ts
git show 8b44f42b14c8e273156474a924ccf29680dd7857:apps/desktop/src/app/DesktopLinuxUrlHandler.ts > /tmp/t3-linux-registration-evidence/base-Handler.ts
node /tmp/t3-linux-registration-evidence/native.mjs "$PWD" before
node /tmp/t3-linux-registration-evidence/native.mjs "$PWD" after
The hook uses the original two source modules for the before run while leaving surrounding dependencies identical. The after run uses the checkout modules. registration-before.json and registration-after.json are the captured structured output (service log lines omitted). changedFiles compares native mtimes and sizes; syncMutations intercepts pre-ready write/copy APIs; commands records actual native spawns delegated to NodeServices. There is no mocked helper success in this fixture.
Observed repeat: base runs update-desktop-database + xdg-mime default and changes the entry, icon, cache and mimeapps.list. Head launches neither helper and changes none of those files. Initial registration and missing-cache/default, changed-icon and stale-executable repair appear in both transcripts.
The two new regression cases failed against the original implementation: second-launch entry write count 1 rather than 0, and repeated MIME helpers present rather than absent. The focused command passes 23 tests after the fix:
vp test run apps/desktop/src/app/DesktopPreReadyPlatform.test.ts apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
Limits: fixture proof, not a full AppImage or desktop-session test; no GNOME/Wayland, KDE/LXQt live session or x64 runtime test. KDE/LXQt keep the default-handler setter. Missing/unsupported MIME cache tools preserve the existing repair attempts. Local/remote/relay/tunnel paths and wire contracts are untouched. No architecture-specific code was added. Timing is noisy during parallel repository checks; no full-app latency or memory savings are claimed.
note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.
RUN v5.0.5 /home/sonance/.t3/worktrees/t3code/t3-7823770f
stdout | src/app/DesktopPreReadyPlatform.test.ts > DesktopPreReadyPlatform > leaves an identical pre-ready entry and icon untouched across launches
[18:07:51.213] ERROR (#1): Error [AssertionError]: expected 1 to equal +0
at /home/sonance/.t3/worktrees/t3code/t3-7823770f/apps/desktop/src/app/DesktopPreReadyPlatform.test.ts:189:14 {
actual: 1,
expected: 0,
showDiff: true,
operator: 'strictEqual',
[cause]: undefined
}
❯ |@t3tools/desktop| src/app/DesktopPreReadyPlatform.test.ts (6 tests | 1 failed | 5 skipped) 120ms
❯ DesktopPreReadyPlatform (6)
× leaves an identical pre-ready entry and icon untouched across launches 110ms
stdout | src/app/DesktopLinuxUrlHandler.test.ts > DesktopLinuxUrlHandler > skips current MIME registration but repairs missing and stale caches and defaults
[18:07:51.935] ERROR (#4): Error [AssertionError]: expected [ 'update-desktop-database', …(1) ] to deeply equal [ 'query' ]
at /home/sonance/.t3/worktrees/t3code/t3-7823770f/apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts:264:14 {
actual: [ 'update-desktop-database', 'xdg-mime' ],
expected: [ 'query' ],
showDiff: true,
operator: 'deepStrictEqual',
[cause]: undefined
}
stdout | src/app/DesktopLinuxUrlHandler.test.ts
Downloading Electron binary...
❯ |@t3tools/desktop| src/app/DesktopLinuxUrlHandler.test.ts (17 tests | 1 failed | 16 skipped) 60ms
❯ DesktopLinuxUrlHandler (12)
× skips current MIME registration but repairs missing and stale caches and defaults 59ms
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
FAIL |@t3tools/desktop| src/app/DesktopLinuxUrlHandler.test.ts > DesktopLinuxUrlHandler > skips current MIME registration but repairs missing and stale caches and defaults
AssertionError: expected [ 'update-desktop-database', …(1) ] to deeply equal [ 'query' ]
- Expected
+ Received
[
- "query",
+ "update-desktop-database",
+ "xdg-mime",
]
❯ src/app/DesktopLinuxUrlHandler.test.ts:264:14
262| commands.length = 0;
263| yield* register;
264| assert.deepEqual(commands, ["query"]);
| ^
265| assert.equal(Option.getOrThrow((yield* fs.stat(entry)).mtime).ge…
266| assert.equal(Option.getOrThrow((yield* fs.stat(target)).mtime).g…
❯ ~effect/Effect/successCont ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:1482:28
❯ ~effect/Effect/evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/core.ts:587:30
❯ FiberImpl.runLoop ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:700:41
❯ FiberImpl.evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:635:23
❯ FiberImpl.evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:624:29
❯ ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:1210:17
❯ ../../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@effect/platform-node-shared/src/NodeFileSystem.ts:736:11
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL |@t3tools/desktop| src/app/DesktopPreReadyPlatform.test.ts > DesktopPreReadyPlatform > leaves an identical pre-ready entry and icon untouched across launches
AssertionError: expected 1 to equal +0
- Expected
+ Received
- 0
+ 1
❯ src/app/DesktopPreReadyPlatform.test.ts:189:14
187| copyFileSyncMock.mockClear();
188| yield* DesktopPreReadyPlatform.make;
189| assert.equal(writeFileSyncMock.mock.calls.length, 0);
| ^
190| assert.equal(copyFileSyncMock.mock.calls.length, 0);
191| assert.equal(setDesktopNameMock.mock.calls.length, 2);
❯ ~effect/Effect/successCont ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:1482:28
❯ ~effect/Effect/evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/core.ts:587:30
❯ FiberImpl.runLoop ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:700:41
❯ FiberImpl.evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:635:23
❯ ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:5755:9
❯ ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:5833:19
❯ Module.<anonymous> ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:5852:5
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
Test Files 2 failed (2)
Tests 2 failed | 21 skipped (23)
Start at 18:07:26
Duration 25.55s (transform 79%, import 18%, setup 3%)
import { createRequire, registerHooks } from 'node:module';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
const repo=process.argv[2];
const root=fs.mkdtempSync(path.join(os.tmpdir(),'t3-registration-native-'));
const data=path.join(root,'custom-data'), config=path.join(root,'custom-config');
fs.mkdirSync(config,{recursive:true});
for(const [k,v] of Object.entries({HOME:root,XDG_DATA_HOME:data,XDG_CONFIG_HOME:config,XDG_DATA_DIRS:path.join(root,'system-data'),XDG_CONFIG_DIRS:path.join(root,'system-config'),XDG_CURRENT_DESKTOP:'X-Generic',DE:'generic',APPIMAGE:'/usr/bin/true',VITE_DEV_SERVER_URL:'',T3CODE_HOME:path.join(root,'t3')})) process.env[k]=v;
delete process.env.DISPLAY; delete process.env.WAYLAND_DISPLAY;
const appRoot=path.join(root,'bundle'); const iconSource=path.join(appRoot,'apps/desktop/prod-resources/icon.png');
fs.mkdirSync(path.dirname(iconSource),{recursive:true});fs.copyFileSync(path.join(repo,'assets/prod/black-universal-1024.png'),iconSource);
registerHooks({load(url,ctx,next){if(process.argv[3]==='before'){for(const [file,base] of [['DesktopPreReadyPlatform','Pre'],['DesktopLinuxUrlHandler','Handler']]){if(url===new URL('file://'+path.join(repo,'apps/desktop/src/app',file+'.ts')).href)return {format:'module-typescript',source:fs.readFileSync('/tmp/t3-linux-registration-evidence/base-'+base+'.ts','utf8'),shortCircuit:true};}} return next(url,ctx);},resolve(specifier,ctx,next){ if(specifier==='electron') return {url:'data:text/javascript,'+encodeURIComponent(`export const app={isPackaged:true,getAppPath:()=>${JSON.stringify(appRoot)},getVersion:()=>"0.0.37",setDesktopName:()=>{},commandLine:{hasSwitch:()=>false,getSwitchValue:()=>"",appendSwitch:()=>{}}}; export const protocol={registerSchemesAsPrivileged:()=>{}};`),shortCircuit:true};return next(specifier,ctx);}});
const require=createRequire(path.join(repo,'apps/desktop/package.json'));
const load=(s)=>s.startsWith('@t3tools/') ? import(path.join(repo,'packages/shared/src/HostProcess.ts')) : import(require.resolve(s));
const [Effect,Layer,Option,Path,Host,NS,Spawner,Pre,Handler,Env,Assets]=await Promise.all(['effect/Effect','effect/Layer','effect/Option','effect/Path','@t3tools/shared/HostProcess','@effect/platform-node/NodeServices','effect/process/ChildProcessSpawner'].map(load).concat(['DesktopPreReadyPlatform','DesktopLinuxUrlHandler','DesktopEnvironment','DesktopAssets'].map(s=>import(path.join(repo,'apps/desktop/src/app',s+'.ts')))));
const applications=path.join(data,'applications'), entry=path.join(applications,'com.t3tools.T3Code.desktop'), icon=path.join(data,'icons/com.t3tools.T3Code.desktop.png'), cache=path.join(applications,'mimeinfo.cache'), defaults=path.join(config,'mimeapps.list');
const commands=[];
let mutations=[];
for (const method of ['writeFileSync','copyFileSync']) { const real=fs[method];fs[method]=function(...args){mutations.push(method+':'+path.relative(root,method==='copyFileSync'?args[1]:args[0]));return real.apply(this,args);}; }
// Builtin named exports used by the services must see the instrumented functions.
(await import('node:module')).syncBuiltinESMExports();
const program=Effect.gen(function*(){
const real=yield* Spawner.ChildProcessSpawner;const nativePath=yield* Path.Path;
const layer=Handler.layer.pipe(Layer.provide(Layer.mergeAll(
Layer.succeed(Env.DesktopEnvironment,{platform:'linux',isPackaged:true,isDevelopment:false,displayName:'T3 Code (Beta)',linuxDesktopEntryName:'com.t3tools.T3Code.desktop',linuxApplicationsDir:applications,desktopLauncherPath:Option.none(),appImagePath:Option.some('/usr/bin/true'),path:nativePath}),
Layer.succeed(Assets.DesktopAssets,{iconPaths:Effect.succeed({png:Option.some(iconSource),ico:Option.none(),icns:Option.none()}),resolveResourcePath:()=>Effect.succeedNone}),
Layer.succeed(Spawner.ChildProcessSpawner,Spawner.make(cmd=>{commands.push([cmd.command,...cmd.args].join(' '));return real.spawn(cmd);})),
)));
const launch=Effect.gen(function*(){yield* Pre.make.pipe(Effect.provideService(Host.Platform,'linux'));const handler=yield* Handler.DesktopLinuxUrlHandler.pipe(Effect.provide(layer));yield* handler.register;});
const states=()=>Object.fromEntries([entry,icon,cache,defaults].map(p=>[path.relative(root,p),fs.existsSync(p)?{mtime:fs.statSync(p).mtimeNs?.toString()??fs.statSync(p).mtimeMs,size:fs.statSync(p).size}:null]));
const rows=[];
for(const label of (process.env.BENCH ? ['initial',...Array(30).fill('repeat')] : ['initial','repeat','repeat','missing cache','missing default','changed icon','stale executable'])){
if(label==='missing cache') fs.unlinkSync(cache);
if(label==='missing default') fs.unlinkSync(defaults);
if(label==='changed icon') {const bytes=fs.readFileSync(iconSource);bytes[bytes.length-1]^=1;fs.writeFileSync(iconSource,bytes);}
if(label==='stale executable') fs.writeFileSync(entry,fs.readFileSync(entry,'utf8').replace('/usr/bin/true','/deleted.AppImage'));
commands.length=0;mutations=[];const before=states();const start=performance.now();yield* launch;const ms=performance.now()-start;const after=states();
rows.push({label,ms:+ms.toFixed(3),commands:commands.map(c=>c.replaceAll(root,'<fixture>')),syncMutations:[...mutations],changedFiles:Object.keys(after).filter(k=>JSON.stringify(before[k])!==JSON.stringify(after[k]))});
}
console.log(JSON.stringify({node:process.version,arch:process.arch,platform:process.platform,iconBytes:fs.statSync(iconSource).size,rows},null,2));
});
try{await Effect.runPromise(program.pipe(Effect.provide(NS.layer)));}finally{fs.rmSync(root,{recursive:true,force:true});}
{
"node": "v26.12.1",
"arch": "arm64",
"platform": "linux",
"iconBytes": 549578,
"rows": [
{
"label": "initial",
"ms": 185.417,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"writeFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "repeat",
"ms": 5.042,
"commands": [],
"syncMutations": [],
"changedFiles": []
},
{
"label": "repeat",
"ms": 4.059,
"commands": [],
"syncMutations": [],
"changedFiles": []
},
{
"label": "missing cache",
"ms": 29.111,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [],
"changedFiles": [
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "missing default",
"ms": 62.009,
"commands": [
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [],
"changedFiles": [
"custom-config/mimeapps.list"
]
},
{
"label": "changed icon",
"ms": 35.073,
"commands": [],
"syncMutations": [
"writeFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png"
],
"changedFiles": [
"custom-data/icons/com.t3tools.T3Code.desktop.png"
]
},
{
"label": "stale executable",
"ms": 101.706,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
}
]
}
{
"node": "v26.12.1",
"arch": "arm64",
"platform": "linux",
"iconBytes": 549578,
"rows": [
{
"label": "initial",
"ms": 88.324,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "repeat",
"ms": 82.26,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "repeat",
"ms": 108.866,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "missing cache",
"ms": 54.491,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "missing default",
"ms": 48.093,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "changed icon",
"ms": 31.943,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
},
{
"label": "stale executable",
"ms": 38.326,
"commands": [
"update-desktop-database <fixture>/custom-data/applications",
"xdg-mime default com.t3tools.T3Code.desktop x-scheme-handler/t3code"
],
"syncMutations": [
"copyFileSync:custom-data/icons/com.t3tools.T3Code.desktop.png",
"writeFileSync:custom-data/applications/com.t3tools.T3Code.desktop"
],
"changedFiles": [
"custom-data/applications/com.t3tools.T3Code.desktop",
"custom-data/icons/com.t3tools.T3Code.desktop.png",
"custom-data/applications/mimeinfo.cache",
"custom-config/mimeapps.list"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment