Skip to content

Conversation

@TutTrue
Copy link

@TutTrue TutTrue commented Nov 6, 2025

What type of PR is this? (check all applicable)

  • ✨ Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • ♻️ Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert
  • 🌐 Internationalization / Translation

Description

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentations?

  • 📓 docs (./docs)
  • 📕 storybook (./storybook)
  • 📜 README.md
  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Summary by CodeRabbit

  • New Features

    • Added templates search functionality to filter templates by language directly within the templates modal.
    • Implemented debounced search input for improved performance when filtering through available templates.
  • Improvements

    • Updated starter template metadata with centralized naming for enhanced consistency.
    • Added internationalization support for the new templates search feature.

@netlify
Copy link

netlify bot commented Nov 6, 2025

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit b9318ef
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/690cc94f8ac01f0008c8c6b2
😎 Deploy Preview https://deploy-preview-913--livecodes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2025

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

The pull request introduces a template search feature across multiple layers: adding a search input UI element to the templates modal, implementing debounced event-driven filtering in TypeScript, and adding localization strings. Additionally, starter template definitions are refactored to use a centralized naming function instead of hard-coded strings.

Changes

Cohort / File(s) Change Summary
Template Definitions Refactoring
functions/vendors/templates.js
Updated starter template entries to derive titles via getTemplateName() instead of hard-coded strings; minor content adjustments and text refinements in multiple template blocks (e.g., Go Wasm, Jest React); input/output handling tweaks.
Search Feature Implementation
src/livecodes/UI/templates.ts
Added debounce utility import; wired input event listener on #templates-search-input that dispatches a debounced templates:filter CustomEvent with trimmed query value (150ms debounce interval).
Search UI
src/livecodes/html/templates.html
Added templates search container with visually hidden label and search input field (id: templates-search-input) for template filtering.
Internationalization
src/livecodes/i18n/locales/en/translation.lokalise.json, src/livecodes/i18n/locales/en/translation.ts
Added new localization key templates.search.label with translation "Search templates" in both JSON and TypeScript translation files.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant SearchInput as templates-search-input
    participant Debounce as debounce(150ms)
    participant EventDispatcher as CustomEvent Dispatch
    participant Handler as templates:filter Handler

    User->>SearchInput: Types query
    SearchInput->>Debounce: input event fires
    Debounce->>Debounce: Reset timer
    Note over Debounce: Wait 150ms with no new input
    Debounce->>EventDispatcher: Trigger after timeout
    EventDispatcher->>Handler: Dispatch templates:filter event
    Handler->>Handler: Process query (trim & filter)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring attention:

  • Verify that all starter templates in functions/vendors/templates.js correctly call getTemplateName() and that the function is properly available/exported.
  • Confirm the templates:filter CustomEvent is consumed/handled elsewhere in the codebase (not shown in this diff).
  • Validate that localization keys in both .lokalise.json and .ts files remain synchronized across all locale files (only English shown in diff).
  • Ensure the 150ms debounce interval is appropriate for search responsiveness and performance requirements.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references continuing work from PR #901 but does not clearly describe the actual changes: adding template search functionality with debounced filtering and localization support. Consider a more descriptive title that summarizes the main feature, such as 'Add template search functionality with debounced filtering' or similar.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link

@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: 0

🧹 Nitpick comments (3)
src/livecodes/i18n/locales/en/translation.lokalise.json (1)

2551-2554: Add complementary i18n keys for placeholder/aria to keep UI consistent.

Label looks good. Please also add templates.search.placeholder and templates.search.ariaLabel in the source that generates this file to localize the input attributes used in templates.html. Avoid editing this generated file directly.

src/livecodes/i18n/locales/en/translation.ts (1)

985-987: Extend the search entry to cover placeholder/aria strings.

Please add templates.search.placeholder and templates.search.ariaLabel in the source that generates this file, so the HTML attributes can be localized alongside the label. Don’t hand-edit this generated file.

src/livecodes/html/templates.html (1)

14-24: Accessibility/i18n polish: unify wording, localize attributes, add aria-controls.

  • “Search templates” vs “Filter languages…” vs “Filter templates by language” is inconsistent.
  • Localize placeholder and aria-label; add aria-controls for relation to the list.

Proposed minimal HTML tweak:

-      <input
-        id="templates-search-input"
-        type="search"
-        placeholder="Filter languages..."
-        aria-label="Filter templates by language"
-      />
+      <input
+        id="templates-search-input"
+        type="search"
+        placeholder="Search templates"
+        aria-label="Search templates"
+        aria-controls="starter-templates-list"
+        enterkeyhint="search"
+        autocomplete="off"
+        spellcheck="false"
+        autocapitalize="off"
+      />

Then wire placeholder/aria-label to the new i18n keys you add (templates.search.placeholder, templates.search.ariaLabel).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d1d304 and b9318ef.

📒 Files selected for processing (5)
  • functions/vendors/templates.js (8 hunks)
  • src/livecodes/UI/templates.ts (2 hunks)
  • src/livecodes/html/templates.html (1 hunks)
  • src/livecodes/i18n/locales/en/translation.lokalise.json (1 hunks)
  • src/livecodes/i18n/locales/en/translation.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/livecodes/UI/templates.ts (1)
src/livecodes/utils/utils.ts (1)
  • debounce (4-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Redirect rules - livecodes
  • GitHub Check: Header rules - livecodes
  • GitHub Check: Pages changed - livecodes
🔇 Additional comments (7)
src/livecodes/UI/templates.ts (2)

3-3: LGTM. Importing debounce here is appropriate.


32-46: <!-- [scratchpad_start]
[task verify_listener_locations COMPLETE]
[observations]

  • Comprehensive search shows 'templates:filter' appears ONLY at lines 32 and 36 in src/livecodes/UI/templates.ts
  • Line 32: Comment about the event
  • Line 36: The CustomEvent creation and dispatch
  • NO listeners found anywhere in the codebase for this event
  • NO event listeners registered for templates:filter in any TypeScript or JavaScript file
    [analysis]
  • CRITICAL: The review assumes listeners exist "above templatesContainer" but they don't exist anywhere
  • The event is emitted but never consumed in the codebase
  • The review's suggestion is based on a false premise
  • Either:
    (a) This is defensive coding for future listeners (but none planned)
    (b) The review was written for a different version of the code
    (c) The reviewer misunderstood the code flow
    [conclusion]
  • The review comment is INCORRECT
  • Adding bubbles:true and composed:true has no effect if there are no listeners
  • This is unnecessary defensive coding without any consumers of the event
    [done]
  • Verification confirms: no listeners exist for templates:filter anywhere in codebase
    </scratchpad_end] -->

Remove this suggestion—no listeners for "templates:filter" exist in the codebase.

A comprehensive search shows the templates:filter event is emitted only at line 36 but never listened to anywhere in the codebase. The review assumes listeners are "attached above templatesContainer," but none exist. The suggested bubbles: true and composed: true flags have no practical effect without actual event listeners. If listeners are planned for the future, this can be addressed then; otherwise, the change is unnecessary defensive coding.

Likely an incorrect or invalid review comment.

functions/vendors/templates.js (5)

1199-1199: Go (Wasm) demo improvements look good.

  • Clearer UI, safe DOM updates via textContent, stdin parsing with TrimSpace/Atoi works.
  • Handlers enable/disable controls correctly.

No blockers.

Also applies to: 1233-1239, 1245-1245, 1252-1253, 1328-1353


696-696: No action needed. Looks like a non-functional change (closing snippet/format).


1474-1474: No action needed. Trivial change at end of JS starter snippet.


1646-1646: No action needed. Minor change at end of Jest tests block.


3956-3956: No action needed. Minor change at end of WAT snippet.

@hatemhosny
Copy link
Collaborator

Thank you @TutTrue

Would you please check with @a0m0rajab first to make sure he is no longer available for working on this, or if he wants some help?

@TutTrue
Copy link
Author

TutTrue commented Nov 6, 2025

Thank you @TutTrue

Would you please check with @a0m0rajab first to make sure he is no longer available for working on this, or if he wants some help?

Sure

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.

3 participants