Skip to content

Improve URL metrics, resilient hash decoding, and file:// share URL handling#1

Merged
HKTITAN merged 3 commits intomainfrom
codex/fix-bugs-in-in-browser-editor
Feb 3, 2026
Merged

Improve URL metrics, resilient hash decoding, and file:// share URL handling#1
HKTITAN merged 3 commits intomainfrom
codex/fix-bugs-in-in-browser-editor

Conversation

@HKTITAN
Copy link
Copy Markdown
Owner

@HKTITAN HKTITAN commented Feb 3, 2026

Motivation

  • Ensure the status bar, QR, and share/copy flows reflect the actual saved share URL and size rather than stale location.href during edits.
  • Make hash decoding more tolerant so legacy/base85-encoded or mis-detected hashes don't break loading.
  • Preserve correct share URLs when running from local file:// origins where location.origin === 'null'.

Description

  • Added a lightweight cached URL metrics model with contentVersion and urlMetrics plus helpers buildShareUrl, refreshUrlMetrics, syncUrlMetricsToLocation, and scheduleUrlMetricsUpdate to compute and cache the share URL and its byte size.
  • Updated UI flows to prefer cached metrics when available by changing updateStatusBar, updateQR, tooltip logic, and isAtInputLimit to use urlMetrics when urlMetrics.version === contentVersion.
  • Bumped contentVersion in scheduleSave and other lifecycle points and updated save() to compute and store urlMetrics after saving, so share/QR/clipboard reflect the latest saved URL.
  • Made decompressToBlocks resilient by attempting decoding in both base85 and base64 orders (depending on detection), retrying the other format on failure, and preserving encrypted errors (err.type === 'ENCRYPTED') so they propagate unchanged.
  • Fixed share URL construction for file:///local origins by preserving the local base path instead of returning an invalid null origin, using normalizeHash and an encoded hash suffix.
  • Added debounce utility and wired scheduleUrlMetricsUpdate (350ms) to avoid expensive recomputation during typing, and synced metrics to location changes in theme/version/preview/encryption flows.

Testing

  • Attempted an automated end-to-end check by starting a local static server (python -m http.server) and running a Playwright script to type and inspect the UI, but the Playwright run timed out after 30s and did not complete (failure); no further automated tests were present.
  • No unit tests were added; existing code paths were exercised via local server runs and static inspection during the change.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
khemessage Ready Ready Preview, Comment Feb 3, 2026 6:57am

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8fdd3f56a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 3710 to +3714
function isAtInputLimit() {
return estimateUrlSizeFromBlocks(blocks) >= URL_THRESHOLDS.danger
const size = (urlMetrics.version === contentVersion)
? urlMetrics.size
: new Blob([location.href]).size
return size >= URL_THRESHOLDS.danger
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use live content size for input limit enforcement

The new isAtInputLimit checks only urlMetrics (when versions match) or location.href (when they don’t). During active typing/pasting, the URL hash hasn’t been updated yet, so location.href reflects the previous saved state and urlMetrics is stale until the debounced recomputation finishes. This means the limit checks in handleBeforeInput/handlePaste can allow users to type or paste well past the URL threshold before the limit flips, which defeats the size guard that previously used a live estimate from blocks. Consider reverting to (or incorporating) estimateUrlSizeFromBlocks for enforcement so the limit is based on the current content, not the last saved URL.

Useful? React with 👍 / 👎.

@HKTITAN HKTITAN merged commit 8b6b4ab into main Feb 3, 2026
4 checks passed
@HKTITAN HKTITAN deleted the codex/fix-bugs-in-in-browser-editor branch February 3, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant