Skip to content

feat: add language-mode plugin recommendation system#2368

Merged
bajrangCoder merged 5 commits into
mainfrom
feat/recommendation-system
Jun 24, 2026
Merged

feat: add language-mode plugin recommendation system#2368
bajrangCoder merged 5 commits into
mainfrom
feat/recommendation-system

Conversation

@bajrangCoder

Copy link
Copy Markdown
Member

No description provided.

@bajrangCoder bajrangCoder marked this pull request as ready for review June 23, 2026 10:57
@bajrangCoder bajrangCoder requested a review from deadlyjack June 23, 2026 10:57
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a language-mode plugin recommendation system: when a file opens as plain text because no syntax mode is installed, Acode checks the plugin API and either suggests an existing plugin (with a "Search plugins" action) or offers a GitHub issue link to request one. The feature is opt-out via a new recommendExtensions editor setting, and the notification UI gains a generic actions button row.

  • Core logic (languageModeRecommendations.js): singleton with pendingKeywords deduplication, availabilityCache to avoid repeated API calls per session, conservative false on network failure, and lazy-loaded sidebar integration.
  • Extensions sidebar (extensions/index.js): search logic extracted into runSearch; new openWithSearch export uses requestAnimationFrame polling (up to 1 s) to wait for panel initialisation before executing the programmatic search.
  • Notification (notificationManager.js + notification.scss): optional actions array renders styled action buttons that stop propagation so the parent notification's action handler is not double-fired.

Confidence Score: 5/5

Safe to merge — the feature is entirely additive, opt-out by default, and the previously flagged bugs have been addressed in this revision.

The recommendation engine uses conservative defaults (no notification on network failure, deduplication via pendingKeywords, notifiedKeywords marked only after success), and the extensions sidebar integration guards against uninitialised state via waitForSearchInput. The two remaining observations are edge-case silent failures that do not affect correctness under normal conditions.

No files require special attention beyond the two minor edge cases noted in languageModeRecommendations.js and extensions/index.js.

Important Files Changed

Filename Overview
src/lib/languageModeRecommendations.js New core module: singleton recommendation engine with pending-set deduplication, conservative false on network failure, and lazy-loading of the extensions sidebar. Minor: strings global is implicit (idiomatic in this codebase); openExtensions errors are silently swallowed.
src/sidebarApps/extensions/index.js Search logic extracted into standalone runSearch; openWithSearch exported with requestAnimationFrame-based polling to wait for panel initialisation before executing the search. The 1-second timeout silently no-ops on slow devices.
src/lib/notificationManager.js Adds optional actions array to notification props; each button stops propagation and calls the individual action. Toast auto-dismissal still fires after 5 s.
src/lib/editorFile.js Adds maybeRecommendLanguageModeExtension helper; called after mode is set. Setting check correctly uses === false so the feature activates by default for both new and upgraded users.
src/lib/settings.js Adds recommendExtensions: true default. No issues.
src/settings/editorSettings.js Exposes the new toggle under the assistance category; correctly falls back to true with ?? true. No issues.
src/styles/notification.scss Well-structured action-button styles using CSS custom properties and color-mix; handles overflow with ellipsis and includes focus-visible ring. No issues.
src/lang/en-us.json All 7 new keys added correctly; template placeholders match the formatString call-sites.
src/lang/ar-ye.json New keys added with verbatim English text (noted in prior thread); same pattern across all 31 non-English locale files.
src/lang/index.d.ts Type definitions updated to include all 7 new keys in the correct positions. No issues.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant EF as editorFile.js
    participant LMR as languageModeRecommendations.js
    participant API as Plugin API
    participant NM as notificationManager
    participant EXT as extensions/index.js

    EF->>EF: setMode(mode, modeInfo)
    EF->>LMR: maybeRecommendLanguageModeExtension(file, modeInfo)
    Note over LMR: check recommendExtensions setting
    LMR->>API: "fetch /plugins?name=keyword"
    alt plugins found
        API-->>LMR: plugin list
        LMR->>NM: pushNotification with Search plugins action
        NM-->>EF: toast shown, auto-dismiss 5s
        NM->>EXT: openWithSearch(keyword)
        EXT->>EXT: waitForSearchInput poll up to 1s
        EXT->>EXT: runSearch(keyword)
    else no plugins or error
        API-->>LMR: empty or failure
        LMR->>NM: pushNotification with Request plugin action
        NM->>NM: openUrl GitHub issue
    end
    LMR->>LMR: notifiedKeywords.add(keyword)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant EF as editorFile.js
    participant LMR as languageModeRecommendations.js
    participant API as Plugin API
    participant NM as notificationManager
    participant EXT as extensions/index.js

    EF->>EF: setMode(mode, modeInfo)
    EF->>LMR: maybeRecommendLanguageModeExtension(file, modeInfo)
    Note over LMR: check recommendExtensions setting
    LMR->>API: "fetch /plugins?name=keyword"
    alt plugins found
        API-->>LMR: plugin list
        LMR->>NM: pushNotification with Search plugins action
        NM-->>EF: toast shown, auto-dismiss 5s
        NM->>EXT: openWithSearch(keyword)
        EXT->>EXT: waitForSearchInput poll up to 1s
        EXT->>EXT: runSearch(keyword)
    else no plugins or error
        API-->>LMR: empty or failure
        LMR->>NM: pushNotification with Request plugin action
        NM->>NM: openUrl GitHub issue
    end
    LMR->>LMR: notifiedKeywords.add(keyword)
Loading

Reviews (2): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread src/lib/languageModeRecommendations.js Outdated
Comment thread src/sidebarApps/extensions/index.js Outdated
Comment thread src/lib/languageModeRecommendations.js
Comment thread src/lang/ar-ye.json
@bajrangCoder

This comment was marked as outdated.

@bajrangCoder bajrangCoder merged commit e822817 into main Jun 24, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Jun 24, 2026
@bajrangCoder bajrangCoder deleted the feat/recommendation-system branch June 24, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant