Skip to content

Commit f58f695

Browse files
bug fixes (switching pcs)
1 parent 274a25f commit f58f695

File tree

5 files changed

+97
-45
lines changed

5 files changed

+97
-45
lines changed

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@
2121
"@emotion/styled": "^11.14.1",
2222
"@heroicons/react": "^2.2.0",
2323
"@hono/node-server": "^1.19.6",
24-
"@mercuryworkshop/bare-mux": "^2.1.7",
24+
"@mercuryworkshop/bare-mux": "^2.1.8",
2525
"@mercuryworkshop/epoxy-transport": "^2.1.28",
26-
"@mercuryworkshop/libcurl-transport": "^1.5.1",
26+
"@mercuryworkshop/libcurl-transport": "^1.5.2",
2727
"@mercuryworkshop/scramjet": "https://cdn.terbiumon.top/scramjet-v2.0-alpha.tgz",
2828
"@mercuryworkshop/wisp-js": "^0.4.0",
2929
"@paralleldrive/cuid2": "^3.0.4",
3030
"@tailwindcss/postcss": "^4.1.17",
31-
"@terbiumos/tfs": "1.0.18",
31+
"@terbiumos/tfs": "1.0.19",
3232
"@titaniumnetwork-dev/ultraviolet": "^3.2.10",
3333
"@webcontainer/api": "^1.6.1",
34-
"better-auth": "^1.4.1",
34+
"better-auth": "^1.4.4",
3535
"compressorjs": "^1.2.1",
3636
"consola": "^3.4.2",
3737
"cropperjs": "1.6.2",
3838
"crypto-js": "^4.2.0",
3939
"dotenv": "^17.2.3",
4040
"fflate": "^0.8.2",
41-
"hono": "^4.10.6",
41+
"hono": "^4.10.7",
4242
"isomorphic-git": "^1.35.1",
43-
"libcurl.js": "^0.7.3",
43+
"libcurl.js": "^0.7.4",
4444
"open": "^11.0.0",
4545
"path-browserify": "^1.0.1",
4646
"postcss": "^8.5.6",
4747
"react": "^19.2.0",
4848
"react-dom": "^19.2.0",
49-
"tsx": "^4.20.6",
49+
"tsx": "^4.21.0",
5050
"vite-plugin-static-copy": "^3.1.4",
51-
"zustand": "5.0.8"
51+
"zustand": "5.0.9"
5252
},
5353
"devDependencies": {
54-
"@biomejs/biome": "2.3.7",
54+
"@biomejs/biome": "2.3.8",
5555
"@eslint/js": "^9.39.1",
5656
"@types/node": "^24.10.1",
5757
"@types/path-browserify": "^1.0.3",
@@ -66,8 +66,8 @@
6666
"htmlparser2": "^10.0.0",
6767
"tailwindcss": "^4.1.17",
6868
"typescript": "^5.9.3",
69-
"typescript-eslint": "^8.48.0",
70-
"vite": "^7.2.4"
69+
"typescript-eslint": "^8.48.1",
70+
"vite": "^7.2.6"
7171
},
7272
"pnpm": {
7373
"onlyBuiltDependencies": [

public/apps/settings.tapp/index.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ permEl.addEventListener("click", async () => {
617617
sudo: true,
618618
title: "Authenticate to change your permissions",
619619
defaultUsername: sessionStorage.getItem("currAcc"),
620-
onOk: async (username, password) => {
620+
onOk: async (_username, password) => {
621621
const pass = await tb.crypto(password);
622622
if (pass === data["password"]) {
623623
await tb.dialog.Select({
@@ -674,6 +674,37 @@ actype.addEventListener("click", async () => {
674674
case "cloud":
675675
const res = await window.parent.tb.tauth.signIn();
676676
actype.innerHTML = "Terbium Cloud\u2122 Account";
677+
window.parent.tb.fs.readFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, "utf8", async (err, data) => {
678+
if (err) return console.log(err);
679+
data = JSON.parse(data);
680+
data["username"] = res.data.user.name;
681+
await window.parent.tb.fs.promises.writeFile(`/home/${sessionStorage.getItem("currAcc")}/user.json`, JSON.stringify(data));
682+
let desktopDat = JSON.parse(await window.parent.tb.fs.promises.readFile(`/home/${sessionStorage.getItem("currAcc")}/desktop/.desktop.json`, "utf8"));
683+
desktopDat = desktopDat.map(entry => {
684+
entry.item = entry.item.replace(`/home/${sessionStorage.getItem("currAcc")}/`, `/home/${res.data.user.name}/`);
685+
return entry;
686+
});
687+
await window.parent.tb.fs.promises.rename(`/home/${sessionStorage.getItem("currAcc")}`, `/home/${res.data.user.name}`);
688+
await window.parent.tb.fs.promises.writeFile(`/home/${res.data.user.name}/desktop/.desktop.json`, JSON.stringify(desktopDat));
689+
await window.parent.tb.fs.promises.rename(`/apps/user/${sessionStorage.getItem("currAcc")}`, `/apps/user/${res.data.user.name}`);
690+
window.parent.tb.fs.readFile("/system/etc/terbium/settings.json", "utf8", async (err, data) => {
691+
if (err) return console.log(err);
692+
data = JSON.parse(data);
693+
data["defaultUser"] = res.data.user.name;
694+
await window.parent.tb.fs.promises.writeFile("/system/etc/terbium/settings.json", JSON.stringify(data));
695+
});
696+
const fcfg = JSON.parse(await window.parent.tb.fs.promises.readFile(`/apps/user/${res.data.user.name}/files/config.json`, "utf8"));
697+
fcfg.drives["File System"] = `/home/${res.data.user.name}/`;
698+
await window.parent.tb.fs.promises.writeFile(`/apps/user/${res.data.user.name}/files/config.json`, JSON.stringify(fcfg));
699+
const qcfg = JSON.parse(await window.parent.tb.fs.promises.readFile(`/apps/user/${res.data.user.name}/files/quick-center.json`, "utf8"));
700+
for (const key in qcfg.paths) {
701+
if (Object.prototype.hasOwnProperty.call(qcfg.paths, key)) {
702+
qcfg.paths[key] = qcfg.paths[key].replace(sessionStorage.getItem("currAcc"), res.data.user.name);
703+
}
704+
}
705+
await window.parent.tb.fs.promises.writeFile(`/apps/user/${res.data.user.name}/files/quick-center.json`, JSON.stringify(qcfg));
706+
sessionStorage.setItem("currAcc", res.data.user.name);
707+
});
677708
window.parent.tb.system.users.update({
678709
username: res.data.user.name,
679710
pfp: res.data.user.image,
@@ -689,7 +720,7 @@ actype.addEventListener("click", async () => {
689720
});
690721

691722
window.parent.tb.fs.readFile(`/system/etc/terbium/taccs.json`, "utf8", (err, data) => {
692-
if (err) return console.log(err);
723+
if (err) actype.innerHTML = "Local Account";
693724
const entries = JSON.parse(data);
694725
const act = sessionStorage.getItem("currAcc");
695726
try {

src/sys/Api.ts

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -555,24 +555,24 @@ export default async function Api() {
555555
return users;
556556
},
557557
async add(user: User) {
558-
const { username, password, pfp, perm, securityQuestion, window } = user;
558+
const { username, password, pfp, perm, securityQuestion, window: userWinopts } = user;
559559
const userDir = `/home/${username}`;
560-
await parent.tb.fs.promises.mkdir(userDir);
560+
await window.tb.fs.promises.mkdir(userDir);
561561
const userJson: User = {
562562
id: username,
563563
username: username,
564564
password: password,
565565
pfp: pfp,
566566
perm: perm,
567-
window: window,
567+
window: userWinopts,
568568
};
569569
if (securityQuestion) {
570570
userJson.securityQuestion = {
571571
question: securityQuestion.question,
572572
answer: securityQuestion.answer,
573573
};
574574
}
575-
await parent.tb.fs.promises.writeFile(`${userDir}/user.json`, JSON.stringify(userJson));
575+
await window.tb.fs.promises.writeFile(`${userDir}/user.json`, JSON.stringify(userJson));
576576
const userSettings = {
577577
wallpaper: "/assets/wallpapers/1.png",
578578
wallpaperMode: "cover",
@@ -588,14 +588,14 @@ export default async function Api() {
588588
showSeconds: false,
589589
},
590590
};
591-
await parent.tb.fs.promises.writeFile(`${userDir}/settings.json`, JSON.stringify(userSettings));
591+
await window.tb.fs.promises.writeFile(`${userDir}/settings.json`, JSON.stringify(userSettings));
592592
const defaultDirs = ["desktop", "documents", "downloads", "music", "pictures", "videos"];
593593
defaultDirs.forEach(async dir => {
594-
await parent.tb.fs.promises.mkdir(`${userDir}/${dir}`);
594+
await window.tb.fs.promises.mkdir(`${userDir}/${dir}`);
595595
});
596-
await parent.tb.fs.promises.mkdir(`/apps/user/${username}`);
597-
await parent.tb.fs.promises.mkdir(`/apps/user/${username}/files`);
598-
await parent.tb.fs.promises.writeFile(
596+
await window.tb.fs.promises.mkdir(`/apps/user/${username}`);
597+
await window.tb.fs.promises.mkdir(`/apps/user/${username}/files`);
598+
await window.tb.fs.promises.writeFile(
599599
`/apps/user/${username}/files/config.json`,
600600
JSON.stringify({
601601
"quick-center": true,
@@ -614,11 +614,11 @@ export default async function Api() {
614614
}),
615615
"utf8",
616616
);
617-
await parent.tb.fs.promises.writeFile(`/apps/user/${username}/files/davs.json`, JSON.stringify([]));
617+
await window.tb.fs.promises.writeFile(`/apps/user/${username}/files/davs.json`, JSON.stringify([]));
618618
const response = await fetch("/apps/files.tapp/icons.json");
619619
const dat = await response.json();
620-
await parent.tb.fs.promises.writeFile(`/apps/user/${username}/files/icns.json`, JSON.stringify(dat));
621-
await parent.tb.fs.promises.writeFile(
620+
await window.tb.fs.promises.writeFile(`/apps/user/${username}/files/icns.json`, JSON.stringify(dat));
621+
await window.tb.fs.promises.writeFile(
622622
`/apps/user/${username}/files/quick-center.json`,
623623
JSON.stringify({
624624
paths: {
@@ -668,10 +668,10 @@ export default async function Api() {
668668
left: leftPos,
669669
},
670670
});
671-
await parent.tb.fs.promises.symlink(`/apps/system/${name}.tapp/index.json`, `/home/${username}/desktop/${name}.lnk`);
671+
await window.tb.fs.promises.symlink(`/apps/system/${name}.tapp/index.json`, `/home/${username}/desktop/${name}.lnk`);
672672
}
673-
await parent.tb.fs.promises.writeFile(`/home/${username}/desktop/.desktop.json`, JSON.stringify(items));
674-
await parent.tb.fs.promises.writeFile(
673+
await window.tb.fs.promises.writeFile(`/home/${username}/desktop/.desktop.json`, JSON.stringify(items));
674+
await window.tb.fs.promises.writeFile(
675675
`/apps/user/${username}/app store/repos.json`,
676676
JSON.stringify([
677677
{
@@ -744,10 +744,10 @@ export default async function Api() {
744744
return true;
745745
},
746746
async update(user: User) {
747-
const { username, password, pfp, perm, securityQuestion, window } = user;
747+
const { username, password, pfp, perm, securityQuestion, window: userwinOpts } = user;
748748
const userDir = `/home/${username}`;
749-
const userConfig = JSON.parse(await parent.tb.fs.promises.readFile(`${userDir}/user.json`, "utf8"));
750-
await parent.tb.fs.promises.writeFile(
749+
const userConfig = JSON.parse(await window.tb.fs.promises.readFile(`${userDir}/user.json`, "utf8"));
750+
await window.tb.fs.promises.writeFile(
751751
`${userDir}/user.json`,
752752
JSON.stringify({
753753
id: userConfig.id,
@@ -756,10 +756,10 @@ export default async function Api() {
756756
pfp: pfp === userConfig.pfp ? userConfig.pfp : pfp,
757757
perm: perm === userConfig.perm ? userConfig.perm : perm,
758758
window: {
759-
winAccent: window.winAccent === userConfig.window.winAccent ? userConfig.window.winAccent : "#ffffff",
760-
blurlevel: window.blurlevel === userConfig.window.blurlevel ? userConfig.window.blurlevel : 0,
761-
alwaysMaximized: window.alwaysMaximized === userConfig.window.alwaysMaximized ? userConfig.window.alwaysMaximized : false,
762-
alwaysFullscreen: window.alwaysFullscreen === userConfig.window.alwaysFullscreen ? userConfig.window.alwaysFullscreen : false,
759+
winAccent: userwinOpts?.winAccent ?? userConfig.window?.winAccent ?? "#ffffff",
760+
blurlevel: userwinOpts?.blurlevel ?? userConfig.window?.blurlevel ?? 18,
761+
alwaysMaximized: userwinOpts?.alwaysMaximized ?? userConfig.window?.alwaysMaximized ?? false,
762+
alwaysFullscreen: userwinOpts?.alwaysFullscreen ?? userConfig.window?.alwaysFullscreen ?? false,
763763
},
764764
...(securityQuestion !== undefined ? { securityQuestion: securityQuestion === userConfig.securityQuestion ? userConfig.securityQuestion : securityQuestion } : userConfig.securityQuestion !== undefined ? { securityQuestion: userConfig.securityQuestion } : {}),
765765
}),
@@ -807,6 +807,10 @@ export default async function Api() {
807807
password: password,
808808
fetchOptions: {
809809
onSuccess: async response => {
810+
const exists = await window.tb.fs.promises.exists("/system/etc/terbium/taccs.json");
811+
if (!exists) {
812+
await window.tb.fs.promises.writeFile("/system/etc/terbium/taccs.json", JSON.stringify([], null, 2), "utf8");
813+
}
810814
const conf = JSON.parse(await window.tb.fs.promises.readFile("/system/etc/terbium/taccs.json", "utf8"));
811815
conf.push({
812816
username: response.data.user.name,
@@ -860,8 +864,11 @@ export default async function Api() {
860864
updateInfo: async (user: Partial<User>) => {
861865
const target = (user as any).id || user.username || sessionStorage.getItem("currAcc");
862866
if (!target) throw new Error("No target account specified");
863-
const raw = await window.tb.fs.promises.readFile("/system/etc/terbium/taccs.json", "utf8");
864-
let conf: any = JSON.parse(raw);
867+
let conf = JSON.parse(await window.tb.fs.promises.readFile("/system/etc/terbium/taccs.json", "utf8"));
868+
const exists = await window.tb.fs.promises.exists("/system/etc/terbium/taccs.json");
869+
if (!exists) {
870+
await window.tb.fs.promises.writeFile("/system/etc/terbium/taccs.json", JSON.stringify([], null, 2), "utf8");
871+
}
865872
if (!Array.isArray(conf)) {
866873
if (conf && typeof conf === "object") conf = Object.values(conf);
867874
else conf = [];
@@ -881,6 +888,7 @@ export default async function Api() {
881888
email: updated.email,
882889
image: updated.pfp,
883890
};
891+
console.log("Updating TAuth user info:", obj);
884892
try {
885893
await window.tb.tauth.client.updateUser(obj);
886894
} catch (e) {
@@ -974,7 +982,6 @@ export default async function Api() {
974982
// @ts-expect-error
975983
const stream = await navigator.mediaDevices.getDisplayMedia({ preferCurrentTab: true });
976984
const capture = new ImageCapture(stream.getVideoTracks()[0]);
977-
// @ts-expect-error
978985
const frame = await capture.grabFrame();
979986
stream.getVideoTracks()[0].stop();
980987
const canvas: HTMLCanvasElement = document.createElement("canvas");

src/sys/gui/WindowArea.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,16 @@ const WindowElement: React.FC<WindowProps> = ({ className, config, onSnapDone, o
103103
ExternalApp: window.parent.ExternalApp,
104104
ExternalLib: window.parent.ExternalLib,
105105
Filer: window.parent.Filer,
106-
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
107106
});
107+
const aInstanceInt = setInterval(() => {
108+
Object.assign(srcRef.current?.contentWindow as typeof window, {
109+
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
110+
});
111+
if (window.anura.wm.getWeakRef(Number(config.pid)) !== undefined) {
112+
clearInterval(aInstanceInt);
113+
}
114+
}, 1);
108115
} else {
109-
console.log("no proxy", window.anura.wm.getWeakRef(Number(config.pid)));
110116
Object.assign(srcRef.current?.contentWindow as typeof window, {
111117
tb: window.parent.tb,
112118
anura: window.parent.anura,
@@ -115,8 +121,16 @@ const WindowElement: React.FC<WindowProps> = ({ className, config, onSnapDone, o
115121
ExternalApp: window.parent.ExternalApp,
116122
ExternalLib: window.parent.ExternalLib,
117123
Filer: window.parent.Filer,
118-
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
124+
instanceWindow: {},
119125
});
126+
const aInstanceInt = setInterval(() => {
127+
Object.assign(srcRef.current?.contentWindow as typeof window, {
128+
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
129+
});
130+
if (window.anura.wm.getWeakRef(Number(config.pid)) !== undefined) {
131+
clearInterval(aInstanceInt);
132+
}
133+
}, 1);
120134
}
121135
};
122136
prox();
@@ -137,7 +151,7 @@ const WindowElement: React.FC<WindowProps> = ({ className, config, onSnapDone, o
137151
Filer: window.parent.Filer,
138152
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
139153
});
140-
}, 500);
154+
}, 100);
141155
}
142156
}
143157
};
@@ -236,7 +250,7 @@ const WindowElement: React.FC<WindowProps> = ({ className, config, onSnapDone, o
236250
Filer: window.parent.Filer,
237251
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
238252
});
239-
}, 500);
253+
}, 250);
240254
}
241255
},
242256
},
@@ -266,7 +280,7 @@ const WindowElement: React.FC<WindowProps> = ({ className, config, onSnapDone, o
266280
Filer: window.parent.Filer,
267281
instanceWindow: window.anura.wm.getWeakRef(Number(config.pid)),
268282
});
269-
}, 500);
283+
}, 250);
270284
}
271285
}
272286
};

src/sys/liquor/api/WmApi.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class WMAPI {
9494
for (const ref of this.windows) {
9595
const r = ref.deref();
9696
if (!r) continue;
97-
if (r.pid === pid) return r;
97+
if (Number(r.pid) === pid) return r;
9898
}
9999
}
100100
}

0 commit comments

Comments
 (0)