-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add search to new-thread project picker #4259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
colonelpanic8
wants to merge
9
commits into
pingdotgg:main
Choose a base branch
from
colonelpanic8:t3code/searchable-new-thread-projects
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+337
−44
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d1940d7
Add search to new-thread project picker
colonelpanic8 120f506
fix(web): preserve project picker search and keyboard access
colonelpanic8 e1f57cf
fix(web): pin new-project picker action
colonelpanic8 b5d30eb
fix(web): constrain project picker footer
colonelpanic8 44b3b15
fix(web): render filtered project picker rows
colonelpanic8 3675a60
fix(web): make empty project search a no-op
colonelpanic8 ce300e3
fix(web): preserve explicit project picker navigation
colonelpanic8 e49be20
fix(web): preserve project search IME input
colonelpanic8 b872596
fix(web): disambiguate draft hero picker items
colonelpanic8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
apps/web/src/components/chat/draftHeroProjectSearch.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { | ||
| DRAFT_HERO_NEW_PROJECT_ITEM, | ||
| filterDraftHeroProjects, | ||
| getDraftHeroFilteredPickerItems, | ||
| getDraftHeroProjectPickerItemValue, | ||
| resolveDraftHeroPickerKeyAction, | ||
| } from "./draftHeroProjectSearch"; | ||
|
|
||
| const projects = [ | ||
| { title: "T3 Code", workspaceRoot: "/work/t3code" }, | ||
| { title: "Mobile App", workspaceRoot: "/work/products/mobile" }, | ||
| { title: "Marketing Site", workspaceRoot: "/work/products/marketing" }, | ||
| ]; | ||
|
|
||
| describe("filterDraftHeroProjects", () => { | ||
| it("narrows candidates as the title query becomes more specific", () => { | ||
| expect(filterDraftHeroProjects(projects, "m").map((project) => project.title)).toEqual([ | ||
| "Mobile App", | ||
| "Marketing Site", | ||
| ]); | ||
| expect(filterDraftHeroProjects(projects, "mob").map((project) => project.title)).toEqual([ | ||
| "Mobile App", | ||
| ]); | ||
| }); | ||
|
|
||
| it("matches project paths and multiple query tokens", () => { | ||
| expect( | ||
| filterDraftHeroProjects(projects, "products market").map((project) => project.title), | ||
| ).toEqual(["Marketing Site"]); | ||
| }); | ||
|
|
||
| it("preserves candidate order for an empty query", () => { | ||
| expect(filterDraftHeroProjects(projects, " ")).toEqual(projects); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getDraftHeroFilteredPickerItems", () => { | ||
| it("keeps project values disjoint even when their scoped key matches the action value", () => { | ||
| const projectItem = getDraftHeroProjectPickerItemValue(DRAFT_HERO_NEW_PROJECT_ITEM); | ||
|
|
||
| expect(projectItem).not.toBe(DRAFT_HERO_NEW_PROJECT_ITEM); | ||
| expect(getDraftHeroFilteredPickerItems([projectItem])).toEqual([ | ||
| projectItem, | ||
| DRAFT_HERO_NEW_PROJECT_ITEM, | ||
| ]); | ||
| }); | ||
|
|
||
| it("keeps New project in the navigable collection after a failed search", () => { | ||
| expect(getDraftHeroFilteredPickerItems([])).toEqual([DRAFT_HERO_NEW_PROJECT_ITEM]); | ||
| }); | ||
|
|
||
| it("keeps New project reachable when browsing or navigating successful search results", () => { | ||
| expect(getDraftHeroFilteredPickerItems(["project-1"])).toEqual([ | ||
| "project-1", | ||
| DRAFT_HERO_NEW_PROJECT_ITEM, | ||
| ]); | ||
| }); | ||
| }); | ||
|
|
||
| describe("resolveDraftHeroPickerKeyAction", () => { | ||
| it("blocks an immediate Enter after a failed project search", () => { | ||
| expect( | ||
| resolveDraftHeroPickerKeyAction({ | ||
| key: "Enter", | ||
| isComposing: false, | ||
| keyCode: 13, | ||
| hasFailedProjectSearch: true, | ||
| hasNewProjectKeyboardIntent: false, | ||
| }), | ||
| ).toBe("block-selection"); | ||
| }); | ||
|
|
||
| it("allows deliberate ArrowDown then Enter access to New project", () => { | ||
| const navigationAction = resolveDraftHeroPickerKeyAction({ | ||
| key: "ArrowDown", | ||
| isComposing: false, | ||
| keyCode: 40, | ||
| hasFailedProjectSearch: true, | ||
| hasNewProjectKeyboardIntent: false, | ||
| }); | ||
| expect(navigationAction).toBe("enable-new-project"); | ||
|
|
||
| expect( | ||
| resolveDraftHeroPickerKeyAction({ | ||
| key: "Enter", | ||
| isComposing: false, | ||
| keyCode: 13, | ||
| hasFailedProjectSearch: true, | ||
| hasNewProjectKeyboardIntent: navigationAction === "enable-new-project", | ||
| }), | ||
| ).toBe("allow"); | ||
| }); | ||
|
|
||
| it("allows Enter to commit an active IME composition", () => { | ||
| expect( | ||
| resolveDraftHeroPickerKeyAction({ | ||
| key: "Enter", | ||
| isComposing: true, | ||
| keyCode: 13, | ||
| hasFailedProjectSearch: true, | ||
| hasNewProjectKeyboardIntent: false, | ||
| }), | ||
| ).toBe("preserve-composition"); | ||
| }); | ||
|
|
||
| it("allows the legacy 229 composition fallback", () => { | ||
| expect( | ||
| resolveDraftHeroPickerKeyAction({ | ||
| key: "Enter", | ||
| isComposing: false, | ||
| keyCode: 229, | ||
| hasFailedProjectSearch: true, | ||
| hasNewProjectKeyboardIntent: false, | ||
| }), | ||
| ).toBe("preserve-composition"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.