Skip to content

[plugins] add LeetCode Summary bar plugin - #228

Merged
neur0map merged 3 commits into
Ryoku-dev:mainfrom
mannish01:add-leetcode-summary
Nov 30, 2026
Merged

neur0map merged 3 commits into
Ryoku-dev:mainfrom
mannish01:add-leetcode-summary

Conversation

@mannish01

Copy link
Copy Markdown
Contributor

What is this?

Adds LeetCode Summary, a community topbarGlyph plugin: a small LC glyph on the bar with a click-through panel showing that installer's LeetCode solved counts, global rank, difficulty split, streak, acceptance rate and 12-week activity grid. First uploaded to https://github.com/mannish01/LeetCode-Summary, now proposed for the Ryostore catalogue for approval.

Why each installer sees their own summary

The panel has an editable username field — type a handle and press Enter, and pluginApi.saveSetting("username", …) plus a refresh shows that account's stats. The same username setting (default MANISHX01, the contributor's profile, so the preview is non-empty) is available under QS Bar Settings > Community > LeetCode Summary. It uses the same public alfa-leetcode-api as the contributor's portfolio; no token or login is needed.

Changes

  • New plugins/leetcode-summary/ with manifest.json, service/Main.qml, content/Widget.qml, content/Panel.qml, bin/leetcode_summary.py, README.md, LICENSE and a real panel preview.
  • New plugins/registry.json entry: official: false, upstream mannish01/LeetCode-Summary, lastUpdated 2026-11-29.
  • Generated product-manifest.json and refreshed manifestSha256 with tools/pack-product.py --touch.

Security and privacy

  • Network hosts declared: alfa-leetcode-api.onrender.com (read-only public stats) and leetcode.com (opened only on an explicit OPEN PROFILE click).
  • Username is URL-encoded as one path component, never passed to a shell. No credentials, privileged commands, shell strings built from data, secrets or binaries.
  • Writes only summary.json under the plugin's own stateDir. A snapshot is live only when all three endpoints answer; a partial outage reuses a matching cached snapshot (marked SAVED.) and never overwrites a good cache. A cache is only read for the username it belongs to.

Checklist

  • One folder under its catalogue with a manifest and a real preview image captured from the rendered panel (not a placeholder).
  • One entry added to plugins/registry.json (lastUpdated 2026-11-29, official: false, manifest hash refreshed).
  • Tested live: rendered the actual Panel.qml in Quickshell with sample stats; the panel shows the header, editable handle, solved count, rank/streak/acceptance cards, E/M/H bars, 12-week grid and both buttons, with a clean log (only the benign textinput focus warning).
  • Mocked-endpoint tests for the helper: full response → live with correct activity dot, rank text and acceptance; partial outage → saved snapshot preserved; other username offline → no cross-account data.
  • tests/validate-catalogue.sh passes from the repo root.
  • tests/validate-store.py --categories plugins passes.
  • ryoku plugin validate plugins/leetcode-summary → 0 blocking, 0 warnings.
  • tools/security-screen.py --staged → 0 blocking, 0 errors; 0 findings in this plugin.
  • I own the content, MIT licensed; it overwrites no user configuration and runs no privileged commands.

A topbarGlyph plugin driven by the public alfa-leetcode-api used in the portfolio. An editable username setting means every installer sees their own LeetCode summary. Complete snapshots are cached under stateDir and partial outages never overwrite a good cache.

@neur0map neur0map left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔴 Changes requested — 0 critical and 1 major issue(s): see the inline comments and the walkthrough for fixes and an agent-ready prompt.

🧹 Nitpicks (2) — optional, not blocking
  1. plugins/leetcode-summary/service/Main.qml:69-74 — Bug — If the username changes while a request is running, refresh() returns without starting a new request, and the old response replaces the displayed stats. Discard that response and start a request for the current usernam…

    Suggested change

onExited: {
    svc.loading = false;
    if (statusProc.command[3] !== svc.username) {
        Qt.callLater(svc.refresh);
        return;
    }
    if (String(summaryErr.text).trim().length > 0) console.warn("LEETCODE_SUMMARY_ERR", summaryErr.text);
    if (!svc.applyOutput(summaryOut.text))
        svc.errorText = String(summaryErr.text).trim().slice(0, 80) || "stats unavailable";
}
  1. plugins/leetcode-summary/service/Main.qml:69-74 — Suggestion: bug — Refresh after an in-flight username change

    Suggested change

onExited: {
    svc.loading = false;
    if (statusProc.command[3] !== svc.username) {
        Qt.callLater(svc.refresh);
        return;
    }
    if (String(summaryErr.text).trim().length > 0) console.warn("LEETCODE_SUMMARY_ERR", summaryErr.text);
    if (!svc.applyOutput(summaryOut.text))
        svc.errorText = String(summaryErr.text).trim().slice(0, 80) || "stats unavailable";
}

@neur0map

neur0map commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

🦊 mika's review

Incremental review: new commits since the last checkpoint.

Summary

  • Add a community bar plugin for LeetCode profile statistics.
  • Support configurable usernames, polling, and saved-snapshot fallback.
  • Register the plugin and its installation manifest in the catalogue.

Estimated review effort: 1/5 · risk: low

📁 Walkthrough details

plugins/leetcode-summary/service/Main.qml

  • Manages settings, polling, helper execution, and shared statistics for both views.
  • Queues refreshes during an active request and discards obsolete account results.
    • Adds a timeout and starts queued refreshes after completion or timeout.
    • Clears displayed statistics when the configured username changes.

plugins/leetcode-summary/bin/leetcode_summary.py

  • Fetches profile, solved, and calendar data concurrently and emits a compact JSON snapshot.
  • Falls back to a matching account's saved snapshot when an endpoint fails.
    • URL-encodes usernames and computes acceptance, rank text, and activity dots.
    • Writes complete snapshots to summary.json in the plugin state directory.

plugins/leetcode-summary/content/Panel.qml

  • Adds a summary panel with editable username, statistics, difficulty bars, and activity grid.
    • Saves username changes and provides refresh and profile-opening controls.
    • Shows live or saved status and an offline indicator.

plugins/leetcode-summary/content/Widget.qml

  • Adds an LC bar glyph that opens the summary panel.
    • Optionally displays the solved count and shows profile statistics in a tooltip.

plugins/leetcode-summary/manifest.json

  • Declares the community plugin's entry points, network hosts, Python dependency, and settings.
    • Configures username, polling interval, and bar count defaults.

plugins/leetcode-summary/product-manifest.json

  • Defines the product's installation destination, file hashes, and install flags.
    • Lists runtime files alongside non-installed documentation and preview assets.

plugins/registry.json

  • Registers LeetCode Summary as an unofficial catalogue plugin with upstream and preview metadata.
    • Links the product manifest and its SHA-256 hash.

plugins/leetcode-summary/README.md

  • Documents the plugin's views, settings, privacy behavior, and installation commands.
    • Describes API access and account-specific cache fallback.

plugins/leetcode-summary/LICENSE

  • Adds the author's MIT license and copyright notice.

No actionable findings. Mika looked for bugs, security issues, and risks in the diff and came up empty on clear defects.

🚦 Merge recommendation: no_concerns_found


🦊 Generated by Mika — the Ryoku org's self-hosted AI code reviewer. Machine findings: verify before merging.

A result for a username changed while its process ran is consumed but ignored, settings and panel changes queue a refresh, and the timeout path finishes through the same queue.
@mannish01

Copy link
Copy Markdown
Contributor Author

Addressed the username-change finding in 3d7c731. Stale results are discarded, username changes queue a refresh instead of being dropped while a process runs, and the queue is drained from the exit/timeout path. Source repo is in sync at https://github.com/mannish01/LeetCode-Summary. Revalidated: 0 blocking / 0 warnings, catalogue + store validators pass, staged security screen 0 blocking / 0 errors with 0 findings in this plugin. Requesting re-review.

@neur0map neur0map left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔴 Changes requested — 0 critical and 1 major issue(s): see the inline comments and the walkthrough for fixes and an agent-ready prompt.

The timeout path now calls finishRefresh() instead of clearing loading directly, so a queued username change starts as soon as the stalled process is stopped.
@mannish01

Copy link
Copy Markdown
Contributor Author

Fixed the follow-up finding in 246c270: the timeout path now calls finishRefresh(), so a queued username change starts as soon as the stalled process is stopped. Source repo synced at https://github.com/mannish01/LeetCode-Summary (f811fe5). Revalidation clean: 0 blocking/0 warnings, catalogue + store pass, security screen 0 errors and 0 findings in this plugin.

@neur0map
neur0map dismissed stale reviews from themself November 29, 2026 19:03

Blocking findings were addressed (verified at 246c270d15).

@neur0map
neur0map merged commit 2b61f9d into Ryoku-dev:main Nov 30, 2026
2 checks passed
neur0map added a commit that referenced this pull request Nov 30, 2026
@neur0map

Copy link
Copy Markdown
Member

Thanks for the work here, merged with the default username left empty and a 120 second minimum poll, it's live in the store now

@mannish01

Copy link
Copy Markdown
Contributor Author

Addressed the maintainer's request from #227: the desktop tile is now a second host inside this plugin, so there is no separate copy of the stats code.

What changed in 5c2af7f

  • content/Widget.qml now dispatches on density like Coffee/VPN: Glyph.qml for topbarGlyph, Card.qml for desktopWidget.
  • content/Glyph.qml is the unchanged bar glyph; content/Card.qml is the paper-and-ink desktop tile (solved count, rank, difficulty bar, streak, acceptance, top languages, 12-week activity, click to open the configured profile).
  • One shared service/Main.qml and one helper. The helper now also fetches /language, so the tile shows the language mix without a second script, and all four endpoints must succeed before a snapshot is called live or the cache is rewritten.
  • Manifest/registry are 0.2.0, hosts: [topbarGlyph, desktopWidget], densities glyph/compact, both preview images included, official: false.
  • Both views read the same username/poll settings. Per-user behaviour is unchanged: set a handle in the panel, press Enter, both views switch and a username-scoped cache is used offline.

Verification

  • Helper tests: all-live live=true, 37 solved, 3.37M rank, 64%, languages sorted, dot level 3; /solved outage and /language outage each give live=false with saved 37; offline other user gives 0. All passed.
  • ryoku plugin validate plugins/leetcode-summary → 0 blocking, 0 warnings.
  • tests/validate-catalogue.sh and tests/validate-store.py --root . --categories plugins → OK.
  • tools/security-screen.py --staged → 0 blocking, 232 warning(s), 0 error(s), leetcode-summary findings: 0.
  • Quickshell harness loaded Card.qml through the new dispatcher with fake stats (solved: 37) and no QML errors; the tile design is the already-rendered Pulse preview at assets/preview-desktop.png.

Source repo updated first: https://github.com/mannish01/LeetCode-Summary (commit 4cc12e5). Re-review requested — the requested follow-up from #227 is now in this PR.

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