Skip to content

fix: update addSource function to accept parameters and improve butto…#2011

Merged
deadlyjack merged 1 commit intomainfrom
extension-tsconfig-fix
Apr 4, 2026
Merged

fix: update addSource function to accept parameters and improve butto…#2011
deadlyjack merged 1 commit intomainfrom
extension-tsconfig-fix

Conversation

@deadlyjack
Copy link
Copy Markdown
Member

…n onclick handler

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 4, 2026

Greptile Summary

This PR refactors the addSource function in the extensions sidebar to accept sourceType and value parameters, enabling a retry-with-pre-filled-value UX when plugin installation fails. It also fixes a subtle but important bug in the button's onclick handler.

  • onclick fix: Changed onclick={addSource} to onclick={() => addSource()}. Without the arrow wrapper, the browser's MouseEvent would be passed as the first argument (sourceType). Since a MouseEvent is truthy, the source-type selection dialog would be skipped, and the sourceType === "remote" comparison would always be false, silently falling through to FileBrowser regardless of intent.
  • addSource refactor: Now accepts an optional sourceType and value (default "https://"). If sourceType is not provided, the user is prompted to choose remote/local. On installation failure, the catch block retries with addSource(sourceType, source) to pre-populate the URL field — however, this recursive call is not awaited (same pattern also in src/pages/plugins/plugins.js:727).
  • tsconfig.json cleanup: Removes baseUrl: "./src" and updates paths from "*": ["*"] (resolved relative to the old baseUrl) to "*": ["./src/*"] (explicit relative path from the project root). These are functionally equivalent under TypeScript 5.0+ with moduleResolution: "bundler".

Confidence Score: 4/5

Safe to merge — the onclick fix is correct and important, and the addSource refactor logic is sound; one minor unhandled-promise concern on the retry call.

The onclick arrow-wrapper fix is the most important change and is correctly implemented. The addSource parameter refactor is well-designed, enabling pre-filled retry. The only concern is the missing await on the recursive addSource call in the catch block, which could silently swallow unhandled rejections in edge cases but is unlikely to affect normal usage. The tsconfig change is a safe, equivalent cleanup.

src/sidebarApps/extensions/index.js — unawaited recursive addSource call on line 400

Important Files Changed

Filename Overview
src/sidebarApps/extensions/index.js Refactors addSource to accept sourceType and value params enabling retry with pre-filled URL; fixes button onclick to prevent click event being passed as sourceType; missing await on recursive retry call in catch block.
tsconfig.json Removes baseUrl and makes paths explicit with ./src/*; functionally equivalent for TypeScript 5.0+ bundler module resolution.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([Button Click]) --> B["addSource()"]
    B --> C{sourceType\nprovided?}
    C -->|No| D[Show select dialog\nremote / local]
    D --> E{User selected?}
    E -->|No| Z([Return])
    E -->|Yes| F{sourceType\n=== 'remote'?}
    C -->|Yes, skip dialog| F
    F -->|Yes| G["prompt('Enter plugin source', value, 'url')"]
    F -->|No| H["FileBrowser('file', ...)"]  
    G --> I{source\nprovided?}
    H --> I
    I -->|No| Z
    I -->|Yes| J[installPlugin(source)]
    J --> K{Success?}
    K -->|Yes| L[Reload explore / installed lists]
    K -->|No| M[toast error message]
    M --> N["addSource(sourceType, source)\n⚠️ not awaited"]
    N --> F
Loading

Comments Outside Diff (1)

  1. src/sidebarApps/extensions/index.js, line 400 (link)

    P2 Missing await on recursive retry call

    The recursive addSource call in the catch block is not awaited. As a fire-and-forget call, any unexpected rejection from dialog operations (e.g. select, prompt, or FileBrowser throwing) will become a silent unhandled promise rejection. Adding await (or return) keeps the retry correctly chained.

    Note: the same unawaited pattern also exists at src/pages/plugins/plugins.js:727.

Reviews (1): Last reviewed commit: "fix: update addSource function to accept..." | Re-trigger Greptile

@deadlyjack deadlyjack merged commit d6ddb87 into main Apr 4, 2026
8 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