Skip to content

Filter cards by type in Recents Section of Card Picker#4066

Merged
burieberry merged 11 commits intomainfrom
cs-10261-create-new-via-recents
Feb 26, 2026
Merged

Filter cards by type in Recents Section of Card Picker#4066
burieberry merged 11 commits intomainfrom
cs-10261-create-new-via-recents

Conversation

@burieberry
Copy link
Contributor

@burieberry burieberry commented Feb 25, 2026

Recents section was missing the type filter for the following cases:

  • Create New card instance
  • Add card to LinksTo field
  • Add card to LinksToMany field
  • Find Instances in code mode
recents

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Host Test Results

    1 files  ± 0      1 suites  ±0   1h 46m 12s ⏱️ + 12m 22s
1 902 tests +23  1 887 ✅ +23  15 💤 ±0  0 ❌ ±0 
1 917 runs  +23  1 902 ✅ +23  15 💤 ±0  0 ❌ ±0 

Results for commit 9189ca6. ± Comparison against base commit 61ceac3.

This pull request removes 7 and adds 30 tests. Note that renamed tests count towards both.
Chrome ‑ Acceptance | code submode | create-file tests > when user has permissions to both test realms: new file button has options to create card def, field def, card instance, and text files
Chrome ‑ Integration | operator-mode | card catalog: Recents section filters cards by realm
Chrome ‑ Integration | operator-mode | card catalog: Recents section filters cards by search key
Chrome ‑ Integration | operator-mode | card catalog: Recents section hides cards from unselected realms
Chrome ‑ Integration | operator-mode | card catalog: Recents section is present when search sheet is open (expanded mode)
Chrome ‑ Integration | operator-mode | card catalog: displays recently accessed card
Chrome ‑ Integration | operator-mode | card catalog: displays recently accessed card, maximum 10 cards
Chrome ‑ Acceptance | code submode | create-file tests > when user has permissions to both test realms: can upload a file via the New menu
Chrome ‑ Acceptance | code submode | create-file tests > when user has permissions to both test realms: cancelling upload file picker does not cause errors
Chrome ‑ Acceptance | code submode | create-file tests > when user has permissions to both test realms: new file button has options to create card def, field def, card instance, text files, and upload file
Chrome ‑ Acceptance | code submode | file-tree tests > when the user lacks write permissions: file tree does not show context menu in read-only realm
Chrome ‑ Acceptance | code submode | file-tree tests: can cancel delete from file tree context menu
Chrome ‑ Acceptance | code submode | file-tree tests: can delete a file from file tree context menu
Chrome ‑ Acceptance | code submode | file-tree tests: can delete a file via right-click in file tree
Chrome ‑ Acceptance | file chooser tests: uploading a file without an extension shows an error
Chrome ‑ Integration | operator-mode | card catalog > recents section: displays recently accessed card
Chrome ‑ Integration | operator-mode | card catalog > recents section: displays recently accessed card, maximum 10 cards
…

♻️ This comment has been updated with latest results.

@burieberry burieberry marked this pull request as ready for review February 25, 2026 23:08
@burieberry burieberry requested a review from a team February 25, 2026 23:08
Comment on lines 165 to 189
private get filterTypeRef(): CodeRef | undefined {
const filter = this.args.baseFilter;
if (filter) {
// EveryFilter with 'on' scoping (e.g. specRef in chooseCard)
if ('on' in filter && filter.on) {
return filter.on;
}
// Top-level CardTypeFilter { type: CodeRef } (e.g. linksTo)
if (isCardTypeFilter(filter)) {
return filter.type;
}
// EveryFilter containing a CardTypeFilter (e.g. linksToMany)
if (isEveryFilter(filter)) {
for (const sub of filter.every) {
if (isCardTypeFilter(sub)) {
return sub.type;
}
}
}
return undefined;
}
// Search-sheet mode: extract type from carddef: search key (searchForInstances)
return getCodeRefFromSearchKey(this.args.searchKey);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it might belong in a query-utils module with unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added this as getTypeRefsFromFilter utility function in query-field-utils and also expanded the logic to handle types in other filter kinds and more complex filters.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing type-based filtering for the Recents section in the card picker / search UI flows (create card, linksTo/linksToMany pickers, and “Find Instances” in code mode), so Recents aligns with the active type constraints.

Changes:

  • Introduces getTypeRefsFromFilter() in runtime-common to extract type refs (including negations) from query Filters.
  • Applies extracted type constraints to Recents filtering in SearchContent.
  • Adds unit + integration tests and a new data-test-recent-card-result hook for asserting Recents behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/runtime-common/query-field-utils.ts Adds getTypeRefsFromFilter() helper to extract type refs from filters.
packages/host/app/components/card-search/search-content.gts Applies type filtering to Recents using extracted type refs (and carddef: search key in search-sheet mode).
packages/host/app/components/card-search/search-result-section.gts Adds data-test-recent-card-result attribute for Recents items to support assertions.
packages/host/tests/unit/get-type-refs-from-filter-test.ts Adds unit coverage for getTypeRefsFromFilter() behavior.
packages/host/tests/integration/components/operator-mode-card-catalog-test.gts Expands Recents integration coverage including new type-filtering scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


function cardMatchesTypeRef(card: CardDef, typeRef: CodeRef): boolean {
if (!isResolvedCodeRef(typeRef)) {
return false;
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

cardMatchesTypeRef returns false for any non-ResolvedCodeRef (e.g. CodeRef shapes like { type: 'fieldOf' | 'ancestorOf', ... }). Since getTypeRefsFromFilter() can return these (and chooseCardTitle() already supports them via loadCardDef), this can cause the recents list to be filtered down to zero even when there are matching recent cards. Consider either resolving non-resolved CodeRefs to a concrete card def (via loadCardDef + identifyCard/prototype checks) before filtering, or skipping type filtering when the extracted type refs are not resolvable (instead of filtering everything out).

Suggested change
return false;
// For non-resolved CodeRefs (e.g. fieldOf/ancestorOf), we cannot
// concretely determine a mismatch here. Treat them as a no-op filter
// rather than excluding the card, so recents are not over-filtered.
return true;

Copilot uses AI. Check for mistakes.

// expand search sheet
await fillIn('[data-test-search-field]', ' ');
// Simulate searchForInstances for Person — carddef: prefix + absolute module/name key
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The inline comment says this simulates searchForInstances for "Person", but the carddef: search key being entered is for pet/Pet. Update the comment to match the actual type being searched to avoid confusion when maintaining this test.

Suggested change
// Simulate searchForInstances for Person — carddef: prefix + absolute module/name key
// Simulate searchForInstances for Pet — carddef: prefix + absolute module/name key

Copilot uses AI. Check for mistakes.
@burieberry burieberry merged commit 86a8f76 into main Feb 26, 2026
110 of 111 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.

3 participants