Skip to content

Fix admin JS/CSS namespace leaks missed in rename#31

Merged
r00bbert merged 1 commit into
mainfrom
fix/admin-js-css-namespace-leaks
May 21, 2026
Merged

Fix admin JS/CSS namespace leaks missed in rename#31
r00bbert merged 1 commit into
mainfrom
fix/admin-js-css-namespace-leaks

Conversation

@r00bbert
Copy link
Copy Markdown
Collaborator

@r00bbert r00bbert commented May 21, 2026

Final namespace sweep before WP.org resubmission turned up real breakage the big rename (#28) missed in assets/js/admin.js and one admin.css class.

What was broken

The PHP renders the new namespace, but admin.js still queried the old one:

Feature PHP renders admin.js queried Result
Accent-contrast live preview #ettic_otc_accent_color, #ettic-otc-accent-warning #opentrust_* dead
Version-summary toggle #ettic_otc_publish_new_version, #ettic_otc_version_summary #opentrust_* dead
Cert-type catalog autofill meta _ettic_otc_* replace(/^_opentrust_/…) dead
Model-unavailable marker .ettic-otc-ai-model-unavailable CSS defined .opentrust-ai-model-unavailable unstyled

These are admin-edit-screen behaviors, which is why frontend/chat QA didn't catch them.

Also

Updated stale OpenTrust references in JS/CSS/XML header comments and the chat localStorage key. No translatable strings changed (POT untouched).

After this, the only opentrust strings left in shipped code are intentional: the importer legacy back-compat maps, the readme changelog, and the Docs link URL.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Updated internal naming conventions and identifiers throughout application components, including DOM element references, CSS class names, and storage keys, to align with current branding standards.
    • Adjusted chat history storage mechanism.
  • Chores

    • Updated documentation and header comments across asset files for consistency.

Review Change Stack

Phase 9 missed assets/js/admin.js and one admin.css class. The PHP
renders ettic_otc_* ids and .ettic-otc-* classes, but the JS still
queried opentrust_* ids and the _opentrust_ meta prefix, so the accent
contrast preview, version-summary toggle, and cert-type catalog autofill
silently broke. Realign selectors, regex, and the model-unavailable class;
update stale OpenTrust references in JS/CSS/XML comments and chat storage key.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR updates product branding and DOM naming conventions across the codebase. CSS selectors, JavaScript element IDs, storage keys, and configuration comments are systematically renamed from "OpenTrust"/"opentrust" to "Open Trust Center"/"ettic-otc" to align with new product terminology.

Changes

Open Trust Center Rebranding

Layer / File(s) Summary
CSS Class and Header Updates
assets/css/admin.css, assets/css/chat.css
The "model unavailable" CSS class selector is renamed from .opentrust-ai-model-unavailable to .ettic-otc-ai-model-unavailable. File header comments in both admin and chat stylesheets are updated to use "Open Trust Center" wording.
Admin JavaScript DOM Element References
assets/js/admin.js
Accent warning container ID, color picker input selectors, catalog typeahead meta-key-to-DOM-id mapping, certification type toggle, and policy version toggle are all updated to use ettic_otc/ettic-otc prefixes instead of opentrust. Related inline comments are adjusted accordingly.
Chat and Configuration Naming Updates
assets/js/chat.js, assets/js/frontend.js, wpml-config.xml
Chat controller header comment and sessionStorage key for history persistence are updated to use ettic-otc naming. Frontend header comment updated to "Open Trust Center" branding. WPML configuration documentation comment revised to reflect the new product name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • EtticDevelopment/opentrust#5: This PR introduced the original opentrust-prefixed CSS selector (.opentrust-ai-model-unavailable) and admin DOM IDs; the current PR renames those artifacts to the new ettic-otc equivalents.

Suggested labels

bug

Suggested reviewers

  • nolderoos

Poem

🐰 A rename so neat, so clean, and quite bright,
From OpenTrust old to ettic-otc's light,
CSS rules and DOM IDs align,
Config and storage in harmony shine,
The brand takes flight with a tidy refine!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix admin JS/CSS namespace leaks missed in rename' directly summarizes the main change—correcting namespace mismatches in admin JavaScript and CSS selectors that were missed during a prior rename operation.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/admin-js-css-namespace-leaks

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

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@assets/js/chat.js`:
- Line 25: The sessionStorage key var STORAGE_KEY = 'ettic-otc.chat.history'
will drop existing history stored under 'opentrust.chat.history'; update
loadHistory() to perform a one-time migration: if nothing exists under
STORAGE_KEY but data exists under the old key 'opentrust.chat.history',
copy/parse that value into STORAGE_KEY (and optionally remove the old key) so
existing conversations are preserved; reference the STORAGE_KEY constant and the
loadHistory() function when making this change.
🪄 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 Plus

Run ID: 2b1b5e02-40fa-4939-acef-7ac88ff472c4

📥 Commits

Reviewing files that changed from the base of the PR and between af18711 and 85ecd8e.

📒 Files selected for processing (6)
  • assets/css/admin.css
  • assets/css/chat.css
  • assets/js/admin.js
  • assets/js/chat.js
  • assets/js/frontend.js
  • wpml-config.xml

Comment thread assets/js/chat.js

var strings = config.strings || {};
var STORAGE_KEY = 'opentrust.chat.history';
var STORAGE_KEY = 'ettic-otc.chat.history';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Note: sessionStorage key change will clear existing chat history.

The sessionStorage key has been renamed from opentrust.chat.history to ettic-otc.chat.history. This means users with existing chat history will lose their conversation history after this update, as the code will no longer read from the old key.

This is likely intentional as part of the rebranding, but it's worth noting that the impact is:

  • Existing chat sessions will appear empty on first load after the update
  • Users will need to start fresh conversations

If preserving history is important, you could add a one-time migration in the loadHistory() function that checks the old key and copies data to the new key.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/js/chat.js` at line 25, The sessionStorage key var STORAGE_KEY =
'ettic-otc.chat.history' will drop existing history stored under
'opentrust.chat.history'; update loadHistory() to perform a one-time migration:
if nothing exists under STORAGE_KEY but data exists under the old key
'opentrust.chat.history', copy/parse that value into STORAGE_KEY (and optionally
remove the old key) so existing conversations are preserved; reference the
STORAGE_KEY constant and the loadHistory() function when making this change.

@r00bbert r00bbert merged commit e4aa0bc into main May 21, 2026
11 checks passed
@r00bbert r00bbert deleted the fix/admin-js-css-namespace-leaks branch May 21, 2026 21:45
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