Skip to content

feat(notes): accept a problem name as well as a problem ID - #50

Merged
night-slayer18 merged 3 commits into
night-slayer18:devfrom
acid-boi:feat/note-problem-name
Sep 10, 2026
Merged

night-slayer18 merged 3 commits into
night-slayer18:devfrom
acid-boi:feat/note-problem-name

Conversation

@acid-boi

Copy link
Copy Markdown
Contributor

Summary

leetcode note now accepts a problem name (title slug) in addition to a numeric problem ID, so leetcode note two-sum edit works the same way leetcode note 1 edit always has.

  • A name is resolved through the LeetCode API and the returned frontend ID names the note file, so both forms read and write the same file on disk.
  • The resolved problem is handed to the note template generator, so creating a note by name costs a single API call rather than two.
  • Input that is neither an ID nor a slug is rejected locally with a clear message, without an API round trip.
  • An unknown name reports Problem "..." not found instead of dumping the raw Zod validation error, while genuine network failures still surface their message.

Motivation / Context

pick, show, hint, reset, submissions and timer all accept either a problem ID or a title slug. note was the odd one out and rejected anything non-numeric, which meant switching mental models mid-session: pick a problem by name, then look up its number to write a note about it.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • CI / Tooling / Refactoring

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the relevant documentation / release notes
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally (npm test)
  • Type check passes (npm run typecheck)
  • Linter passes (npm run lint)

How to test

npm run build

leetcode note two-sum view      # resolves to problem 1
leetcode note 1 view            # same note file, unchanged behaviour
leetcode note "Two Sum" view    # rejected locally, no API call
leetcode note not-a-problem view # clean "not found" message

Notes for the reviewer

isTitleSlug is deliberately the only new validation helper, and only note uses it for now. A follow-up PR can share one resolver across every command that takes an ID or a slug, which would also stop show and hint from printing raw Zod errors for an unknown slug.

Existing behaviour is untouched: the TUI passes a numeric ID, so its note path is unchanged, and all 354 existing tests still pass alongside the 5 new ones.

fiftytwo-art and others added 3 commits September 10, 2026 16:09
The note command only accepted a numeric problem ID, while pick, show and
hint already take either an ID or a title slug. Notes now do the same: a
title slug is resolved through the LeetCode API and its frontend ID names
the note file, so both forms point at the same file on disk.

The resolved problem is passed to the note template generator, so creating
a note by name still costs a single API call.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4JwzivBEbeq9u3zAXKUu2
Signed-off-by: acid-boi <yjbmki@gmail.com>
Adds coverage for name lookup, template reuse of the already fetched
problem, rejected input, unknown names and unexpected lookup failures.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4JwzivBEbeq9u3zAXKUu2
Signed-off-by: acid-boi <yjbmki@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4JwzivBEbeq9u3zAXKUu2
Signed-off-by: acid-boi <yjbmki@gmail.com>
@github-actions github-actions Bot added the enhancement New feature or request label Sep 10, 2026
@acid-boi acid-boi closed this Sep 10, 2026
@acid-boi acid-boi reopened this Sep 10, 2026
@acid-boi
acid-boi changed the base branch from main to dev September 10, 2026 11:51
@night-slayer18
night-slayer18 merged commit cf5a8cc into night-slayer18:dev Sep 10, 2026
24 checks passed
@night-slayer18

night-slayer18 commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

hey @acid-boi, nice one! slug resolver is looking clean. good catch on reusing the fetched problem for the template too, saves the extra API call. error messages are way cleaner now and the tests cover the important stuff. merged 👍

@night-slayer18

Copy link
Copy Markdown
Owner

also saw your note about the shared resolver — yeah that's worth doing. if you're up for it, raise a PR that pulls that ID-or-slug resolution logic into a shared utility and wires up show, hint, reset, submissions and timer to use it. the raw Zod error thing on unknown slugs has been bugging me for a while so would be great to fix that across the board at the same time 👍

Repository owner deleted a comment from github-actions Bot Sep 10, 2026
@night-slayer18 night-slayer18 mentioned this pull request Oct 14, 2026
11 of 13 tasks
night-slayer18 added a commit that referenced this pull request Oct 14, 2026
Merge dev into main for v3.6.0 release:
- Add --lang option to commands locating solutions by problem ID (#56)
- Add shared problem resolver and title slug support (#50)
- Resolve dependency audit vulnerabilities

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants