Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

Commit 54981ae

Browse files
fix: scope handleProjectSearch org filtering for display names
Both handleProjectSearch implementations (org-list.ts and project/list.ts) now accept and use the parsed org to scope display-name searches, matching the pattern already applied in resolveTargetsFromParsedArg and resolveOrgProjectTarget.
1 parent 5854391 commit 54981ae

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎src/commands/project/list.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,14 @@ export async function handleProjectSearch(
587587
/** Original user input before normalization — for clearer messages. */
588588
originalSlug?: string,
589589
/** @internal — prevents infinite recursion from fuzzy recovery. */
590-
_isRecoveryAttempt = false
590+
_isRecoveryAttempt = false,
591+
/** Organization slug to scope the search to (e.g. from "org/My Project"). */
592+
scopedOrg?: string
591593
): Promise<ListResult<ProjectWithOrg>> {
592594
// When the input is a display name (originalSlug set, contains spaces),
593595
// skip the slug-based API lookup and go straight to name-based matching.
594596
const isDisplayName = originalSlug !== undefined;
595-
const { projects, orgs } = isDisplayName
597+
const { projects, orgs: foundOrgs } = isDisplayName
596598
? { projects: [], orgs: await listOrganizations() }
597599
: await withProgress(
598600
{
@@ -601,6 +603,14 @@ export async function handleProjectSearch(
601603
},
602604
() => findProjectsBySlug(projectSlug)
603605
);
606+
607+
// When the caller provided an org (e.g. "org/My Project"), scope the
608+
// search to that org instead of all accessible orgs.
609+
const orgs =
610+
isDisplayName && scopedOrg !== undefined
611+
? foundOrgs.filter((o) => o.slug === scopedOrg)
612+
: foundOrgs;
613+
604614
const filtered = filterByPlatform(projects, flags.platform);
605615

606616
if (filtered.length === 0) {
@@ -734,7 +744,9 @@ export const listCommand = buildListCommand("project", {
734744
handleProjectSearch(
735745
ctx.parsed.projectSlug,
736746
flags,
737-
ctx.parsed.originalSlug
747+
ctx.parsed.originalSlug,
748+
false,
749+
ctx.parsed.org
738750
),
739751
},
740752
});

‎src/lib/org-list.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,17 +773,19 @@ export async function handleProjectSearch<TEntity, TWithOrg>(
773773
orgAllFallback?: (orgSlug: string) => Promise<ListResult<TWithOrg>>;
774774
/** Original user input before normalization — for clearer messages. */
775775
originalSlug?: string;
776+
/** Organization slug to scope the search to (e.g. from "org/My Project"). */
777+
org?: string;
776778
},
777779
/** Guard against infinite recursion from fuzzy recovery. */
778780
_isRecoveryAttempt = false
779781
): Promise<ListResult<TWithOrg>> {
780-
const { flags, orgAllFallback, originalSlug } = options;
782+
const { flags, orgAllFallback, originalSlug, org: scopedOrg } = options;
781783
/** Display label: the user's raw input when available, otherwise the slug. */
782784
const displaySlug = originalSlug ?? projectSlug;
783785
// When the input is a display name (originalSlug set, contains spaces),
784786
// skip the slug-based API lookup and go straight to name-based matching.
785787
const isDisplayName = originalSlug !== undefined;
786-
const { projects: matches, orgs } = isDisplayName
788+
const { projects: matches, orgs: foundOrgs } = isDisplayName
787789
? { projects: [], orgs: await listOrganizations() }
788790
: await withProgress(
789791
{
@@ -793,6 +795,13 @@ export async function handleProjectSearch<TEntity, TWithOrg>(
793795
() => findProjectsBySlug(projectSlug)
794796
);
795797

798+
// When the caller provided an org (e.g. "org/My Project"), scope the
799+
// search to that org instead of all accessible orgs.
800+
const orgs =
801+
isDisplayName && scopedOrg !== undefined
802+
? foundOrgs.filter((o) => o.slug === scopedOrg)
803+
: foundOrgs;
804+
796805
if (matches.length === 0) {
797806
// Skip triage on recovery attempts to prevent infinite recursion.
798807
const outcome: ProjectNotFoundOutcome = _isRecoveryAttempt
@@ -953,6 +962,7 @@ function buildDefaultHandlers<TEntity, TWithOrg>(
953962
flags: ctx.flags,
954963
orgAllFallback: (orgSlug) => runOrgAll(config, orgSlug, ctx.flags),
955964
originalSlug: ctx.parsed.originalSlug,
965+
org: ctx.parsed.org,
956966
}),
957967

958968
"org-all": (ctx) => {

0 commit comments

Comments
 (0)