Skip to content

feat: support custom local study plans via json#3

Open
ravikiranp123 wants to merge 1 commit into
NikkyAmresh:mainfrom
ravikiranp123:feat/custom-study-plans
Open

feat: support custom local study plans via json#3
ravikiranp123 wants to merge 1 commit into
NikkyAmresh:mainfrom
ravikiranp123:feat/custom-study-plans

Conversation

@ravikiranp123

Copy link
Copy Markdown

Description:
This PR introduces the ability to load highly structured, custom-categorized study plans without relying on LeetCode's backend API or hardcoding them into the extension's source code.

Key Changes:

  • Config Schema Update: The studyPlans configuration array in .leetcode now supports an optional path property.
  • Local JSON Rendering: When the extension detects the path property, it bypasses the LeetCode API and instead reads the local JSON file.
  • Zero Network Overhead: It seamlessly resolves problem slugs by mapping them against the offline problemset-cache.json, instantly constructing the categorized UI tree in the sidebar exactly like an official LeetCode Study Plan.
  • Documentation: Updated the README.md and .leetcode file with examples of how to configure and structure the custom JSON payload.

@NikkyAmresh

Copy link
Copy Markdown
Owner

Thanks for the submission. I tested it and the feature does work, but the source resolution is ambiguous in a few places, and I would like that fixed before accepting.

1. It is not clear whether a plan loads from LeetCode or from the local JSON

Whether a plan is local depends only on the presence of path, and nothing in the UI indicates the source. If a study plan with the same slug also exists on LeetCode, the user cannot tell which one is being rendered. In my testing I hit exactly this: the sidebar kept showing the questions from LeetCode and ignored my local JSON. Two things in the current code cause that:

  • The .leetcode configuration UI drops path on save. collectConfig() in src/modules/LeetcodeConfigEditor.ts only serializes slug and name (and parseConfigText() in the same file strips path when reading). So as soon as the config is edited through the UI, the plan silently reverts to the LeetCode API.
  • The per-slug cache is shared between sources. The sidebar cache is ~/.lcex/<slug>-cache.json, keyed only by slug. If the local JSON fails to load (missing file, bad path), this.groups ends up empty and the provider falls back to that cache, which can still hold previously fetched LeetCode data for the same slug. The result is stale LeetCode content with no error shown.

2. Please make the source explicit in the configuration UI

Add a per-plan source selector in the .leetcode config editor, for example a dropdown with "LeetCode" and "Local JSON". When "Local JSON" is selected, show a path input and persist path on save. A small badge or tooltip in the Study Plans sidebar showing the source would also help, and the override rule on a slug collision should be stated clearly (local should win whenever path is set).

3. The JSON contract needs to be documented more clearly

The README example is a good start, but please also spell out: the expected shape (category name mapped to an array of problem slugs), which workspace folder a relative path resolves against, and the failure behavior. Right now a missing file or an unknown slug fails silently (empty tree or silently dropped entries); a visible warning would be much better.

Happy to accept once these are addressed.

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.

2 participants