Skip to content

Full in-depth audit + CloudStorage crash fix#116

Merged
xlabtg merged 3 commits into
mainfrom
issue-115-9f630769e0a4
May 19, 2026
Merged

Full in-depth audit + CloudStorage crash fix#116
xlabtg merged 3 commits into
mainfrom
issue-115-9f630769e0a4

Conversation

@konard
Copy link
Copy Markdown
Collaborator

@konard konard commented May 19, 2026

Closes #115.

What this PR does

Second-pass audit of the work shipped against the improvements plan (#1)
and the 53-task roadmap (#2), extending the prior audit in PR #114 /
APPLICATION_AUDIT.md (2026-05-04).

Code change (one)

Harden CloudStorage callers — three modules used
Telegram.WebApp.CloudStorage methods without catching synchronous
throws. On Telegram WebApp 6.0 the object exists but its methods raise
WebAppMethodUnsupported synchronously, which crashed every consumer:

  • assets/js/prefs.jsmigrate() Promise never resolved, so
    prefs.init() hung forever and broke language / theme / last-pair
    persistence.
  • assets/js/achievements.jsloadStats/saveStats threw and broke
    the tier badge + celebration modal.
  • assets/js/address-book.jsloadEntries/saveEntries threw and
    broke the chip list and the Manage Addresses page.

Fix: gate access behind tg.isVersionAtLeast('6.1') and wrap calls in
try/catch so unsupported clients fall back to localStorage (the
fallback already present for non-Telegram envs).

Audit doc

AUDIT.md adds the second-pass audit summary with the verification
matrix, fixed findings, audit-only findings, and the new follow-up
issues filed below.

Follow-up issues filed

Items that surfaced during the audit but whose right fix belongs in
its own scoped PR:

Verification

Check Result
npm run build Passed
npm run check:i18n Passed
npm run validate:manifest Passed
npm run test:unit Passed (18/18)
npm run test:schema Passed
npm run test:auth-verify Passed
npm run test:accrual Passed
npm run test:redeem Passed
npm run test:rate-config Passed
npm run test:installer Passed
npx playwright test (focused: prefs, achievements, address-book) Passed (44/44)
npx playwright test --grep "RU\|Russian\|ru locale" Passed (52/52)
npx html-validate "dist/*.html" Passed

Test plan

  • Local unit + integration test suites pass
  • Playwright tests for modified modules pass
  • Playwright RU-locale tests pass
  • Build produces no warnings/errors
  • CI on this PR passes

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #115
Three modules called Telegram.WebApp.CloudStorage methods without
catching synchronous throws, which crashed the page on Telegram WebApp
< 6.1 (CloudStorage object exists but methods raise
WebAppMethodUnsupported). Gate behind isVersionAtLeast('6.1') and wrap
calls in try/catch so unsupported clients fall back to localStorage:

  * assets/js/prefs.js — migrate() now always resolves; csGet/csSet/
    csRemove catch synchronous throws and reject cleanly.
  * assets/js/achievements.js — loadStats/saveStats fall back via a
    shared cloudStorage() probe + localStorage fallback.
  * assets/js/address-book.js — loadEntries/saveEntries probe the API
    and catch throws around getItem/setItem.

AUDIT.md documents the audit done against issues #1, #2, and the
in-flight #115 work, plus the 6 follow-up GitHub issues it spawned
(#117#122).
@konard konard changed the title [WIP] Conduct a full in-depth audit Full in-depth audit + CloudStorage crash fix May 19, 2026
@konard konard marked this pull request as ready for review May 19, 2026 19:40
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $6.630777

📊 Context and tokens usage:

Claude Opus 4.7: (2 sub-sessions)

  1. 116.6K / 1M (12%) input tokens, 18.2K / 128K (14%) output tokens
  2. 83.5K / 1M (8%) input tokens, 26.3K / 128K (21%) output tokens

Total: (2.4K new + 182.9K cache writes + 8.4M cache reads) input tokens, 51.6K output tokens, $6.630777 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.7 (claude-opus-4-7)

📎 Log file uploaded as Gist (4115KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

🔄 Auto-restart 1/5

Detected uncommitted changes from previous run. Starting new session to review and commit or discard them.

Uncommitted files:

M assets/img/screenshots/bridge-desktop.png
 M assets/img/screenshots/bridge-mobile.png
 M assets/img/screenshots/exchange-desktop.png
 M assets/img/screenshots/exchange-mobile.png
 M assets/img/screenshots/otc-desktop.png
 M assets/img/screenshots/otc-mobile.png
 M tests/screenshots/affiliate-en.png
 M tests/screenshots/affiliate-ru.png
 M tests/screenshots/bridge-en-iframe.png
 M tests/screenshots/bridge-en-placeholder.png
 M tests/screenshots/bridge-tier-bronze.png
 M tests/screenshots/rate-ticker-en.png
 M tests/screenshots/settings-referral-en.png
 M tests/screenshots/social-proof-bridge-en.png
 M tests/screenshots/wallet-bridge-en.png
 M tests/screenshots/wallet-settings-en.png
?? .lighthouseci/
?? audit-admin.png
?? audit-bridge-en.png
?? audit-bridge-viewport.png
?? audit-exchange-en.png
?? audit-orders.png

Auto-restart will stop after changes are committed or discarded, or after 4 more iterations. Please wait until working session will end and give your feedback.

`lhci collect` writes reports to `.lighthouseci/` and the audit pass
saved ad-hoc PNGs at the repo root (`audit-bridge-en.png`, etc.).
Neither should land in the tree; add explicit patterns so future audit
runs leave a clean working copy.
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

Working session summary

Рабочее дерево чистое, gitignore-обновление запушено в ветку PR.

Резюме:

  • Все «висящие» изменения — .lighthouseci/, audit-*.png в корне и регенерированные Playwright скриншоты — были артефактами локального аудит-прогона, а не частью решения.
  • Скриншоты откатил (git checkout --), артефакты удалил, и добавил в .gitignore шаблоны /.lighthouseci/ и /audit-*.png, чтобы будущие аудит-запуски не оставляли мусор в рабочей копии.
  • Изменение коммитом 8801607 запушено в issue-115-9f630769e0a4; PR Full in-depth audit + CloudStorage crash fix #116 уже в Ready for review и не требует дополнительных правок по существу задачи.

This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

🔄 Auto-restart 1/5 Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.596445

📊 Context and tokens usage:

  • 43.7K / 1M (4%) input tokens, 5.1K / 128K (4%) output tokens

Total: (22 new + 38K cache writes + 465.0K cache reads) input tokens, 5.1K output tokens, $0.596445 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Model: Claude Opus 4.7 (claude-opus-4-7)

📎 Log file uploaded as Gist (4598KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

🔄 Auto-restart triggered (iteration 1)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. This run will stop after 5 restart iterations.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

CI зелёный на свежем коммите 8801607: 11 джобов SUCCESS, Lighthouse CI прошёл, Deploy to GitHub Pages корректно skipped для PR. Предыдущий сбой Lighthouse был флейком (разброс perf 0.48/0.76/0.76 при пороге 0.85 на бюджете 206KB JS, дельта моих правок ~2.5KB). Долгосрочное улучшение render-blocking ресурсов закреплено за follow-up issue #122.

@xlabtg xlabtg merged commit f063746 into main May 19, 2026
23 of 24 checks passed
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 19, 2026

🔄 Auto-restart-until-mergeable Log (iteration 1)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $6.384719

📊 Context and tokens usage:

Claude Opus 4.7: (2 sub-sessions)

  1. 115.6K / 1M (12%) input tokens, 16.9K / 128K (13%) output tokens
  2. 107.9K / 1M (11%) input tokens, 36.8K / 128K (29%) output tokens

Total: (2.0K new + 207.7K cache writes + 7.2M cache reads) input tokens, 58.3K output tokens, $6.383054 cost

Claude Haiku 4.5:

  • 225 / 200K (0%) input tokens, 288 / 64K (0%) output tokens

Total: 225 input tokens, 288 output tokens, $0.001665 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: opus
  • Main model: Claude Opus 4.7 (claude-opus-4-7)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (7539KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conduct a full in-depth audit

2 participants