Skip to content

Tab opening ranking - #23435

Merged
AmethystLiang merged 2 commits into
mainfrom
tab-opening-ranking
Sep 27, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
tab-opening-ranking

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​291 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​270
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40

ELI5

What Changed

Why

Linked Issue

Fixes #

Visual Proof

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

- Distinguish literal filename matches from fuzzy matches
- Prioritize search for short tokens (1-2 Latin characters)
- Sort literal matches naturally instead of by fuzzy score
- Reserve search option even when literal matches fill results

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues. The ranking logic is coherent and thoroughly tested. One process gap and one consistency nit below.

Reviewed changes

  • New literal-basename match kind — findExistingFileMatches now adds case-insensitive contiguous basename substring matches (lowerFilename.includes(query)), ordered by natural compareFileNames order, between exact matches and fuzzy matches.
  • Skip fuzzy ranking when literal matches fill the window — preferFilenames gates the literal scan; if exact + literal already reaches the limit, rankQuickOpenFiles is never called (asserted by tests).
  • Classifier re-ranking — exactExistingFiles is tightened to exact-path || exact-basename; the host-url / path-error / new-file-intent / whitespace branches now consume all existingFiles; a new short-token branch (/^[\p{Script=Latin}\p{Nd}]{1,2}$/u) puts search ahead of files; the general branch reserves a search slot ahead of fuzzy matches.
  • Net behavior — web search is promoted above fuzzy path matches (e.g. btn classifies as search on Enter), while literal/extended filename matches still lead search.

ℹ️ The user-facing before/after and rationale are missing

The PR description is the bare template: no ELI5, no before/after, no mechanism, no "why". This is a subjective ranking change — Enter on btn/abbreviations now runs a web search where it previously opened the top fuzzy file — and a reviewer has no stated intent to judge it against. The repository template requires a user-facing before/after (with screenshots or a video for behavior changes) and the reasoning over the alternatives considered.

Technical details
# Add the ranking rationale and before/after

## Affected sites
- PR #23435 body — `## ELI5`, `## What Changed`, `## Why`, `## Visual Proof`, `## Testing` are all empty.
- `src/renderer/src/components/tab-bar/tab-create-entry-classifier.ts:253-272` — the branches that move search ahead of files.

## Required outcome
- State the before/after as the user experiences it for at least: a literal filename match (`button`), a fuzzy abbreviation (`btn`), and a phrase (`release notes`).
- State why search-first for non-literal tokens is preferred over the previous fuzzy-first ordering, and which alternatives were rejected.

## Open questions for the human
- Is Enter-on-abbreviation intentionally now a search, or is the visible list ordering (search first, fuzzy below) meant to differ from the Enter default?

ℹ️ Nitpicks

  • The classifier normalizes text to NFC only to test the short-token regex (tab-create-entry-classifier.ts:263), while findExistingFileMatches and prepareQuickOpenFile compare code units without normalization. An accented query therefore matches an NFD filename (common on macOS) as neither exact nor literal, even though the NFC call signals that normalization matters here. Not introduced by this PR, but the two now disagree and it's worth a deliberate decision.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The file matcher now identifies literal filename-substring matches and combines them with exact and fuzzy matches. The classifier updates how it orders search, file, and new-file options. Tests cover result ordering, short queries, and submission while file listings are loading.

Estimated code review effort

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to b8188

Some matching files are missing from tab-opening choices when another file matches exactly. Users can refine the query, but the missing choices should be restored.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only the template and an automated line-count summary. It does not explain the user-facing change, reason, linked issue, visual proof, testing, or checklist status. Complete the required sections with a plain-language summary, detailed changes, rationale, linked issue, visual proof or an explanation of why it is not applicable, testing details, review notes, and checklist status.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and directly describes the main change: ranking behavior for tab opening.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Retain literal matches after an exact match. · tab-create-entry-classifier.ts:223-237

src/renderer/src/components/tab-bar/tab-create-entry-classifier.ts:223-237
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Retain literal matches after an exact match.

When existingFiles contains an exact-basename result and a literal-basename result, this branch returns only the exact result plus search or host actions. The literal file is missing from the tab actions even when actionLimit has spare slots, so the user cannot open it from the tab picker.

Suggested fix
   const exactExistingFiles = existingFiles.filter(
     (file) => file.matchKind === 'exact-path' || file.matchKind === 'exact-basename'
   )
+  const literalExistingFiles = existingFiles.filter(
+    (file) => file.matchKind === 'literal-basename'
+  )

   if (exactExistingFiles.length > 0) {
     const options: TabEntryActionClassification[] = [...exactExistingFiles]
     if (hostUrl?.kind === 'host-url') {
       options.push(hostUrl)
     } else if (!hostUrl && newFile) {
       options.push(search)
     }
+    options.push(...literalExistingFiles)
     return toOptions(options, actionLimit)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f4d0425f-8b86-4f94-991d-f1d0c4010e1d

📥 Commits

Reviewing files that changed from the base of the PR and between 0a876b2 and b81882f.

📒 Files selected for processing (7)
  • src/renderer/src/components/tab-bar/TabBarCreateEntry.search.test.tsx
  • src/renderer/src/components/tab-bar/tab-create-entry-classifier.test.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-classifier.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-file-matches.test.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-file-matches.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-history-placement.test.ts
  • src/renderer/src/components/tab-bar/tab-create-entry-search-ranking.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang, thanks for the update. I’ll leave the comment open until the fix is in the PR.

You are interacting with an AI system.

Ensure literal-basename file matches appear in tab creation suggestions
as fallback options when exact-basename matches exist, improving file
discovery for users.
@AmethystLiang
AmethystLiang merged commit eaa6fb7 into main Sep 27, 2026
2 of 4 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.

1 participant