From 1a04f855b54f39b59242eb86c69b17a768b625ac Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:30:13 +0800 Subject: [PATCH 01/15] fix(downloads): prompt for a fresh sign-in when Store AMD state is missing ipatool 2.8.1 provisions Store AMD state during auth login; sessions from an older engine still search and list purchases, but downloads fail with an opaque error. Surface it as a re-login prompt and open the sign-in dialog. --- src/renderer/src/i18n/en.ts | 3 +++ src/renderer/src/i18n/zh.ts | 3 +++ src/renderer/src/store/queue.ts | 22 +++++++++++++++++----- src/shared/ipatool/errors.ts | 9 +++++++++ tests/errors.test.ts | 17 ++++++++++++++++- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/i18n/en.ts b/src/renderer/src/i18n/en.ts index 1d448b2..0e96f4f 100644 --- a/src/renderer/src/i18n/en.ts +++ b/src/renderer/src/i18n/en.ts @@ -470,6 +470,9 @@ export const en = { 'toast.downloadStarted': 'Download started', 'toast.downloadDone': '{name} downloaded', 'toast.downloadFailed': '{name} failed', + 'toast.reloginRequired': 'Sign in again to enable downloads', + 'toast.reloginRequiredDetail': + 'ipatool 2.8.1 needs to provision this session for Store downloads. Sign in with the same Apple ID; your purchases and queue are kept.', 'toast.copied': 'Copied to clipboard', 'toast.saved': 'Saved', 'toast.settingsReset': 'Settings reset to defaults', diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index 670431d..a76a3fa 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -455,6 +455,9 @@ export const zh: Dict = { 'toast.downloadStarted': '开始下载', 'toast.downloadDone': '{name} 下载完成', 'toast.downloadFailed': '{name} 下载失败', + 'toast.reloginRequired': '需要重新登录一次才能下载', + 'toast.reloginRequiredDetail': + 'ipatool 2.8.1 需要为当前会话完成 Store AMD 初始化;用同一个 Apple ID 重新登录即可,已购记录和队列都会保留。', 'toast.copied': '已复制到剪贴板', 'toast.saved': '已保存', 'toast.settingsReset': '设置已恢复默认', diff --git a/src/renderer/src/store/queue.ts b/src/renderer/src/store/queue.ts index 1ec9c3d..e17dfe5 100644 --- a/src/renderer/src/store/queue.ts +++ b/src/renderer/src/store/queue.ts @@ -9,6 +9,7 @@ import { create } from 'zustand' import type { DownloadRequest, QueueItem } from '@shared/types' import type { QueueAction } from '@shared/ipc' +import { isStoreReloginRequired } from '@shared/ipatool/errors' import { computeStats, mergeSnapshot, type QueueStats } from '@renderer/lib/queueMerge' import { progressBus } from '@renderer/lib/progressBus' import { useUiStore } from './ui' @@ -139,11 +140,22 @@ export const useQueueStore = create()((set, get) => ({ : {}) }) } else if (item.state === 'error') { - useUiStore.getState().toast({ - kind: 'error', - message: t('toast.downloadFailed', { name: item.name }), - detail: item.error?.message - }) + const detail = item.error?.message + if (isStoreReloginRequired(detail)) { + useUiStore.getState().toast({ + kind: 'error', + message: t('toast.reloginRequired'), + detail: t('toast.reloginRequiredDetail'), + actionLabel: t('auth.signIn'), + onAction: () => useUiStore.getState().setAuthOpen(true) + }) + } else { + useUiStore.getState().toast({ + kind: 'error', + message: t('toast.downloadFailed', { name: item.name }), + detail + }) + } } })) }, diff --git a/src/shared/ipatool/errors.ts b/src/shared/ipatool/errors.ts index a28ec9b..3e60b2d 100644 --- a/src/shared/ipatool/errors.ts +++ b/src/shared/ipatool/errors.ts @@ -312,6 +312,15 @@ export function isPassphraseRequired(...parts: Array) return classifyError(...parts).code === 'passphrase-required' } +/** + * ipatool 2.8.1 added a Store AMD provisioning step to downloads. A session + * created by an older engine is still signed in - search and purchases work - + * but the download proof cannot be generated until the user logs in again. + */ +export function isStoreReloginRequired(...parts: Array): boolean { + return /store AMD state is not provisioned/i.test(haystack(parts)) +} + /** Truncates very long messages (Apple sometimes returns whole plists). */ export function shorten(message: string, max = 400): string { if (message.length <= max) return message diff --git a/tests/errors.test.ts b/tests/errors.test.ts index 7f02b2c..669a6c7 100644 --- a/tests/errors.test.ts +++ b/tests/errors.test.ts @@ -1,5 +1,11 @@ import { describe, expect, it } from 'vitest' -import { classifyError, isPassphraseRequired, isTwoFactorRequired, shorten } from '@shared/ipatool/errors' +import { + classifyError, + isPassphraseRequired, + isStoreReloginRequired, + isTwoFactorRequired, + shorten +} from '@shared/ipatool/errors' describe('classifyError', () => { it('recognises the non-interactive 2FA signal ipatool logs on success', () => { @@ -24,6 +30,15 @@ describe('classifyError', () => { expect(classifyError('failed to decrypt keyring item').code).toBe('passphrase-invalid') }) + it('recognises a session that needs Store AMD provisioning again', () => { + // ipatool 2.8.1 emits this while the account is still signed in; searches + // and purchases work, but downloads need a fresh auth login. + const log = + 'failed to send http request: generate Store AMD proof: store AMD state is not provisioned; run \'ipatool auth login\' to authenticate' + expect(isStoreReloginRequired(log)).toBe(true) + expect(isStoreReloginRequired('download failed: disk full')).toBe(false) + }) + it('recognises an unauthenticated session', () => { expect(classifyError('no account found; please login first').code).toBe('not-signed-in') expect(classifyError('received error: SignInRequired').code).toBe('not-signed-in') From dd09e9c36bc85f02b68e5afb44b1e529c82049a2 Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:30:14 +0800 Subject: [PATCH 02/15] fix(engine): use 2.8.1 as the offline fallback --- src/main/engine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/engine.ts b/src/main/engine.ts index 0d405e5..bd1db56 100644 --- a/src/main/engine.ts +++ b/src/main/engine.ts @@ -64,7 +64,7 @@ const REPO_WEB = `https://github.com/${IPATOOL_REPO}` * trick can answer (offline API, blocked mirror, ...). Installing a slightly old * ipatool beats failing to install any. */ -const FALLBACK_VERSION = '2.6.0' +const FALLBACK_VERSION = '2.8.1' interface GhAsset { name: string From d8aa3f69e9b03958660071d5ca743fc95f621e27 Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:30:15 +0800 Subject: [PATCH 03/15] build(linux): drop the redundant linux segment from artifact names --- electron-builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron-builder.yml b/electron-builder.yml index 894571b..db88261 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -112,7 +112,7 @@ linux: category: Utility synopsis: Desktop front-end for ipatool maintainer: ipatool-gui contributors - artifactName: ${name}-${version}-linux-${arch}.${ext} + artifactName: ${name}-${version}-${arch}.${ext} # mksquashfs then defaults to zlib, which the catalog's mount helper supports. compression: normal # ⚠️ Deliberately NO `arch:` here. Once a target declares its own arch list, From 892cce7dc89358a00aa10833d1687f9c9be2b3dd Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:30:15 +0800 Subject: [PATCH 04/15] build(linux): embed AppImage update info and publish zsync AppImageHub and AppImageUpdate expect an .upd_info section and a .zsync beside the AppImage. electron-builder emits neither, so rebuild the AppImage with appimagetool during the release job and checksum the zsync file too. --- .github/workflows/release.yml | 43 ++++++++++++++++++++++++++++++++++- scripts/sha256sums.mjs | 2 +- tests/sha256sums.test.ts | 5 ++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6930def..e7c8e78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ - fakeroot dpkg rpm libarchive-tools + fakeroot dpkg rpm libarchive-tools zsync # Packaging consumes dist/, so it must exist before electron-builder runs. - name: Build app bundle @@ -150,6 +150,46 @@ jobs: # certificate never silently changes the output. CSC_IDENTITY_AUTO_DISCOVERY: 'false' + # electron-builder's AppImage writer does not embed update info and does + # not emit a zsync file, which AppImageHub/AppImageUpdate require. Rebuild + # the AppImage with appimagetool so both are present next to the asset. + - name: Add AppImage update information + if: matrix.platform == 'linux' + run: | + set -euo pipefail + APPIMAGE="$(find release -maxdepth 1 -name '*.AppImage' -print -quit)" + if [ -z "$APPIMAGE" ]; then + echo "::error::electron-builder produced no AppImage" + exit 1 + fi + NAME="$(basename "$APPIMAGE")" + case "${{ matrix.arch }}" in + x64) APPIMAGE_ARCH=x86_64 ;; + arm64) APPIMAGE_ARCH=aarch64 ;; + *) echo "::error::unsupported AppImage architecture"; exit 1 ;; + esac + + TOOL="/tmp/appimagetool-${APPIMAGE_ARCH}.AppImage" + curl -fsSL -o "$TOOL" \ + "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${APPIMAGE_ARCH}.AppImage" + chmod +x "$TOOL" + + ( cd release && "./$NAME" --appimage-extract > /dev/null ) + rm -f "$APPIMAGE" + REPO="${GITHUB_REPOSITORY}" + APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$APPIMAGE_ARCH" "$TOOL" --no-appstream \ + -u "gh-releases-zsync|${REPO%%/*}|${REPO##*/}|latest|ipatool-gui-*-${APPIMAGE_ARCH}.AppImage.zsync" \ + release/squashfs-root "$APPIMAGE" + rm -rf release/squashfs-root + + # appimagetool generates this when zsyncmake is installed; fall back + # to zsyncmake directly so a missing helper cannot silently drop it. + if [ ! -f "${APPIMAGE}.zsync" ]; then + zsyncmake -u "https://github.com/${GITHUB_REPOSITORY}/releases/download/${GITHUB_REF_NAME}/${NAME}.zsync" \ + -o "${APPIMAGE}.zsync" "$APPIMAGE" + fi + ls -lh "$APPIMAGE" "${APPIMAGE}.zsync" + # macOS: turn the unpacked .app into a single runnable archive. - name: Package the .app as a runnable tar.gz if: matrix.platform == 'mac' @@ -259,6 +299,7 @@ jobs: release/*.dmg release/*.app.tar.gz release/*.AppImage + release/*.zsync release/*.deb release/SHA256SUMS.txt if-no-files-found: error diff --git a/scripts/sha256sums.mjs b/scripts/sha256sums.mjs index 3a78eb1..01d6753 100644 --- a/scripts/sha256sums.mjs +++ b/scripts/sha256sums.mjs @@ -23,7 +23,7 @@ import path from 'node:path' import { pathToFileURL } from 'node:url' /** Artifact extensions that ship to users. Intermediate build output is skipped. */ -const ARTIFACT_SUFFIXES = ['.exe', '.dmg', '.app.tar.gz', '.AppImage', '.deb', '.zip'] +const ARTIFACT_SUFFIXES = ['.exe', '.dmg', '.app.tar.gz', '.AppImage', '.deb', '.zip', '.zsync'] export const MANIFEST_NAME = 'SHA256SUMS.txt' diff --git a/tests/sha256sums.test.ts b/tests/sha256sums.test.ts index d086242..33f3a97 100644 --- a/tests/sha256sums.test.ts +++ b/tests/sha256sums.test.ts @@ -57,6 +57,7 @@ describe('artifact selection', () => { 'ipatool-gui-0.1.1-win-x64-portable.exe', 'ipatool-gui-0.1.1-mac-arm64.app.tar.gz', 'ipatool-gui-0.1.1-linux-x86_64.AppImage', + 'ipatool-gui-0.1.1-linux-x86_64.AppImage.zsync', 'ipatool-gui-0.1.1-linux-amd64.deb', 'ipatool-gui-0.1.1-mac-x64.dmg' ] @@ -64,10 +65,10 @@ describe('artifact selection', () => { const result = await run([dir]) expect(result.code).toBe(0) - expect(result.stdout).toContain('6 artifact(s)') + expect(result.stdout).toContain('7 artifact(s)') const lines = await manifestLines() - expect(lines).toHaveLength(6) + expect(lines).toHaveLength(7) // Sorted, so the manifest is stable across runs and diffable. expect(lines.map((line) => line.slice(66))).toEqual([...artifacts].sort()) }) From 4321daa0c8b260b415f95c67e4ed9360c4aa4aff Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:30:23 +0800 Subject: [PATCH 05/15] chore: release 0.3.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9da0d21..8fda861 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ipatool-gui", - "version": "0.3.1", + "version": "0.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ipatool-gui", - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "devDependencies": { "@eslint/js": "9.39.2", diff --git a/package.json b/package.json index b9dec4c..071ae62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ipatool-gui", "productName": "IPATool GUI", - "version": "0.3.1", + "version": "0.3.2", "engines": { "node": ">=20.19" }, From fe4b1194c205a124d3c75ebc253f7c2ae124db17 Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:34:50 +0800 Subject: [PATCH 06/15] build(linux): make the extracted AppDir readable for appimagetool --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7c8e78..7da40ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -175,6 +175,10 @@ jobs: chmod +x "$TOOL" ( cd release && "./$NAME" --appimage-extract > /dev/null ) + # electron-builder's stage directory is 0700; appimagetool (rightly) + # refuses to ship an AppImage that other users cannot read. + chmod -R a+rX release/squashfs-root + chmod a+rx release/squashfs-root/AppRun rm -f "$APPIMAGE" REPO="${GITHUB_REPOSITORY}" APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$APPIMAGE_ARCH" "$TOOL" --no-appstream \ From 013616184b80dc21274eab96e6ba1fcea7406803 Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:39:58 +0800 Subject: [PATCH 07/15] build(linux): extract AppImages without running their runtime --- .github/workflows/release.yml | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7da40ff..b2494ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ - fakeroot dpkg rpm libarchive-tools zsync + fakeroot dpkg rpm libarchive-tools zsync squashfs-tools # Packaging consumes dist/, so it must exist before electron-builder runs. - name: Build app bundle @@ -164,25 +164,45 @@ jobs: fi NAME="$(basename "$APPIMAGE")" case "${{ matrix.arch }}" in - x64) APPIMAGE_ARCH=x86_64 ;; - arm64) APPIMAGE_ARCH=aarch64 ;; + x64) TARGET_ARCH=x86_64 ;; + arm64) TARGET_ARCH=aarch64 ;; *) echo "::error::unsupported AppImage architecture"; exit 1 ;; esac + # appimagetool is itself an AppImage, so run the build for the runner's + # architecture; ARCH selects the target runtime it embeds. + case "$(uname -m)" in + x86_64) TOOL_ARCH=x86_64 ;; + aarch64) TOOL_ARCH=aarch64 ;; + *) echo "::error::unsupported runner architecture"; exit 1 ;; + esac + # This is the suffix electron-builder put in the filename (x86_64 / + # arm64), not the runtime architecture appimagetool wants (x86_64 / + # aarch64); the update-information pattern must match the asset name. + BASE="${NAME%.AppImage}" + FILE_ARCH="${BASE##*-}" - TOOL="/tmp/appimagetool-${APPIMAGE_ARCH}.AppImage" + TOOL="/tmp/appimagetool-${TOOL_ARCH}.AppImage" curl -fsSL -o "$TOOL" \ - "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${APPIMAGE_ARCH}.AppImage" + "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${TOOL_ARCH}.AppImage" chmod +x "$TOOL" - ( cd release && "./$NAME" --appimage-extract > /dev/null ) + # Extract without executing the payload: the arm64 job runs on an x64 + # runner, so running the arm64 AppImage would fail with Exec format. + OFFSET="$(LC_ALL=C grep -abo -m1 'hsqs' "$APPIMAGE" | cut -d: -f1)" + if [ -z "$OFFSET" ]; then + echo "::error::could not locate the SquashFS payload in $APPIMAGE" + exit 1 + fi + rm -rf release/squashfs-root + unsquashfs -o "$OFFSET" -d release/squashfs-root "$APPIMAGE" > /dev/null # electron-builder's stage directory is 0700; appimagetool (rightly) # refuses to ship an AppImage that other users cannot read. chmod -R a+rX release/squashfs-root chmod a+rx release/squashfs-root/AppRun rm -f "$APPIMAGE" REPO="${GITHUB_REPOSITORY}" - APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$APPIMAGE_ARCH" "$TOOL" --no-appstream \ - -u "gh-releases-zsync|${REPO%%/*}|${REPO##*/}|latest|ipatool-gui-*-${APPIMAGE_ARCH}.AppImage.zsync" \ + APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$TARGET_ARCH" "$TOOL" --no-appstream \ + -u "gh-releases-zsync|${REPO%%/*}|${REPO##*/}|latest|ipatool-gui-*-${FILE_ARCH}.AppImage.zsync" \ release/squashfs-root "$APPIMAGE" rm -rf release/squashfs-root From 1df8b72d10efab2d692b65772143102c385b108e Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:48:12 +0800 Subject: [PATCH 08/15] build(linux): use the real SquashFS offset when unpacking AppImages --- .github/workflows/release.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2494ac..e2aa696 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ - fakeroot dpkg rpm libarchive-tools zsync squashfs-tools + fakeroot dpkg rpm libarchive-tools zsync squashfs-tools p7zip-full # Packaging consumes dist/, so it must exist before electron-builder runs. - name: Build app bundle @@ -188,7 +188,9 @@ jobs: # Extract without executing the payload: the arm64 job runs on an x64 # runner, so running the arm64 AppImage would fail with Exec format. - OFFSET="$(LC_ALL=C grep -abo -m1 'hsqs' "$APPIMAGE" | cut -d: -f1)" + # `grep hsqs` also matches strings inside the runtime; use 7z, which + # reports the real SquashFS superblock offset. + OFFSET="$(7z l "$APPIMAGE" 2>/dev/null | sed -n 's/^Offset = //p' | head -n1)" || true if [ -z "$OFFSET" ]; then echo "::error::could not locate the SquashFS payload in $APPIMAGE" exit 1 From 201d93205b0f5db47c0c2ea03e4c51f89805fefb Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 16:53:18 +0800 Subject: [PATCH 09/15] fix(downloads): replace the raw queue error with a re-login prompt The AMD failure was still rendered as a progress/JSON blob in the Downloads row, with the generic network hint. Show the actionable sign-in message there too and add a key button that opens the sign-in dialog. --- src/renderer/src/i18n/en.ts | 2 ++ src/renderer/src/i18n/zh.ts | 2 ++ src/renderer/src/pages/DownloadsView.tsx | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/i18n/en.ts b/src/renderer/src/i18n/en.ts index 0e96f4f..3dc78ea 100644 --- a/src/renderer/src/i18n/en.ts +++ b/src/renderer/src/i18n/en.ts @@ -296,6 +296,8 @@ export const en = { 'downloads.progress.remaining': '{eta} left', 'downloads.progress.done': 'Complete', 'downloads.resumeHint': 'Paused downloads keep their partial file and resume where they stopped.', + 'downloads.reloginRequired': 'Sign in again before downloading', + 'downloads.reloginHint': 'Use the same Apple ID; your queue and purchases are kept.', 'downloads.deletePartial.title': 'Discard the partial file?', 'downloads.deletePartial.body': 'The next attempt will start from zero bytes. Use this when Apple rejects the resume range (HTTP 416) after a long pause.', diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index a76a3fa..74edb66 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -287,6 +287,8 @@ export const zh: Dict = { 'downloads.progress.remaining': '剩余 {eta}', 'downloads.progress.done': '完成', 'downloads.resumeHint': '暂停会保留未完成文件,继续时从断点接着下。', + 'downloads.reloginRequired': '需要重新登录一次才能下载', + 'downloads.reloginHint': '用同一个 Apple ID 登录即可,队列和已购记录都会保留。', 'downloads.deletePartial.title': '丢弃未完成文件?', 'downloads.deletePartial.body': '下次将从 0 字节重新开始。当长时间暂停后 Apple 拒绝续传范围(HTTP 416)时使用。', 'downloads.deletePartial.confirm': '丢弃并重新下载', diff --git a/src/renderer/src/pages/DownloadsView.tsx b/src/renderer/src/pages/DownloadsView.tsx index 4bd50be..8df07d3 100644 --- a/src/renderer/src/pages/DownloadsView.tsx +++ b/src/renderer/src/pages/DownloadsView.tsx @@ -1,7 +1,7 @@ import { memo, useCallback } from 'react' import type { ReactNode } from 'react' import type { QueueItem } from '@shared/types' -import { IPATOOL_ERROR_CODES } from '@shared/ipatool/errors' +import { IPATOOL_ERROR_CODES, isStoreReloginRequired } from '@shared/ipatool/errors' import type { IconName } from '@renderer/components/Icon' import { useAppStore } from '@renderer/store/app' import { useQueueStore } from '@renderer/store/queue' @@ -60,6 +60,7 @@ const DownloadRow = memo(function DownloadRow({ item }: RowProps): ReactNode { const askConfirm = useUiStore((state) => state.askConfirm) const toast = useUiStore((state) => state.toast) const setView = useUiStore((state) => state.setView) + const setAuthOpen = useUiStore((state) => state.setAuthOpen) const busy = item.state === 'running' || item.state === 'waiting' @@ -83,6 +84,9 @@ const DownloadRow = memo(function DownloadRow({ item }: RowProps): ReactNode { const hint = item.error?.hint const hintKey = hint && (IPATOOL_ERROR_CODES as readonly string[]).includes(hint) ? `errors.${hint}.hint` : null + // ipatool 2.8.1's AMD failure is actionable (sign in again), not a network + // error; showing the raw progress/JSON blob here is misleading. + const relogin = item.state === 'error' && isStoreReloginRequired(item.error?.message) return (
@@ -104,9 +108,11 @@ const DownloadRow = memo(function DownloadRow({ item }: RowProps): ReactNode { {item.state === 'error' && item.error ? (
- {item.error.message} + {relogin ? t('downloads.reloginRequired') : item.error.message} - {hintKey ? ( + {relogin ? ( + {t('downloads.reloginHint')} + ) : hintKey ? ( {t(hintKey as Key)} ) : null}
@@ -124,6 +130,10 @@ const DownloadRow = memo(function DownloadRow({ item }: RowProps): ReactNode { ? actionButton('resume', 'play', t('downloads.action.resume'), () => void control(item.id, 'resume')) : null} + {relogin + ? actionButton('signin', 'key', t('auth.signIn'), () => setAuthOpen(true)) + : null} + {item.state === 'error' ? actionButton('retry', 'refresh', t('downloads.action.retry'), () => void control(item.id, 'retry')) : null} From 708f74c1ef364b8e12df76704cdc12a26167449f Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 17:16:51 +0800 Subject: [PATCH 10/15] fix(window): keep the caption strip transparent across login repaints Theme/settings updates called syncTitleBarOverlay() without a modal state and painted the strip opaque; remember the last state and reapply it on focus and after an ipatool login attempt, while the dialog is still open. --- src/main/window.ts | 20 +++++++++++++++++--- src/renderer/src/pages/AuthModal.tsx | 5 ++++- src/renderer/src/store/ui.ts | 5 +++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/window.ts b/src/main/window.ts index dd4a9d5..88284b1 100644 --- a/src/main/window.ts +++ b/src/main/window.ts @@ -42,6 +42,7 @@ function titleBarOptions(): Electron.BrowserWindowConstructorOptions { export function createMainWindow(options: WindowOptions = {}): BrowserWindow { const dark = nativeTheme.shouldUseDarkColors + chromeModal = false const win = new BrowserWindow({ width: options.width ?? 1240, @@ -100,6 +101,10 @@ export function createMainWindow(options: WindowOptions = {}): BrowserWindow { win.on('maximize', () => win.webContents.send('window:maximized', true)) win.on('unmaximize', () => win.webContents.send('window:maximized', false)) + // Windows may repaint the caption strip while the window loses focus (a + // login request, a native dialog, ...). Re-apply the last known state when + // focus comes back instead of leaving a solid strip over an open modal. + win.on('focus', () => syncTitleBarOverlay(win)) if (DEV_URL) { void win.loadURL(DEV_URL) @@ -110,17 +115,26 @@ export function createMainWindow(options: WindowOptions = {}): BrowserWindow { return win } +/** + * Last modal state reported by the renderer. Theme/settings events call + * syncTitleBarOverlay() without an explicit state; they must not paint the + * caption strip back to opaque while a dialog is still open. + */ +let chromeModal = false + /** Keeps the Windows caption buttons in sync with the app theme. */ -export function syncTitleBarOverlay(win: BrowserWindow | null, modal = false): void { +export function syncTitleBarOverlay(win: BrowserWindow | null, modal?: boolean): void { if (!win || process.platform !== 'win32') return + if (typeof modal === 'boolean') chromeModal = modal + const dimmed = modal ?? chromeModal try { const dark = nativeTheme.shouldUseDarkColors // Modal scrim is a dark blur over the whole page, including the strip the // OS caption buttons sit on. A painted overlay color cannot show that blur, // so the strip stays transparent while a modal is open and lets the scrim // through; glyphs stay bright because the scrim is dark on both themes. - const color = modal ? 'rgba(0, 0, 0, 0)' : dark ? '#101014' : '#ffffff' - const symbolColor = modal + const color = dimmed ? 'rgba(0, 0, 0, 0)' : dark ? '#101014' : '#ffffff' + const symbolColor = dimmed ? dark ? '#e8e8ef' : '#ffffff' diff --git a/src/renderer/src/pages/AuthModal.tsx b/src/renderer/src/pages/AuthModal.tsx index 1684918..8b9fef7 100644 --- a/src/renderer/src/pages/AuthModal.tsx +++ b/src/renderer/src/pages/AuthModal.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react' import type { ReactNode } from 'react' import type { LoginResult, LoginStatus } from '@shared/types' import { useAppStore } from '@renderer/store/app' -import { useUiStore } from '@renderer/store/ui' +import { refreshChromeDimming, useUiStore } from '@renderer/store/ui' import { ErrorNotice } from '@renderer/components/ErrorNotice' import { Icon, Spinner } from '@renderer/components/Icon' import { Modal } from '@renderer/components/Modal' @@ -103,6 +103,9 @@ export function AuthModal(): ReactNode { return } finally { setBusy(false) + // Login runs through ipatool and can leave the OS caption strip repainted; + // the dialog is still open, so restore its transparent overlay. + refreshChromeDimming() } if (result.status === 'ok') { diff --git a/src/renderer/src/store/ui.ts b/src/renderer/src/store/ui.ts index f2b05de..5423500 100644 --- a/src/renderer/src/store/ui.ts +++ b/src/renderer/src/store/ui.ts @@ -109,6 +109,11 @@ export function holdModalChrome(): () => void { } } +/** Re-applies the current modal state after an action that may repaint the OS chrome. */ +export function refreshChromeDimming(): void { + syncChromeDimmed(useUiStore.getState) +} + export const useUiStore = create()((set, get) => ({ view: 'search', setView: (view) => { From 9fe90649bb80ea593cb9df8caf3417de6703767e Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:55:17 +0800 Subject: [PATCH 11/15] feat(auth): replace the remembered e-mail with a deletable history The sign-in field now starts empty and opens a fixed-height, scrollable list of previously used Apple IDs. Each row reveals a delete action on hover; a successful sign-in records the address, and old lastEmail settings migrate into the new history. --- src/main/settings.ts | 17 +++- src/renderer/src/i18n/en.ts | 2 +- src/renderer/src/i18n/zh.ts | 2 +- src/renderer/src/pages/AuthModal.tsx | 130 +++++++++++++++++++++------ src/renderer/src/store/app.ts | 2 +- src/shared/types.ts | 4 +- tests/dom/app-boot.test.ts | 2 +- tests/main-settings.test.ts | 8 ++ 8 files changed, 131 insertions(+), 36 deletions(-) diff --git a/src/main/settings.ts b/src/main/settings.ts index f906053..f3a879b 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -59,7 +59,7 @@ export function defaultSettings(): Settings { notifyOnComplete: true, autoCheckUpdates: true, confirmCloseWhileDownloading: false, - lastEmail: '' + emailHistory: [] } } @@ -147,6 +147,21 @@ export function normalizeSettings(input: unknown): Settings { out.activeAccountId = accounts[0]?.id ?? '' } + // `lastEmail` was the pre-history field. Seed it first, then merge the saved + // list; dedupe case-insensitively so a legacy entry cannot appear twice. + const emails: string[] = [] + const seenEmails = new Set() + const addEmail = (value: unknown): void => { + if (typeof value !== 'string') return + const email = value.trim() + if (email === '' || seenEmails.has(email.toLowerCase())) return + seenEmails.add(email.toLowerCase()) + emails.push(email) + } + addEmail(raw.lastEmail) + for (const value of Array.isArray(raw.emailHistory) ? raw.emailHistory : []) addEmail(value) + out.emailHistory = emails.slice(0, 50) + return out } diff --git a/src/renderer/src/i18n/en.ts b/src/renderer/src/i18n/en.ts index 3dc78ea..7622f63 100644 --- a/src/renderer/src/i18n/en.ts +++ b/src/renderer/src/i18n/en.ts @@ -122,7 +122,7 @@ export const en = { 'auth.passwordPlaceholder': 'Your Apple ID password', 'auth.submit': 'Sign in', 'auth.signingIn': 'Signing in…', - 'auth.remember': 'Remember this e-mail', + 'auth.emailHistoryDelete': 'Remove this e-mail', 'auth.2fa.title': 'Two-factor code required', 'auth.2fa.body': 'Apple sent a verification code to your trusted devices. Enter it below.', 'auth.2fa.placeholder': '6-digit code', diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index 74edb66..b0b0918 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -118,7 +118,7 @@ export const zh: Dict = { 'auth.passwordPlaceholder': '你的 Apple ID 密码', 'auth.submit': '登录', 'auth.signingIn': '登录中…', - 'auth.remember': '记住这个邮箱', + 'auth.emailHistoryDelete': '删除这个邮箱', 'auth.2fa.title': '需要双重认证验证码', 'auth.2fa.body': 'Apple 已向你的受信任设备发送验证码,请输入。', 'auth.2fa.placeholder': '6 位验证码', diff --git a/src/renderer/src/pages/AuthModal.tsx b/src/renderer/src/pages/AuthModal.tsx index 8b9fef7..cca2add 100644 --- a/src/renderer/src/pages/AuthModal.tsx +++ b/src/renderer/src/pages/AuthModal.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import type { ReactNode } from 'react' import type { LoginResult, LoginStatus } from '@shared/types' import { useAppStore } from '@renderer/store/app' @@ -50,14 +50,15 @@ export function AuthModal(): ReactNode { const targetId = accounts.activeId const target = accounts.accounts.find((view) => view.id === targetId) - const [email, setEmail] = useState(settings.lastEmail) + const [email, setEmail] = useState('') const [password, setPassword] = useState('') const [code, setCode] = useState('') - const [remember, setRemember] = useState(Boolean(settings.lastEmail)) const [step, setStep] = useState('credentials') const [busy, setBusy] = useState(false) const [failure, setFailure] = useState<{ message: string; code: string | null } | null>(null) const [checking, setChecking] = useState(false) + const [showEmails, setShowEmails] = useState(false) + const emailBoxRef = useRef(null) // Reset transient state each time the dialog opens - and scrub the password // the moment it closes. The dialog stays mounted while hidden (Modal returns @@ -67,16 +68,36 @@ export function AuthModal(): ReactNode { if (!open) { setPassword('') setCode('') + setShowEmails(false) return } setStep('credentials') + setEmail('') setPassword('') setCode('') setFailure(null) setBusy(false) - setEmail(useAppStore.getState().settings.lastEmail) + setShowEmails(false) }, [open]) + // The custom suggestion panel is outside the input, so close it on an + // outside click instead of relying on input blur (clicking Delete would + // otherwise close the list before the click lands). + useEffect(() => { + if (!showEmails) return + const onMouseDown = (event: MouseEvent): void => { + if (!emailBoxRef.current?.contains(event.target as Node)) setShowEmails(false) + } + document.addEventListener('mousedown', onMouseDown) + return () => document.removeEventListener('mousedown', onMouseDown) + }, [showEmails]) + + const forgetEmail = async (value: string): Promise => { + await updateSettings({ + emailHistory: settings.emailHistory.filter((entry) => entry !== value) + }) + } + const submit = async (): Promise => { if (busy) return if (email.trim() === '' || password === '') return @@ -110,8 +131,15 @@ export function AuthModal(): ReactNode { if (result.status === 'ok') { useAppStore.setState({ pendingAddRestoreId: null }) - if (remember) await updateSettings({ lastEmail: email.trim() }) - else if (settings.lastEmail) await updateSettings({ lastEmail: '' }) + const signedInEmail = email.trim() + await updateSettings({ + emailHistory: [ + signedInEmail, + ...settings.emailHistory.filter( + (entry) => entry.toLowerCase() !== signedInEmail.toLowerCase() + ) + ].slice(0, 50) + }) useAppStore.getState().setAccount(result.account) setOpen(false) toast({ kind: 'success', message: t('auth.success', { email: result.account?.email ?? email }) }) @@ -256,17 +284,73 @@ export function AuthModal(): ReactNode { <> - - - -

{t('auth.slow')}

) : ( diff --git a/src/renderer/src/store/app.ts b/src/renderer/src/store/app.ts index ad07d5b..455b403 100644 --- a/src/renderer/src/store/app.ts +++ b/src/renderer/src/store/app.ts @@ -171,7 +171,7 @@ export const useAppStore = create()((set, get) => ({ notifyOnComplete: true, autoCheckUpdates: true, confirmCloseWhileDownloading: true, - lastEmail: '' + emailHistory: [] }, engine: IDLE_ENGINE, engineUpdate: null, diff --git a/src/shared/types.ts b/src/shared/types.ts index a16d4d5..224df84 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -371,8 +371,8 @@ export interface Settings { /** Check GitHub for a newer app release on launch (notification only). */ autoCheckUpdates: boolean confirmCloseWhileDownloading: boolean - /** Convenience only - the password is never persisted. */ - lastEmail: string + /** Previously used Apple IDs, newest first; only e-mails, never passwords. */ + emailHistory: string[] } /* ------------------------------------------------------------------ * diff --git a/tests/dom/app-boot.test.ts b/tests/dom/app-boot.test.ts index 0f30607..77cdee7 100644 --- a/tests/dom/app-boot.test.ts +++ b/tests/dom/app-boot.test.ts @@ -48,7 +48,7 @@ const SETTINGS = { isolateSessionHome: true, accounts: [], activeAccountId: '', accountCounter: 1, verbose: false, theme: 'system', locale: 'system', artworkEnabled: true, artworkCountry: 'us', maxLogLines: 2000, resumeQueueOnLaunch: true, - notifyOnComplete: true, autoCheckUpdates: true, confirmCloseWhileDownloading: false, lastEmail: '' + notifyOnComplete: true, autoCheckUpdates: true, confirmCloseWhileDownloading: false, emailHistory: [] } as unknown as Settings const ENGINE: EngineStatus = { diff --git a/tests/main-settings.test.ts b/tests/main-settings.test.ts index 162d7fc..4205262 100644 --- a/tests/main-settings.test.ts +++ b/tests/main-settings.test.ts @@ -78,6 +78,14 @@ describe('normalizeSettings', () => { expect(normalizeSettings([]).concurrency).toBe(2) }) + it('migrates lastEmail into the e-mail history and de-duplicates it', () => { + const out = normalizeSettings({ + lastEmail: 'a@example.com', + emailHistory: ['A@example.com', ' b@example.com ', 42, ''] + }) + expect(out.emailHistory).toEqual(['a@example.com', 'b@example.com']) + }) + it('ignores unknown fields', () => { const out = normalizeSettings({ totallyUnknownKey: 'x', theme: 'dark' }) expect(out).not.toHaveProperty('totallyUnknownKey') From cfccf0288bd8fc5928c998cdf476b150e53b70ed Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Fri, 13 Nov 2026 21:18:24 +0800 Subject: [PATCH 12/15] fix(auth): close the e-mail history after picking an entry --- src/renderer/src/pages/AuthModal.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/pages/AuthModal.tsx b/src/renderer/src/pages/AuthModal.tsx index cca2add..c4968cb 100644 --- a/src/renderer/src/pages/AuthModal.tsx +++ b/src/renderer/src/pages/AuthModal.tsx @@ -282,7 +282,9 @@ export function AuthModal(): ReactNode { > {step === 'credentials' ? ( <> - +