diff --git a/ee/tabby-schema/graphql/schema.graphql b/ee/tabby-schema/graphql/schema.graphql index 997505ef8cd..f600e8b89de 100644 --- a/ee/tabby-schema/graphql/schema.graphql +++ b/ee/tabby-schema/graphql/schema.graphql @@ -237,6 +237,7 @@ input UpsertUserGroupMembershipInput { } interface ContextSource implements ContextSourceId { + id: ID! sourceId: String! sourceKind: ContextSourceKind! "Display name of the source, used to provide a human-readable name for user selection, such as in a dropdown menu." @@ -865,6 +866,7 @@ type UserSecured implements User { } type WebContextSource implements ContextSourceId & ContextSource { + id: ID! sourceKind: ContextSourceKind! sourceId: String! sourceName: String! diff --git a/ee/tabby-schema/src/schema/context.rs b/ee/tabby-schema/src/schema/context.rs index 0fa5ca27879..01d6d18536c 100644 --- a/ee/tabby-schema/src/schema/context.rs +++ b/ee/tabby-schema/src/schema/context.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use async_trait::async_trait; -use juniper::{graphql_interface, graphql_object, GraphQLEnum, GraphQLInterface, GraphQLObject}; +use juniper::{ + graphql_interface, graphql_object, GraphQLEnum, GraphQLInterface, GraphQLObject, ID, +}; use regex::{Captures, Regex}; use super::{ @@ -31,6 +33,8 @@ pub trait ContextSourceId { #[derive(GraphQLInterface)] #[graphql(context = Context, impl = [ContextSourceIdValue], for = [CustomWebDocument, PresetWebDocument, Repository, WebContextSource])] pub struct ContextSource { + pub id: ID, + // start implements ContextSource pub source_id: String, // end implements ContextSource @@ -66,6 +70,10 @@ const PUBLIC_WEB_INTERNAL_SOURCE_ID: &str = "internal-public-web"; #[graphql_object(context = Context, impl = [ContextSourceIdValue, ContextSourceValue])] impl WebContextSource { + fn id(&self) -> ID { + ID::new(PUBLIC_WEB_INTERNAL_SOURCE_ID.to_owned()) + } + fn source_kind(&self) -> ContextSourceKind { ContextSourceKind::Web } diff --git a/ee/tabby-schema/src/schema/repository/mod.rs b/ee/tabby-schema/src/schema/repository/mod.rs index 4c322052068..bfc91ef4c8e 100644 --- a/ee/tabby-schema/src/schema/repository/mod.rs +++ b/ee/tabby-schema/src/schema/repository/mod.rs @@ -110,7 +110,7 @@ impl From for Repository { fn from(value: GitRepository) -> Self { Self { source_id: value.source_id(), - id: value.id, + id: ID::new(value.source_id()), name: value.name, kind: RepositoryKind::Git, dir: RepositoryConfig::resolve_dir(&value.git_url), diff --git a/ee/tabby-ui/lib/tabby/gql.ts b/ee/tabby-ui/lib/tabby/gql.ts index e0075bb5bbb..24db957e08d 100644 --- a/ee/tabby-ui/lib/tabby/gql.ts +++ b/ee/tabby-ui/lib/tabby/gql.ts @@ -121,7 +121,6 @@ const client = new Client({ GrepFile: () => null, GrepTextOrBase64: () => null, GrepSubMatch: () => null, - Repository: (data: any) => (data ? `${data.kind}_${data.id}` : null), GitReference: () => null, MessageAttachment: () => null, MessageAttachmentCode: () => null, diff --git a/ee/tabby-ui/lib/tabby/query.ts b/ee/tabby-ui/lib/tabby/query.ts index 403392e94f2..406cc87f077 100644 --- a/ee/tabby-ui/lib/tabby/query.ts +++ b/ee/tabby-ui/lib/tabby/query.ts @@ -299,6 +299,7 @@ export const contextInfoQuery = graphql(/* GraphQL */ ` query ContextInfo { contextInfo { sources { + id sourceKind sourceId sourceName diff --git a/ee/tabby-webserver/src/service/repository/mod.rs b/ee/tabby-webserver/src/service/repository/mod.rs index 39cca0a3ef6..f34480d0b1a 100644 --- a/ee/tabby-webserver/src/service/repository/mod.rs +++ b/ee/tabby-webserver/src/service/repository/mod.rs @@ -238,7 +238,7 @@ fn list_refs(git_url: &str) -> Vec { fn to_repository(kind: RepositoryKind, repo: ProvidedRepository) -> Repository { Repository { source_id: repo.source_id(), - id: repo.id, + id: ID::new(repo.source_id()), name: repo.display_name, kind, dir: RepositoryConfig::resolve_dir(&repo.git_url), @@ -254,9 +254,10 @@ fn to_repository(kind: RepositoryKind, repo: ProvidedRepository) -> Repository { } fn repository_config_to_repository(index: usize, config: &RepositoryConfig) -> Result { + let source_id = config_index_to_id(index); Ok(Repository { - id: ID::new(config_index_to_id(index)), - source_id: config_index_to_id(index), + id: ID::new(source_id.clone()), + source_id, name: config.display_name(), kind: RepositoryKind::GitConfig, dir: config.dir(),