Skip to content

fix(sw): fetch失敗時にフォールバックしてResponse.error()返却、登録遅延を最小化\nfeat(ui): 再生コ…#8

Merged
terisuke merged 1 commit intomainfrom
dev
Oct 15, 2025
Merged

fix(sw): fetch失敗時にフォールバックしてResponse.error()返却、登録遅延を最小化\nfeat(ui): 再生コ…#8
terisuke merged 1 commit intomainfrom
dev

Conversation

@terisuke
Copy link
Copy Markdown
Contributor

…ントロールの配色改善(線が見えるように)\ni18n(dialog): sr-onlyラベルを日本語化

…ントロールの配色改善(線が見えるように)\ni18n(dialog): sr-onlyラベルを日本語化
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 15, 2025

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

Project Deployment Preview Comments Updated (UTC)
pro-edit Ready Ready Preview Comment Oct 15, 2025 1:19am

@claude
Copy link
Copy Markdown

claude bot commented Oct 15, 2025

Pull Request Review

Thank you for your contribution! I've reviewed the changes in this PR. Here's my detailed feedback:

Overview

This PR includes:

  1. Service Worker registration timing optimization
  2. Service Worker error handling improvements
  3. UI color scheme improvements for playback controls
  4. i18n improvement for dialog close button

1. Service Worker Registration (app/register-sw.tsx)

Change: Reduced delay from 100ms to 0ms with improved comment

✅ Positive:

  • Good optimization to avoid unnecessary delay
  • The comment clearly explains the rationale (avoiding COOP/COEP issues)

⚠️ Considerations:

  • Using setTimeout(..., 0) still defers execution to the next event loop tick. If immediate execution is desired, consider removing the setTimeout entirely and calling void registerSW() directly in the effect
  • The mixed language comment (English + Japanese) may reduce maintainability. Consider using consistent language throughout the codebase

Suggestion:

// Register immediately to prevent requests before COOP/COEP headers are active
void registerSW()

2. Service Worker Error Handling (public/coi-serviceworker.js:57)

Change: Added fallback fetch with error response on failure

✅ Positive:

  • Improved error resilience
  • Falls back to original request if modified request fails
  • Returns proper error response instead of leaving promise unresolved

⚠️ Potential Issue:
The fallback logic fetch(r).catch(() => Response.error()) may mask the root cause of failures. Consider:

  • Logging different error types separately for debugging
  • The fallback fetch might also fail for the same reason as the first attempt

Security Note: ✅ The error handling is defensive and doesn't introduce security concerns

Suggestion:

.catch((e) => { 
    console.error('[COOP/COEP] Primary fetch failed:', e); 
    return fetch(r).catch((fallbackError) => { 
        console.error('[COOP/COEP] Fallback fetch failed:', fallbackError); 
        return Response.error(); 
    }); 
})

3. Playback Controls UI (features/compositor/components/PlaybackControls.tsx)

Change: Updated color scheme from ghost/muted variants to outline/foreground for better visibility

✅ Positive:

  • Addresses visibility issues with controls
  • Consistent application across all control buttons
  • Improved contrast with explicit text-foreground classes

⚠️ Considerations:

  • The play/pause button uses text-background which creates inverted text. Ensure this provides sufficient contrast in both light and dark themes
  • Background changed from bg-muted/50 to bg-background - verify this doesn't create visual issues with the parent container

Testing Recommendation: Test in both light and dark themes to ensure adequate contrast ratios (WCAG AA compliance requires 4.5:1 for normal text)


4. Dialog i18n (components/ui/dialog.tsx:68)

Change: Japanese translation for screen reader text

✅ Positive:

  • Good accessibility improvement for Japanese users
  • Screen reader users will hear the label in their language

⚠️ Consideration:

  • Hardcoded string suggests lack of i18n framework. For scalability, consider using a proper i18n library (e.g., next-intl, react-i18next) to support multiple languages and easy maintenance
  • Other sr-only text in the codebase may also need localization

Overall Assessment

Code Quality: ✅ Good

  • Changes are focused and well-intentioned
  • Code follows TypeScript/React conventions

Potential Bugs: ⚠️ Minor concerns

  • Service Worker fallback logic may hide errors
  • Color contrast should be verified in both themes

Performance: ✅ Positive impact

  • Removing 100ms delay improves SW registration timing
  • No negative performance implications

Security: ✅ No concerns

  • Changes are defensive in nature
  • No introduction of security vulnerabilities

Test Coverage: ⚠️ Missing

  • No tests included for these changes
  • Consider adding:
    • Unit test for PlaybackControls color classes
    • E2E test for service worker error handling
    • Accessibility test for dialog i18n

Recommendations

  1. High Priority:

    • Test UI changes in both light/dark themes
    • Verify color contrast meets WCAG AA standards
    • Consider more detailed error logging in service worker
  2. Medium Priority:

    • Consider removing setTimeout entirely in SW registration
    • Implement proper i18n framework instead of hardcoded strings
    • Add tests for UI changes
  3. Low Priority:

    • Standardize comment language (English or Japanese, not mixed)
    • Document the color scheme changes in commit message

Verdict

The changes are generally good improvements that address real issues (visibility, timing, error handling, i18n). With minor adjustments for error logging and accessibility verification, this PR will be ready to merge.

Estimated Risk: Low
Recommended Action: Approve with minor suggestions


Review generated by Claude Code

@terisuke terisuke merged commit 7579ee8 into main Oct 15, 2025
3 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