Skip to content

feat(install): add GitHub search panel to discover and install skills/plugins/MCP - #32

Open
hzqstc88 wants to merge 6 commits into
wanghuan9:mainfrom
hzqstc88:codex-mvp
Open

hzqstc88 wants to merge 6 commits into
wanghuan9:mainfrom
hzqstc88:codex-mvp

Conversation

@hzqstc88

Copy link
Copy Markdown

No description provided.

MVP 1st cut - search GitHub repositories from inside the app, see them
sorted by stars, copy clone URL, then switch to git install tab to paste.

Backend (Rust)
- New module src-tauri/src/github_search.rs as a self-contained submodule
  with no coupling to github_api.rs's crate-private helpers, so merging
  upstream stays conflict-free.
- 13 unit tests covering query composition, URL construction, response
  mapping, and validation.
- New Tauri command search_github_repositories (commands.rs: line ~9024)
  registered in lib.rs invoke_handler. Token is optional - falls back to
  unauthenticated GitHub Search (60 req/h).

Frontend (React)
- skill-client.ts: GithubSearchRepository / GithubSearchResponse /
  searchGithubRepositories invoke wrapper.
- New component GithubSearchPanel.tsx (~300 lines): form with keyword +
  topic presets + language, results list, copy-to-clipboard, hint to
  switch to git tab for install.
- market.tsx: git tab gets an 'URL | GitHub Search' mode switcher above
  the existing RepoInstallPanel; state is internal.
- i18n: 25 new keys in zh-CN and en, leveraging existing keyof typeof
  translations['zh-CN'] union.

Validation
- cargo test --lib search: 13 passed
- npm run build: tsc --noEmit + vite build both clean
- npm run test: 550 tests passed (54 files)
Eliminate the copy/paste round-trip. After searching GitHub, a
'Use this repository' button sends the selected cloneUrl straight into
RepoInstallPanel, which now accepts an optional prefilledRepoUrl prop
and triggers its existing discovery flow (branch fetch + skill detection).

market.tsx holds a single source of truth (prefilledRepoUrl state) and
flips gitInstallMode from 'search' to 'url' atomically, so the user
lands in the install UI with everything already loaded.

Touch points: RepoInstallPanel +14/-3, market.tsx +8/-4, panel +29/-11,
i18n +2. All 550 vitest tests still pass.
search_github_repositories now falls back to github_credentials::active_token()
when the caller passes None or empty string. Effect: if the user has already
completed GitHub device flow (Settings → GitHub), search queries silently
upgrade from 60 req/h (anonymous) to 5000 req/h (authenticated). No frontend
changes required; the existing UI contract is unchanged.

This unblocks real-world search usage without forcing users to invent a
PAT only for this panel.
Each search result now displays a probe badge so users can tell at a glance
whether the repo is actually installable. Probe runs in the background per
item when the result list renders; uses the same auto-injected GitHub token
from the credentials cache, so 30 concurrent probes are well under the
5000 req/h authed budget.

Backend (Rust)
- github_search.rs: new RepositoryInstallability struct, PROBE_PATHS table
  (7 marker file locations: SKILL.md, .codex-plugin/plugin.json,
  .claude-plugin/plugin.json, plugin.json, mcp.json, .mcp.json), and
  probe_repository_installability() walking them serially. 6 new unit
  tests cover URL construction, classification, and serialization.
- commands.rs: probe_repository_installability command (also auto-falls
  back to github_credentials::active_token), registered in lib.rs.

Frontend (React)
- skill-client.ts: RepositoryInstallability type + probeRepositoryInstallability
  invoke wrapper.
- GithubSearchPanel.tsx: result items extracted into ResultItem subcomponent
  with internal probe state (loading/error/ok) and badge rendering for
  the three install kinds.
- i18n: 7 new keys (probe.loading, probe.failed, probe.unknown,
  probe.skill, probe.plugin, probe.mcp) in zh-CN and en.

Touch points: github_search.rs +99, commands.rs +18, lib.rs +1,
skill-client.ts +29, panel +97, i18n +14. 19 Rust unit tests
pass; 550 vitest tests still pass; npm run build clean.
Search results used to fire 30 concurrent probe_repository_installability
calls the moment the list rendered. Anonymous GitHub users (60 req/h) hit
the limit instantly; even authenticated users wasted API calls for cards
they never scrolled to.

ResultItem now mounts into an IntersectionObserver (rootMargin 120px). The
probe fires only when the card becomes visible (or is about to be), then
the observer disconnects so each card is probed exactly once. No
IntersectionObserver is provided (older jsdom) → falls back to immediate
probe to preserve current behavior.

Touch points:
- NEW src/features/install/hooks/useLazyProbe.ts (109 lines)
- NEW src/tests/install/use-lazy-probe.test.ts (6 unit tests)
- src/features/install/components/GithubSearchPanel.tsx: ResultItem now
  calls useLazyProbe; renderProbeBadges handles the new idle state.

Verification: cargo test --lib search 19 passed, npm run build clean,
vitest 556 passed (54 files + 1 new file).
…stence

After every successful search query, the (query, topics, language)
triple is pushed to a 10-entry ring buffer in localStorage. The panel
renders that list right under the form so a returning user can replay
a previous query with one click — topics get a stable order-aware
fingerprint so reordering tags dedupes rather than creating an extra
slot.

Touch points:
- NEW src/features/install/utils/searchHistoryStorage.ts (109 lines)
- NEW src/tests/install/search-history-storage.test.ts (15 unit tests)
- src/features/install/components/GithubSearchPanel.tsx: historyStorage
  state, replay callback, history list UI under the form.
- src/app/i18n.tsx: 4 new bilingual keys (history.aria, history.title,
  history.clear, history.emptyQuery).

Verification: cargo test --lib search still 19 passed, npm run build
clean, vitest 571 passed (56 files).
@hzqstc88 hzqstc88 changed the title Codex mvp feat(install): add GitHub search panel to discover and install skills/plugins/MCP Sep 25, 2026
@wh1024k

wh1024k commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the search MVP — the backend works, but I can't merge this yet.

The new GitHub Search panel has no styles. Classes like github-search-panel / github-search-result-item are unused, so it falls back to browser defaults and doesn't match the rest of the Install page:

unstyled search form

unstyled search results

If you want to continue: reuse the existing install UI (install-card, current search/filter row, badges/pills, dark theme). Don't add a second heading. Results should look like the market/git install cards, not a numbered list. Also drop or hide the probe badge until detection is accurate — root-only file checks mark installable repos as "无可装入标记".

Happy to re-review after that.

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