Skip to content

[codex] fix astro deprecation warnings#563

Merged
riderx merged 3 commits intomainfrom
codex/fix-astro-deprecation-warnings
Apr 14, 2026
Merged

[codex] fix astro deprecation warnings#563
riderx merged 3 commits intomainfrom
codex/fix-astro-deprecation-warnings

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Apr 14, 2026

Summary

  • switch the Astro content schema import to astro/zod so apps/web/src/content.config.ts no longer relies on the deprecated z re-export
  • remove deprecated document.execCommand('copy') clipboard fallbacks from the web UDID tool page and the docs copy-page component
  • remove the unused index parameter in the UDID result page callback surfaced during Astro checking

Root cause

Astro 6.1.3 now marks the z export from astro:content as deprecated, and the copy helpers still used the deprecated DOM execCommand('copy') fallback.

Impact

This clears the TypeScript deprecation warnings from both apps/web and apps/docs without changing the visible copy interactions when the Clipboard API is available.

Validation

  • bun run check

Summary by CodeRabbit

  • Refactor

    • Streamlined clipboard copy handling across docs and tools.
    • Minor consolidation in content schema import usage.
  • Accessibility

    • Added an explicit status role for copy feedback to improve assistive tech annunciation.
  • Behavior Changes

    • Copy-to-clipboard prefers the modern Clipboard API, falling back to a legacy textarea-based method when needed.
    • Copy feedback now updates on success/failure and automatically resets after ~2 seconds.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b451ac6c-240c-470e-b1f1-8cf46bf54653

📥 Commits

Reviewing files that changed from the base of the PR and between d8b478d and 382e7ea.

📒 Files selected for processing (1)
  • apps/docs/src/components/doc/CopyPage.astro
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/docs/src/components/doc/CopyPage.astro

📝 Walkthrough

Walkthrough

Refactors clipboard copy logic in two UI components to perform a capability check, add shared helper functions (updateFeedback, resetFeedback, fallbackCopy), unify feedback handling, and provide a textarea+execCommand fallback. Adds role="status" to feedback. Changes z import source and collapses localeSchema to one line.

Changes

Cohort / File(s) Summary
Docs copy UI
apps/docs/src/components/doc/CopyPage.astro
Added role="status" to .copy-page-feedback. Refactored copy handler to use updateFeedback() and resetFeedback() helpers, introduced fallbackCopy() that uses a hidden <textarea> and document.execCommand via Reflect.get, and removed prior nested try/catch flow. Fallback throws Error('Fallback copy method also failed') on failure.
Tools copy UI
apps/web/src/pages/tools/ios-udid-finder/result.astro
Reworked copyText to check navigator.clipboard?.writeText capability, attempt navigator.clipboard.writeText with a fallback to fallbackCopy() (textarea + execCommand) on errors. Fallback throws Error('Copy failed') when legacy copy reports failure.
Content config / Zod import
apps/web/src/content.config.ts
Switched z import source from astro:content to astro/zod while keeping defineCollection from astro:content. Collapsed localeSchema to a single-line z.custom(...) call; validation logic unchanged.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant User
participant UI as "Copy Button / Feedback"
participant Clipboard as "navigator.clipboard"
participant Legacy as "document.execCommand (fallback)"
User->>UI: Click copy
UI->>Clipboard: check navigator.clipboard?.writeText
alt Clipboard available
UI->>Clipboard: await writeText(content)
Clipboard-->>UI: success / throws
alt success
UI->>UI: updateFeedback("Copied"), resetFeedback() (restore title after 2s)
else failure
UI->>Legacy: fallbackCopy -> create textarea, select, execCommand('copy')
Legacy-->>UI: success / failure
UI->>UI: updateFeedback(success or throw Error), resetFeedback()
end
else Clipboard not available
UI->>Legacy: fallbackCopy -> create textarea, select, execCommand('copy')
Legacy-->>UI: success / failure
UI->>UI: updateFeedback(success or throw Error), resetFeedback()
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I nudge the button, ears a-flip,
I try the clipboard, then do a skip —
A tiny textarea, a hop, a click,
Feedback blinks, then all is slick. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main objective: fixing Astro deprecation warnings by updating imports and removing deprecated APIs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-astro-deprecation-warnings

Comment @coderabbitai help to get the list of available commands and usage tips.

@riderx riderx marked this pull request as ready for review April 14, 2026 10:16
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: 098a81024f

ℹ️ 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".

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/docs/src/components/doc/CopyPage.astro`:
- Around line 202-208: The copy handler currently uses
navigator.clipboard.writeText(content) and only logs success, but needs an
aria-live status region for screen readers: add a visually-hidden element in the
component markup with role="status" and aria-live="polite" (e.g., a status DOM
node or state variable bound to text), then update that element's text to a
clear success or error message inside the copy routine (on success and in the
catch branch where you throw or handle 'Clipboard API unavailable') instead of
only console.log so assistive tech receives the announcement; reference the
existing navigator.clipboard.writeText call and the content variable when wiring
the updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d2506670-d2f8-4f0f-8cca-c83d97544f5a

📥 Commits

Reviewing files that changed from the base of the PR and between 7d028e0 and 098a810.

📒 Files selected for processing (3)
  • apps/docs/src/components/doc/CopyPage.astro
  • apps/web/src/content.config.ts
  • apps/web/src/pages/tools/ios-udid-finder/result.astro

@riderx riderx force-pushed the codex/fix-astro-deprecation-warnings branch from 098a810 to b952889 Compare April 14, 2026 10:22
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/docs/src/components/doc/CopyPage.astro (1)

181-188: Avoid overlapping feedback reset timers.

Line 182 schedules a new timeout per copy without cancelling prior ones; rapid repeated copies can clear a newer status early. Keep one timer per button and clear it before scheduling a new reset.

Suggested patch
   document.querySelectorAll('.copy-markdown').forEach((btn) => {
+    let resetTimer
     btn.addEventListener('click', async (e) => {
@@
       function resetFeedback() {
+        if (resetTimer) window.clearTimeout(resetTimer)
-        window.setTimeout(() => {
+        resetTimer = window.setTimeout(() => {
           if (title) {
             title.textContent = originalText || translations.copyPage
           }
           updateFeedback('')
         }, 2000)
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/docs/src/components/doc/CopyPage.astro` around lines 181 - 188, The
resetFeedback function schedules timeouts per copy but never cancels previous
ones, causing newer feedback to be cleared early; modify the component to store
a single timer id (e.g., feedbackTimeoutId) scoped to the button/component, call
clearTimeout(feedbackTimeoutId) before scheduling a new window.setTimeout in
resetFeedback, then assign the new id so only one pending reset exists; keep
using title.textContent (with originalText || translations.copyPage) and
updateFeedback('') inside the timeout.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/docs/src/components/doc/CopyPage.astro`:
- Around line 190-207: Remove the legacy fallbackCopy function and its use:
delete the function named fallbackCopy and any code that calls or relies on
Reflect.get(document, 'execCommand') and the textarea-based fallback; instead,
call navigator.clipboard.writeText(value) directly where copying is needed
(e.g., in the copy handler that previously invoked fallbackCopy) and throw an
error if navigator.clipboard or navigator.clipboard.writeText is unavailable or
the promise rejects, ensuring you surface that error to the caller/UI.

---

Nitpick comments:
In `@apps/docs/src/components/doc/CopyPage.astro`:
- Around line 181-188: The resetFeedback function schedules timeouts per copy
but never cancels previous ones, causing newer feedback to be cleared early;
modify the component to store a single timer id (e.g., feedbackTimeoutId) scoped
to the button/component, call clearTimeout(feedbackTimeoutId) before scheduling
a new window.setTimeout in resetFeedback, then assign the new id so only one
pending reset exists; keep using title.textContent (with originalText ||
translations.copyPage) and updateFeedback('') inside the timeout.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9dfece40-afe1-44fb-b91c-f671b6d28888

📥 Commits

Reviewing files that changed from the base of the PR and between b952889 and d8b478d.

📒 Files selected for processing (2)
  • apps/docs/src/components/doc/CopyPage.astro
  • apps/web/src/pages/tools/ios-udid-finder/result.astro
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/pages/tools/ios-udid-finder/result.astro

@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit 7476a0e into main Apr 14, 2026
6 checks passed
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.

1 participant