Repository navigation
Commit 1d03901
fix(console): PWA manifest declares the branding icon's real type and size, with 192/512 PNG fallbacks (#29405)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb6KFUEBv4xhM1GGBkDXW4oV)_
Fixes #29332
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:Console 运行时 PWA manifest 的图标不再一律写成 `image/svg+xml` + `sizes:
'any'`。品牌 favicon 是 SVG 时照旧;是 PNG/ICO 等位图时按真实类型与实测像素尺寸声明;没有 ≥192 px
正方形位图时,补上平台默认的 192/512 PNG(由现有 `favicon.svg` 渲染,新增两个静态文件)。
- **为什么改**:配了小尺寸 PNG favicon 的品牌 Console 在 Chrome 里不可安装(实测
`no-acceptable-icon`,最低 144 px),与 #29155 要的「品牌化可安装」相悖。
- **风险与回滚**:风险低,只动 Console 入口的 manifest 生成;manifest
链接改为在位图测量完成后才挂上(不阻塞首屏,最长 10 秒超时)。回滚即 revert 本 PR。取舍:小尺寸品牌 PNG
安装后,启动器图标显示的是平台默认图标而非品牌图标。
-
**先看**:`ui/apps/console/src/pwaManifestIcons.ts`(`resolveManifestIcons`
的判定);`ui/apps/console/src/main.tsx`(`injectPwaManifest`,异步注入)。
- **两分钟验证**:`pnpm --dir ui exec vitest run
apps/console/src/pwaManifestIcons.test.ts`,预期 23 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
- `ui/apps/console/src/pwaManifestIcons.ts` (new, console-local):
`resolveManifestIcons(faviconUrl, baseURI)` builds the manifest icon
entries.
- SVG favicon, or no branding (the default `favicon.svg`): one entry,
`image/svg+xml`, `sizes: 'any'`, as before. Nothing is loaded.
- Raster favicon (PNG, ICO, WebP, JPEG, GIF, AVIF, by path extension or
`data:` media type): the image is measured through `HTMLImageElement`
and declared with its own type and `WIDTHxHEIGHT`. A favicon whose type
is unknown, or that fails to load, measures zero or does not answer
within 10 s, is left out rather than guessed.
- Whenever the result has no square raster of at least 192 px,
`icon-192.png` and `icon-512.png` are appended.
- `ui/apps/console/public/icon-192.png`, `icon-512.png` (new): the
platform default icons, rendered once with Chromium from the existing
`public/favicon.svg`. No default PNG icon existed anywhere in the
repository and no server-rendered resize exists, so these are the card's
"platform default icons" option (seat approved before the assets were
added).
- `ui/apps/console/src/main.tsx`: the manifest block moves into
`injectPwaManifest`, called without `await`. The static manifest is
still removed synchronously, the native-host check is unchanged, and the
Blob manifest link lands once the icon measurement settles, so first
paint is never held for it. `start_url`, `scope` and the absolute icon
URLs from #29326 are unchanged.
- Changeset: `@object-ui/console` patch.
Trade-off: a branding with a small raster favicon installs with the
platform default icon at launcher sizes, since browsers pick the icon
closest to the size they need. Upscaling a 32 px favicon client-side
would look worse and needs canvas and CSP work, so the branded icon
stays in the manifest at its true size and the defaults cover the large
sizes.
## Tests
- `pnpm --dir ui exec vitest run
apps/console/src/pwaManifestIcons.test.ts`: 23/23 passed. Covers the
manifest (through `generatePWAManifest`) for no branding, SVG, small
PNG, large square PNG, large non-square PNG, ICO, an unmeasurable raster
and an unknown type, plus `iconTypeOf` and the browser measurement
(load, error, zero size, timeout).
- Ablation (back to the hard-coded `image/svg+xml` declaration,
`scripts/ablation-replace.mjs` on `const type = iconTypeOf(src);`): 6
failed / 17 passed, the PNG, ICO, unmeasurable and unknown-type cases
red; no branding and SVG stay green, as they should. Restored, blob
equal to HEAD, `git diff HEAD` empty.
- `turbo run type-check --filter=@object-ui/console`: 71/71 tasks
successful.
- Derived gates (`dispatch-gates --commands`): 33/33 exit 0 at
`29065950`, reconciled with `--ran` (0 NOT-MEASURED, 0 UNRUN), `vitest
run scripts/` included (169 files passed). `origin/main` was merged
afterwards (`1b6eb74f`); none of the merged commits touch these files,
and the unit test re-ran green there (23/23).
## Acceptance notes
- The favicon link a few lines above the manifest block (and the same
line in `index.html`) still labels every non-SVG favicon `image/png`, an
ICO included. Out of this card's surface; browsers sniff favicon bytes,
so nothing visible follows from it.
## Verification
Installability, read with CDP (`Page.getInstallabilityErrors`,
`Page.getAppManifest`) in full Chromium (`launchPersistentContext`,
`channel: 'chromium'`), on a `vite build` of the Console served under
`/console/` with its `base` tag and a stubbed `GET
/api/v1/runtime/config` carrying `branding.faviconUrl`.
| branding favicon | before (main's manifest block) | after (this
branch) |
|:--|:--|:--|
| 32 px PNG | `no-acceptable-icon` (minimum 144 px); icon declared
`image/svg+xml`, `any` | no errors; icons `32x32` PNG + `192x192` +
`512x512` |
| 256 px PNG | no errors; icon declared `image/svg+xml`, `any` | no
errors; one icon `256x256` `image/png` |
| SVG | no errors; one SVG `any` | no errors; one SVG `any` |
| none | no errors; default SVG `any` | no errors; default SVG `any` |
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jSqNEXXfJECHQqN7mG)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent fe5ed7c commit 1d03901
6 files changed
Lines changed: 339 additions & 30 deletions
File tree
- .changeset
- ui/apps/console
- public
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Loading
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 161 | + | |
190 | 162 | | |
191 | 163 | | |
192 | 164 | | |
| |||
207 | 179 | | |
208 | 180 | | |
209 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
0 commit comments