From 82b2717b601ff32885f1d78761a77e76d810b048 Mon Sep 17 00:00:00 2001 From: zzgu Date: Tue, 10 Dec 2024 14:02:02 -0800 Subject: [PATCH 1/6] feat(graphQL): check weather current workspace is indexed --- ee/tabby-schema/graphql/schema.graphql | 1 + ee/tabby-schema/src/schema/mod.rs | 17 ++++++++++ ee/tabby-schema/src/schema/thread/inputs.rs | 10 +++--- ee/tabby-ui/app/chat/page.tsx | 4 +++ ee/tabby-ui/components/chat/chat.tsx | 35 +++++++++++++++++++++ ee/tabby-ui/lib/tabby/gql.ts | 1 + ee/tabby-ui/lib/tabby/query.ts | 6 ++++ 7 files changed, 69 insertions(+), 5 deletions(-) diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index 67c1b82377d1..f757d7cba39b 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -715,6 +715,7 @@ type Query { userEvents(after: String, before: String, first: Int, last: Int, users: [ID!], start: DateTime!, end: DateTime!): UserEventConnection! diskUsageStats: DiskUsageStats! repositoryList: [Repository!]! + isAvaileableWorkspace(gitUrl: String!): Boolean! contextInfo: ContextInfo! integrations(ids: [ID!], kind: IntegrationKind, after: String, before: String, first: Int, last: Int): IntegrationConnection! integratedRepositories(ids: [ID!], kind: IntegrationKind, active: Boolean, after: String, before: String, first: Int, last: Int): ProvidedRepositoryConnection! diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index 504b9ef0a02a..de0695ebfc61 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -541,6 +541,23 @@ impl Query { .await } + async fn resolve_git_url(ctx: &Context, git_url: String) -> Result> { + let user = check_user(ctx).await?; + + let repositorys = ctx.locator + .repository() + .repository_list(Some(&user.policy)) + .await.unwrap_or_default(); + + for repo in repositorys { + if repo.git_url == git_url { + return Ok(Some(repo)); + } + } + + return Ok(None); + } + async fn context_info(ctx: &Context) -> Result { let user = check_user(ctx).await?; ctx.locator.context().read(Some(&user.policy)).await diff --git a/ee/tabby-schema/src/schema/thread/inputs.rs b/ee/tabby-schema/src/schema/thread/inputs.rs index 70d7d76edfa0..cd232ad93041 100644 --- a/ee/tabby-schema/src/schema/thread/inputs.rs +++ b/ee/tabby-schema/src/schema/thread/inputs.rs @@ -30,7 +30,7 @@ pub struct CreateThreadAndRunInput { pub options: ThreadRunOptionsInput, } -#[derive(GraphQLInputObject, Validate, Clone)] +#[derive(GraphQLInputObject, Validate, Clone, Debug)] pub struct DocQueryInput { pub content: String, @@ -41,7 +41,7 @@ pub struct DocQueryInput { pub source_ids: Option>, } -#[derive(GraphQLInputObject, Validate, Clone)] +#[derive(GraphQLInputObject, Validate, Clone, Debug)] #[validate(schema(function = "validate_code_query_input", skip_on_field_errors = false))] pub struct CodeQueryInput { pub filepath: Option, @@ -69,7 +69,7 @@ fn validate_code_query_input(input: &CodeQueryInput) -> Result<(), ValidationErr Ok(()) } -#[derive(GraphQLInputObject, Validate, Default, Clone)] +#[derive(GraphQLInputObject, Validate, Default, Clone, Debug)] pub struct ThreadRunOptionsInput { #[graphql(default)] pub model_name: Option, @@ -89,7 +89,7 @@ pub struct ThreadRunOptionsInput { pub debug_options: Option, } -#[derive(GraphQLInputObject, Clone)] +#[derive(GraphQLInputObject, Clone, Debug)] pub struct CodeSearchParamsOverrideInput { pub min_embedding_score: Option, pub min_bm25_score: Option, @@ -98,7 +98,7 @@ pub struct CodeSearchParamsOverrideInput { pub num_to_score: Option, } -#[derive(GraphQLInputObject, Clone)] +#[derive(GraphQLInputObject, Clone, Debug)] pub struct ThreadRunDebugOptionsInput { #[graphql(default)] pub code_search_params_override: Option, diff --git a/ee/tabby-ui/app/chat/page.tsx b/ee/tabby-ui/app/chat/page.tsx index 2c5da6d76dbd..5c48f7a3666a 100644 --- a/ee/tabby-ui/app/chat/page.tsx +++ b/ee/tabby-ui/app/chat/page.tsx @@ -129,6 +129,7 @@ export default function ChatPage() { setErrorMessage(null) }, addRelevantContext: context => { + console.log('context', context) return addRelevantContext(context) }, updateTheme: (style, themeClass) => { @@ -267,6 +268,9 @@ export default function ChatPage() { const onChatLoaded = () => { pendingRelevantContexts.forEach(addRelevantContext) pendingMessages.forEach(sendMessage) + + console.log('pendingActiveSelection', pendingActiveSelection) + chatRef.current?.updateActiveSelection(pendingActiveSelection) clearPendingState() diff --git a/ee/tabby-ui/components/chat/chat.tsx b/ee/tabby-ui/components/chat/chat.tsx index 03212c6c3295..e23db41bd0cc 100644 --- a/ee/tabby-ui/components/chat/chat.tsx +++ b/ee/tabby-ui/components/chat/chat.tsx @@ -13,6 +13,7 @@ import { CreateMessageInput, InputMaybe, MessageAttachmentCodeInput, + RepositoryListQuery, ThreadRunOptionsInput } from '@/lib/gql/generates/graphql' import { useDebounceCallback } from '@/lib/hooks/use-debounce' @@ -35,6 +36,10 @@ import { ChatPanel, ChatPanelRef } from './chat-panel' import { ChatScrollAnchor } from './chat-scroll-anchor' import { EmptyScreen } from './empty-screen' import { QuestionAnswerList } from './question-answer' +import { createRequest } from '@urql/core' +import { client } from '@/lib/tabby/gql' +import { IsAvaileableWorkspaceQuery } from '@/lib/gql/generates/graphql' +import { isAvaileableWorkspaceQuery, repositoryListQuery } from '@/lib/tabby/query' type ChatContextValue = { threadId: string | undefined @@ -101,6 +106,32 @@ interface ChatProps extends React.ComponentProps<'div'> { supportsOnApplyInEditorV2: boolean } +async function isAvaileableWorkspace(gitUrl: string): Promise< + IsAvaileableWorkspaceQuery['isAvaileableWorkspace'] +> { + // debugger + const query = client.createRequestOperation( + 'query', + createRequest(isAvaileableWorkspaceQuery, { gitUrl }) + ) + + return client + .executeQuery(query) + .then(data => console.log('data', data)) as any +} + +async function fetchAllRepositories(): Promise< + RepositoryListQuery['repositoryList'] +> { + const query = client.createRequestOperation( + 'query', + createRequest(repositoryListQuery, {}) + ) + return client + .executeQuery(query) + .then(data => data?.data?.repositoryList || []) +} + function ChatRenderer( { className, @@ -497,6 +528,10 @@ function ChatRenderer( const debouncedUpdateActiveSelection = useDebounceCallback( (ctx: Context | null) => { + console.log('ctx', ctx); + if (ctx?.git_url) isAvaileableWorkspace(ctx.git_url) + + fetchAllRepositories().then(res => console.log('fetchres', res)) setActiveSelection(ctx) }, 300 diff --git a/ee/tabby-ui/lib/tabby/gql.ts b/ee/tabby-ui/lib/tabby/gql.ts index 6274cc18f0de..3a87ef9b7e9c 100644 --- a/ee/tabby-ui/lib/tabby/gql.ts +++ b/ee/tabby-ui/lib/tabby/gql.ts @@ -123,6 +123,7 @@ const client = new Client({ ServerInfo: () => null, RepositorySearch: () => null, RepositoryList: () => null, + // IsAvaileableWorkspace: () => null, RepositoryGrep: () => null, GrepLine: () => null, GrepFile: () => null, diff --git a/ee/tabby-ui/lib/tabby/query.ts b/ee/tabby-ui/lib/tabby/query.ts index c1088a2ddad1..2fd632f79ce0 100644 --- a/ee/tabby-ui/lib/tabby/query.ts +++ b/ee/tabby-ui/lib/tabby/query.ts @@ -280,6 +280,12 @@ export const repositoryListQuery = graphql(/* GraphQL */ ` } `) +export const isAvaileableWorkspaceQuery = graphql(/* GraphQL */ ` + query IsAvaileableWorkspace($gitUrl: String!) { + isAvaileableWorkspace(gitUrl: $gitUrl) + } +`) + export const repositorySearch = graphql(/* GraphQL */ ` query RepositorySearch( $kind: RepositoryKind! From b5bd892a40da041fc2e51913d59a89e190d5cb0e Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 22:10:51 +0000 Subject: [PATCH 2/6] [autofix.ci] apply automated fixes --- ee/tabby-schema/graphql/schema.graphql | 2 +- ee/tabby-schema/src/schema/mod.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index f757d7cba39b..e54c94d17977 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -715,7 +715,7 @@ type Query { userEvents(after: String, before: String, first: Int, last: Int, users: [ID!], start: DateTime!, end: DateTime!): UserEventConnection! diskUsageStats: DiskUsageStats! repositoryList: [Repository!]! - isAvaileableWorkspace(gitUrl: String!): Boolean! + resolveGitUrl(gitUrl: String!): Repository contextInfo: ContextInfo! integrations(ids: [ID!], kind: IntegrationKind, after: String, before: String, first: Int, last: Int): IntegrationConnection! integratedRepositories(ids: [ID!], kind: IntegrationKind, active: Boolean, after: String, before: String, first: Int, last: Int): ProvidedRepositoryConnection! diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index de0695ebfc61..9c9e4c7fb154 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -544,10 +544,12 @@ impl Query { async fn resolve_git_url(ctx: &Context, git_url: String) -> Result> { let user = check_user(ctx).await?; - let repositorys = ctx.locator + let repositorys = ctx + .locator .repository() .repository_list(Some(&user.policy)) - .await.unwrap_or_default(); + .await + .unwrap_or_default(); for repo in repositorys { if repo.git_url == git_url { @@ -555,7 +557,7 @@ impl Query { } } - return Ok(None); + Ok(None) } async fn context_info(ctx: &Context) -> Result { From ab71850187be100fe6013f4589c99cad9c0bd971 Mon Sep 17 00:00:00 2001 From: zzgu Date: Tue, 10 Dec 2024 16:57:20 -0800 Subject: [PATCH 3/6] feat(graphQL): add ResolveGitUrl query for frontend and backend --- ee/tabby-schema/graphql/schema.graphql | 2 +- ee/tabby-schema/src/schema/mod.rs | 8 ++++---- ee/tabby-ui/lib/tabby/gql.ts | 1 - ee/tabby-ui/lib/tabby/query.ts | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index e54c94d17977..ffbfbf437d5e 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -715,7 +715,7 @@ type Query { userEvents(after: String, before: String, first: Int, last: Int, users: [ID!], start: DateTime!, end: DateTime!): UserEventConnection! diskUsageStats: DiskUsageStats! repositoryList: [Repository!]! - resolveGitUrl(gitUrl: String!): Repository + resolveGitUrl(gitUrl: String!): Boolean! contextInfo: ContextInfo! integrations(ids: [ID!], kind: IntegrationKind, after: String, before: String, first: Int, last: Int): IntegrationConnection! integratedRepositories(ids: [ID!], kind: IntegrationKind, active: Boolean, after: String, before: String, first: Int, last: Int): ProvidedRepositoryConnection! diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index 9c9e4c7fb154..0dac0f78413a 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -541,8 +541,8 @@ impl Query { .await } - async fn resolve_git_url(ctx: &Context, git_url: String) -> Result> { - let user = check_user(ctx).await?; + async fn resolve_git_url(ctx: &Context, git_url: String) -> Result { + let user = check_user_and_auth_token(ctx).await?; let repositorys = ctx .locator @@ -553,11 +553,11 @@ impl Query { for repo in repositorys { if repo.git_url == git_url { - return Ok(Some(repo)); + return Ok(true); } } - Ok(None) + return Ok(false); } async fn context_info(ctx: &Context) -> Result { diff --git a/ee/tabby-ui/lib/tabby/gql.ts b/ee/tabby-ui/lib/tabby/gql.ts index 3a87ef9b7e9c..6274cc18f0de 100644 --- a/ee/tabby-ui/lib/tabby/gql.ts +++ b/ee/tabby-ui/lib/tabby/gql.ts @@ -123,7 +123,6 @@ const client = new Client({ ServerInfo: () => null, RepositorySearch: () => null, RepositoryList: () => null, - // IsAvaileableWorkspace: () => null, RepositoryGrep: () => null, GrepLine: () => null, GrepFile: () => null, diff --git a/ee/tabby-ui/lib/tabby/query.ts b/ee/tabby-ui/lib/tabby/query.ts index 2fd632f79ce0..04f69f0fb9f5 100644 --- a/ee/tabby-ui/lib/tabby/query.ts +++ b/ee/tabby-ui/lib/tabby/query.ts @@ -280,9 +280,9 @@ export const repositoryListQuery = graphql(/* GraphQL */ ` } `) -export const isAvaileableWorkspaceQuery = graphql(/* GraphQL */ ` - query IsAvaileableWorkspace($gitUrl: String!) { - isAvaileableWorkspace(gitUrl: $gitUrl) +export const resolveGitUrlQuery = graphql(/* GraphQL */ ` + query ResolveGitUrl($gitUrl: String!) { + resolveGitUrl(gitUrl: $gitUrl) } `) From d8dc027a92fed22b8e931d891130aa1e9dd28273 Mon Sep 17 00:00:00 2001 From: zzgu Date: Wed, 11 Dec 2024 17:09:40 -0800 Subject: [PATCH 4/6] fix(graphQL): resolve comments --- ee/tabby-schema/graphql/schema.graphql | 2 +- ee/tabby-schema/src/schema/mod.rs | 28 ++++++++++---------- ee/tabby-schema/src/schema/repository/mod.rs | 4 +-- ee/tabby-ui/components/chat/chat.tsx | 8 +++--- ee/tabby-ui/lib/tabby/query.ts | 14 +++++++++- 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index ffbfbf437d5e..e54c94d17977 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -715,7 +715,7 @@ type Query { userEvents(after: String, before: String, first: Int, last: Int, users: [ID!], start: DateTime!, end: DateTime!): UserEventConnection! diskUsageStats: DiskUsageStats! repositoryList: [Repository!]! - resolveGitUrl(gitUrl: String!): Boolean! + resolveGitUrl(gitUrl: String!): Repository contextInfo: ContextInfo! integrations(ids: [ID!], kind: IntegrationKind, after: String, before: String, first: Int, last: Int): IntegrationConnection! integratedRepositories(ids: [ID!], kind: IntegrationKind, active: Boolean, after: String, before: String, first: Int, last: Int): ProvidedRepositoryConnection! diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index 0dac0f78413a..5f6296dc7102 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -541,23 +541,23 @@ impl Query { .await } - async fn resolve_git_url(ctx: &Context, git_url: String) -> Result { - let user = check_user_and_auth_token(ctx).await?; + async fn resolve_git_url(ctx: &Context, git_url: String) -> Result> { + let user = check_user_and_auth_token(ctx, true).await?; - let repositorys = ctx - .locator + let context_info = ctx.locator.context().read(Some(&user.policy)).await?; + let target_source_id: Option = context_info.helper().allowed_code_repository().closest_match(&git_url).map(String::from); + let repos = ctx.locator .repository() .repository_list(Some(&user.policy)) - .await - .unwrap_or_default(); - - for repo in repositorys { - if repo.git_url == git_url { - return Ok(true); - } - } - - return Ok(false); + .await?; + + // Iterate through repositories and find matching source_id + let matching_repo = repos.iter().find(|repo| { + // Match repo source_id with your target + Some(&repo.source_id) == target_source_id.as_ref() + }); + + Ok(matching_repo.map(|repo| repo.clone())) } async fn context_info(ctx: &Context) -> Result { diff --git a/ee/tabby-schema/src/schema/repository/mod.rs b/ee/tabby-schema/src/schema/repository/mod.rs index bfc91ef4c8e8..8d3ba6a52f3f 100644 --- a/ee/tabby-schema/src/schema/repository/mod.rs +++ b/ee/tabby-schema/src/schema/repository/mod.rs @@ -40,7 +40,7 @@ pub enum RepositoryKind { GitConfig, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Repository { pub id: ID, @@ -100,7 +100,7 @@ impl Repository { } } -#[derive(GraphQLObject, Debug)] +#[derive(GraphQLObject, Debug, Clone)] pub struct GitReference { pub name: String, pub commit: String, diff --git a/ee/tabby-ui/components/chat/chat.tsx b/ee/tabby-ui/components/chat/chat.tsx index e23db41bd0cc..7ae1969555af 100644 --- a/ee/tabby-ui/components/chat/chat.tsx +++ b/ee/tabby-ui/components/chat/chat.tsx @@ -38,8 +38,8 @@ import { EmptyScreen } from './empty-screen' import { QuestionAnswerList } from './question-answer' import { createRequest } from '@urql/core' import { client } from '@/lib/tabby/gql' -import { IsAvaileableWorkspaceQuery } from '@/lib/gql/generates/graphql' -import { isAvaileableWorkspaceQuery, repositoryListQuery } from '@/lib/tabby/query' +import { ResolveGitUrlQuery } from '@/lib/gql/generates/graphql' +import { resolveGitUrlQuery, repositoryListQuery } from '@/lib/tabby/query' type ChatContextValue = { threadId: string | undefined @@ -107,12 +107,12 @@ interface ChatProps extends React.ComponentProps<'div'> { } async function isAvaileableWorkspace(gitUrl: string): Promise< - IsAvaileableWorkspaceQuery['isAvaileableWorkspace'] + ResolveGitUrlQuery['resolveGitUrl'] > { // debugger const query = client.createRequestOperation( 'query', - createRequest(isAvaileableWorkspaceQuery, { gitUrl }) + createRequest(resolveGitUrlQuery, { gitUrl }) ) return client diff --git a/ee/tabby-ui/lib/tabby/query.ts b/ee/tabby-ui/lib/tabby/query.ts index 04f69f0fb9f5..93ae9adc9483 100644 --- a/ee/tabby-ui/lib/tabby/query.ts +++ b/ee/tabby-ui/lib/tabby/query.ts @@ -282,7 +282,19 @@ export const repositoryListQuery = graphql(/* GraphQL */ ` export const resolveGitUrlQuery = graphql(/* GraphQL */ ` query ResolveGitUrl($gitUrl: String!) { - resolveGitUrl(gitUrl: $gitUrl) + resolveGitUrl(gitUrl: $gitUrl) { + id + sourceId + sourceKind + sourceName + name + kind + gitUrl + refs { + name + commit + } + } } `) From d16b1bda77cba370bcf211a68634fc843a33a882 Mon Sep 17 00:00:00 2001 From: zzgu Date: Wed, 11 Dec 2024 19:04:17 -0800 Subject: [PATCH 5/6] polish --- ee/tabby-ui/app/chat/page.tsx | 3 --- ee/tabby-ui/components/chat/chat.tsx | 19 ++----------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/ee/tabby-ui/app/chat/page.tsx b/ee/tabby-ui/app/chat/page.tsx index 5c48f7a3666a..44535580864b 100644 --- a/ee/tabby-ui/app/chat/page.tsx +++ b/ee/tabby-ui/app/chat/page.tsx @@ -129,7 +129,6 @@ export default function ChatPage() { setErrorMessage(null) }, addRelevantContext: context => { - console.log('context', context) return addRelevantContext(context) }, updateTheme: (style, themeClass) => { @@ -268,8 +267,6 @@ export default function ChatPage() { const onChatLoaded = () => { pendingRelevantContexts.forEach(addRelevantContext) pendingMessages.forEach(sendMessage) - - console.log('pendingActiveSelection', pendingActiveSelection) chatRef.current?.updateActiveSelection(pendingActiveSelection) diff --git a/ee/tabby-ui/components/chat/chat.tsx b/ee/tabby-ui/components/chat/chat.tsx index 7ae1969555af..cbc2db77da30 100644 --- a/ee/tabby-ui/components/chat/chat.tsx +++ b/ee/tabby-ui/components/chat/chat.tsx @@ -13,7 +13,6 @@ import { CreateMessageInput, InputMaybe, MessageAttachmentCodeInput, - RepositoryListQuery, ThreadRunOptionsInput } from '@/lib/gql/generates/graphql' import { useDebounceCallback } from '@/lib/hooks/use-debounce' @@ -106,10 +105,9 @@ interface ChatProps extends React.ComponentProps<'div'> { supportsOnApplyInEditorV2: boolean } -async function isAvaileableWorkspace(gitUrl: string): Promise< +async function resolveGitUrl(gitUrl: string): Promise< ResolveGitUrlQuery['resolveGitUrl'] > { - // debugger const query = client.createRequestOperation( 'query', createRequest(resolveGitUrlQuery, { gitUrl }) @@ -120,18 +118,6 @@ async function isAvaileableWorkspace(gitUrl: string): Promise< .then(data => console.log('data', data)) as any } -async function fetchAllRepositories(): Promise< - RepositoryListQuery['repositoryList'] -> { - const query = client.createRequestOperation( - 'query', - createRequest(repositoryListQuery, {}) - ) - return client - .executeQuery(query) - .then(data => data?.data?.repositoryList || []) -} - function ChatRenderer( { className, @@ -529,9 +515,8 @@ function ChatRenderer( const debouncedUpdateActiveSelection = useDebounceCallback( (ctx: Context | null) => { console.log('ctx', ctx); - if (ctx?.git_url) isAvaileableWorkspace(ctx.git_url) + // if (ctx?.git_url) resolveGitUrl(ctx.git_url) - fetchAllRepositories().then(res => console.log('fetchres', res)) setActiveSelection(ctx) }, 300 From b2c926de6cab1142c89272e11d3276df8d1245c5 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 03:12:58 +0000 Subject: [PATCH 6/6] [autofix.ci] apply automated fixes --- ee/tabby-schema/src/schema/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index 5f6296dc7102..fa8c95ab95bb 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -545,19 +545,24 @@ impl Query { let user = check_user_and_auth_token(ctx, true).await?; let context_info = ctx.locator.context().read(Some(&user.policy)).await?; - let target_source_id: Option = context_info.helper().allowed_code_repository().closest_match(&git_url).map(String::from); - let repos = ctx.locator + let target_source_id: Option = context_info + .helper() + .allowed_code_repository() + .closest_match(&git_url) + .map(String::from); + let repos = ctx + .locator .repository() .repository_list(Some(&user.policy)) .await?; - + // Iterate through repositories and find matching source_id let matching_repo = repos.iter().find(|repo| { // Match repo source_id with your target Some(&repo.source_id) == target_source_id.as_ref() }); - Ok(matching_repo.map(|repo| repo.clone())) + Ok(matching_repo.cloned()) } async fn context_info(ctx: &Context) -> Result {