desktop-pet-app 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/main/index.js +17 -4
  2. package/package.json +1 -1
package/out/main/index.js CHANGED
@@ -246,6 +246,9 @@ function sleep(ms) {
246
246
  function isPetOnQuest(petId) {
247
247
  return busy.has(petId);
248
248
  }
249
+ function canSendAwayPet(identity) {
250
+ return identity.kind === "remote-friend";
251
+ }
249
252
  function presentPetIdentity(identity, localUsername) {
250
253
  if (identity.kind === "remote-friend") {
251
254
  return {
@@ -274,6 +277,11 @@ class PetManager {
274
277
  count() {
275
278
  return this.pets.size;
276
279
  }
280
+ hasPrimaryPet() {
281
+ return [...this.pets.values()].some(
282
+ (pet) => !pet.win.isDestroyed() && pet.identity.kind === "primary"
283
+ );
284
+ }
277
285
  findRemoteFriend(username) {
278
286
  const normalized = username.trim().toLowerCase();
279
287
  return [...this.pets.values()].find(
@@ -2087,7 +2095,7 @@ function createPetWindow(skin, options) {
2087
2095
  submenu: updateMenuItems(id)
2088
2096
  },
2089
2097
  { type: "separator" },
2090
- { label: "送走这只宠物", click: () => win.close() },
2098
+ ...canSendAwayPet(identity) ? [{ label: "送走这只宠物", click: () => win.close() }] : [],
2091
2099
  { label: "退出", click: () => electron.app.quit() }
2092
2100
  ]);
2093
2101
  menu.popup({ window: win });
@@ -2997,6 +3005,13 @@ if (!singleInstance) {
2997
3005
  electron.app.on("second-instance", (_event, argv) => {
2998
3006
  const callback = argv.find((value) => value.startsWith("desktop-pet://"));
2999
3007
  if (callback) handleAccountCallback(callback);
3008
+ ensurePrimaryPet();
3009
+ });
3010
+ }
3011
+ function ensurePrimaryPet() {
3012
+ if (petManager.hasPrimaryPet()) return null;
3013
+ return createPetWindow(process.env.DESKTOP_PET_SKIN || "codex", {
3014
+ identity: { kind: "primary" }
3000
3015
  });
3001
3016
  }
3002
3017
  electron.app.whenReady().then(async () => {
@@ -3009,9 +3024,7 @@ electron.app.whenReady().then(async () => {
3009
3024
  if (!activated) startRelay();
3010
3025
  if (process.env.DESKTOP_PET_P2P !== "0") startP2PWindow(getDeviceIceServers());
3011
3026
  void startRunnerManager();
3012
- const id = createPetWindow(process.env.DESKTOP_PET_SKIN || "codex", {
3013
- identity: { kind: "primary" }
3014
- });
3027
+ const id = ensurePrimaryPet();
3015
3028
  setTimeout(() => {
3016
3029
  void checkForUpdates().then((result) => {
3017
3030
  if (id && result.kind === "available") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "desktop-pet-app",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "AI desktop pet with MCP support and a self-hosted relay server",
5
5
  "license": "MIT",
6
6
  "keywords": [