Skip to content

Trac JS Overwork - #977

Closed
timse201 wants to merge 112 commits into
WordPress:trunkfrom
timse201:8027/trac-add-link-to-workflow-documentation-1
Closed

timse201 wants to merge 112 commits into
WordPress:trunkfrom
timse201:8027/trac-add-link-to-workflow-documentation-1

Conversation

@timse201

@timse201 timse201 commented Oct 1, 2026 •

Copy link
Copy Markdown

Many bug fixes. Full rewrite in Vanilla JS and backwards compatible with jQuery. Some jQuery checks might be useless.

Improvements:

  • Add accessibility attributes and focus management to the keyword workflow.

Performance:

  • Pre-compile mentionsRegEx and gutenbergIssueRegEx once at module scope to avoid re-compilation on every run.
  • Use startsWith() instead of dynamic RegExp in autocomplete filters for faster substring matching.
  • Batch DOM insertions using DocumentFragment in linkTextNodes() and keyword workflow methods to reduce reflows.
  • Combine multiple replacement passes in capital_P_dangit() into a single regular expression.
  • Streamline escapeHtml() using direct string entity replacements instead of temporary DOM node creation.

Error handling & network:

  • Add HTTP response checks (res.ok) to fetch() calls in reports and GitHub PR modules.
  • Provide clear user-facing error messages on failed GitHub PR fetches, and enable a retry button on report failure.
  • Ensure loading spinners on star indicators are cleared in a finally block on network completion or failure.

Bug fixes:

  • Autocomplete: Prevent syntax crashes when typing special regex characters.
  • Ticket ID: Reliably extract ticket numbers from canonical URLs containing query strings or hash fragments.
  • Unsaved changes: Detect modified summary and description fields on existing tickets, and prevent some unnecessary warnings.
  • Handbook: Correct the Security FAQ URL.
  • Selectors: Use CSS.escape() for keyword selector queries.

Assisted by Gemini 4 and 3.8 Flash

Summary by CodeRabbit

  • Bug Fixes
    • Made unsaved-change warnings more accurate for ticket summaries, descriptions, and comments.
    • Improved GitHub pull request loading, including clearer error and retry states.
    • Improved ticket and report star counts and subscription status, as well as workflow controls and component suggestions.
  • Updates
    • Updated attachment previews to include image links and video playback controls.
    • Adjusted text escaping and mention matching.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • No files to review - (🔄 Check again to try again)
📝 Walkthrough

The Trac JavaScript updates ticket text handling, form interactions, participant and workflow controls, notifications, and GitHub pull-request reporting. It replaces many jQuery operations with native DOM APIs and updates shared utilities.

Changes: Trac Interface and Workflow Updates

Layer / File(s) Summary
Text processing and shared utilities
wordpress.org/public_html/style/trac/wp-trac.js
Shared initialization, current-user access, escaping, mention matching, link generation, and attachment previews use updated utility and DOM handling.
Ticket forms and page interactions
wordpress.org/public_html/style/trac/wp-trac.js
Ticket editing, form notices, validation, navigation, toolbar actions, tracker selection, and report-popup loading use native DOM APIs and updated guards.
Participants and workflow controls
wordpress.org/public_html/style/trac/wp-trac.js
Participant filtering, keyword editing, and contributor-focus controls use native DOM traversal and listeners. Keyword state uses arrays, and keyword additions reject empty or duplicate values.
Notifications and report subscriptions
wordpress.org/public_html/style/trac/wp-trac.js
Notification and report subscription controls use native events and fetch. Request failures and local subscription state updates are handled in the interface.
GitHub reporting and component suggestions
wordpress.org/public_html/style/trac/wp-trac.js
GitHub pull-request loading uses fetch with failure and retry handling. Component suggestions and review labels use native DOM operations and guarded element access.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Refactor

Suggested reviewers: obenland

Merge Risk: 🔵 Low · up to 965b3

Copying a long ticket draft can disable the warning before leaving the original page. Fix that narrow draft-loss risk before merging, or accept it explicitly.

### Architecture Summary

Architecture risk: 🟡 Medium · up to f2b03

The change affects 1 system.

Changed systems: wordpress.org

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — wordpress.org (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in wordpress.org/public_html/style/trac/wp-trac.js: Removed the wpTracCurrentUser globals declaration.
  • observed — Modified behavior in wordpress.org/public_html/style/trac/wp-trac.js: escapeHtml now converts non-string values to strings, treating nullish values as empty, then escapes ampersands, angle brackets, quotes, and apostrophes.
  • observed — Modified behavior in wordpress.org/public_html/style/trac/wp-trac.js: linkTextNodes now returns for non-global or non-RegExp inputs and uses the tree walker filter to reject text inside links and skip blank text nodes; the old post-walk link check is removed.
  • observed — Modified behavior in wordpress.org/public_html/style/trac/wp-trac.js: wpTrac.currentUser now reads window.wpTracCurrentUser and defaults to null, rather than directly using the undeclared global.

Reliability and maintainability

  • inferred — Risk-relevant change factors for wordpress.org: blast_radius_1; direct_dependents_1
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 24.39% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title identifies the main change: substantial rework of the Trac JavaScript implementation. It is concise and related to the full rewrite and bug fixes.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

coderabbitai[bot]

This comment was marked as outdated.

@timse201 timse201 closed this Oct 24, 2026
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in WordPress.org Oct 24, 2026
@timse201 timse201 removed this from WordPress.org Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] On Hold Work is paused temporarily

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants