Skip to content

feat: LeetCode China full support + credential UX improvements (v3.1.0)#11

Merged
night-slayer18 merged 18 commits into
mainfrom
dev
May 1, 2026
Merged

feat: LeetCode China full support + credential UX improvements (v3.1.0)#11
night-slayer18 merged 18 commits into
mainfrom
dev

Conversation

@night-slayer18
Copy link
Copy Markdown
Owner

@night-slayer18 night-slayer18 commented May 1, 2026

Summary

This PR merges the dev branch into main for the v3.1.0 release.

What's Included

🌏 LeetCode China (leetcode.cn)

  • Full site-aware GraphQL query routing — separate CN query packs, Zod schemas, and response adapters
  • Site selection in login, config, and workspace commands
  • Workspace config persists site preference
  • TUI site switch forces immediate session logout with confirmation modal

🔐 Credential UX

  • leetcode login --help explains all 3 backends: Keychain, Encrypted File, Env Vars
  • TUI site-switch bug fixed: in-memory session now correctly cleared on confirmation

🧪 Tests

  • 283/283 passing on Node 20/22/24 (Ubuntu + macOS)
  • versionStorage and network mocks added to prevent CI flakiness

Commits Since v3.0.1

  • 3552caf chore(release): prepare v3.1.0
  • 286dd03 fix(docs/tui): add auth backend details to CLI help & force active session clear on TUI site switch
  • c22ff26 fix: ensure credential clearance on site switch & improve CLI test safety
  • 46893c4 Merge pull request feat: complete leetcode.cn support for problem list, detail, and id-based lookup #10 from dong-frank/feat/leetcode.cn
  • de623e0 feat: add support for 'list' and other commands for leetcode.cn
  • f9e6d4c feat: add support for leetcode.cn in tui
  • 84f91ba ci: run CI and CodeQL workflows on dev branch
  • d85689a docs: document leetcode.cn site support
  • 8d8bc72 test: add tests for CN adapters, query resolver, and site-aware mocks
  • 46ecab5 feat: add site support to TUI config and effects
  • ee94495 feat: add site selection to login, config, and workspace commands
  • 4e9cb7c feat: configure client site from workspace config on auth
  • 3f5e15c feat: persist site selection in workspace config
  • 09822e4 feat: make LeetCodeClient site-aware
  • ecceb06 feat: add CN response adapters for data normalization
  • c47f8c6 feat: add Zod schemas for leetcode.cn API responses
  • a5aec84 feat: split GraphQL queries into site-specific packs
  • b855ad8 feat: add LeetCodeSite type and site utility helpers

night-slayer18 and others added 18 commits April 20, 2026 23:34
- Add LeetCodeSite type ('leetcode.com' | 'leetcode.cn') to types.ts
- Add optional site field to UserConfig interface
- Create src/utils/site.ts with site constants, alias map,
  normalization, and label helpers
- Default site is leetcode.com for backward compatibility

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Create queries.global.ts with existing leetcode.com queries
  and QueryPack interface
- Create queries.cn.ts with CN-specific queries for daily
  challenge (todayRecord), user profile, and skill stats
- Create query-resolver.ts to select the correct QueryPack
  based on configured LeetCodeSite
- Reduce queries.ts to backward-compatible re-exports

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add CnDailyChallengeSchema for todayRecord response shape
- Add CnUserProfileSchema for userProfilePublicProfile and
  userProfileUserQuestionProgress response shapes
- Add CnSkillStatsSchema for skillSet topicAreaScores shape
- All CN schemas use lenient optional fields to handle
  evolving API responses gracefully

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Create adapters/cn.ts with normalization functions:
  - normalizeCnDailyChallenge: maps todayRecord[0] to DailyChallenge
  - normalizeCnUserProfile: maps split CN profile queries to
    unified profile shape
  - normalizeCnSkillStats: maps topicAreaScores into
    fundamental/intermediate/advanced buckets
- Create adapters/index.ts barrel export

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Accept LeetCodeSite in constructor, default to leetcode.com
- Add setSite()/getSite() for runtime site switching
- Use QueryPack from query-resolver for all GraphQL operations
- Add GraphQLOperation type with labeled error messages
- Add multi-endpoint fallback for CN submissions (noj-go)
- Add CN-specific schema mismatch error detection with
  helpful recovery message
- Wire CN adapters for daily challenge, user profile,
  and skill stats normalization

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add site field to WorkspaceConfig interface
- Add getSite()/setSite() to config storage module
- Default new workspaces to leetcode.com
- Site selection is per-workspace for isolation

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add configureLeetCodeClientSite() helper that reads site
  from config and calls setSite() on the singleton client
- Call it in validateSession, requireAuth, setupClientIfLoggedIn,
  and getCurrentUsername to ensure correct site before API calls

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- login: add site picker prompt before cookie input,
  show domain-specific instructions, persist selection
- config: add --site flag and interactive site selection,
  display site in config output
- workspace: show site in workspace list and current output,
  default new workspaces to leetcode.com
- index: add --site option to config command help text

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add site option to config screen with validation
- Wire configureLeetCodeClientSite in executeCommand entry
- Handle site saves in saveConfig effect
- Show site example hint in config detail view

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add cn-adapter.test.ts covering daily challenge, user profile,
  and skill stats normalization
- Add query-resolver.test.ts verifying correct pack selection
- Update mock client with setSite method
- Update auth, config, and integration tests with site mocks
- Add site config assertion to e2e cross-OS tests

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- README: add site support section with config examples
- commands.md: document --site flag and login site picker
- config.md: add site to config table and setup steps
- index.md: add site-aware API support to features list
- testing.md: note site selection in e2e test coverage

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
- Add dev to push and pull_request branch triggers in ci.yml
- Add dev to push and pull_request branch triggers in codeql.yml

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
feat: complete leetcode.cn support for problem list, detail, and id-based lookup
…fety

- Add interactive confirmation prompt before clearing credentials when switching sites in CLI and TUI

- Skip interactive prompts and auto-update background checks in non-TTY environments

- Mock got network requests in update and changelog command tests to prevent rate limit failures

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
…ssion clear on TUI site switch

Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
Signed-off-by: night-slayer18 <samanuaia257@gmail.com>
@night-slayer18 night-slayer18 merged commit 2d4900d into main May 1, 2026
22 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.

2 participants