Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
feat(ai-exp): add support for custom request naming scheme (#4703)
Govind.S.Bd436af587c94
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.jsonindex 7454f2334..b79fc99b6 100644--- a/packages/hoppscotch-common/locales/en.json+++ b/packages/hoppscotch-common/locales/en.json@@ -802,6 +802,8 @@"ai_request_naming_style_camel_case": "Camel Case ( camelCase )","ai_request_naming_style_snake_case": "Snake Case ( snake_case )","ai_request_naming_style_pascal_case": "Pascal Case ( PascalCase )",+ "ai_request_naming_style_custom": "Custom",+ "ai_request_naming_style_custom_placeholder": "Enter your custom naming style template...","sync": "Synchronise","sync_collections": "Collections","sync_description": "These settings are synced to cloud.",diff --git a/packages/hoppscotch-common/src/composables/ai-experiments.ts b/packages/hoppscotch-common/src/composables/ai-experiments.tsindex 8739360ad..767bd8368 100644--- a/packages/hoppscotch-common/src/composables/ai-experiments.ts+++ b/packages/hoppscotch-common/src/composables/ai-experiments.ts@@ -50,6 +50,7 @@ export const useRequestNameGeneration = (targetNameRef: Ref<string>) => {}const namingStyle = useSetting("AI_REQUEST_NAMING_STYLE").value+ const customNamingStyle = useSetting("CUSTOM_NAMING_STYLE").valueisGenerateRequestNamePending.value = true@@ -60,7 +61,7 @@ export const useRequestNameGeneration = (targetNameRef: Ref<string>) => {const result = await generateRequestNameForPlatform(JSON.stringify(requestContext),- namingStyle+ namingStyle === "CUSTOM" ? customNamingStyle : namingStyle)if (result && E.isLeft(result)) {diff --git a/packages/hoppscotch-common/src/newstore/settings.ts b/packages/hoppscotch-common/src/newstore/settings.tsindex b0130a697..8581fbf59 100644--- a/packages/hoppscotch-common/src/newstore/settings.ts+++ b/packages/hoppscotch-common/src/newstore/settings.ts@@ -78,6 +78,8 @@ export type SettingsDef = {| "camelCase"| "snake_case"| "PascalCase"+ | "CUSTOM"+ CUSTOM_NAMING_STYLE: string}export const getDefaultSettings = (): SettingsDef => ({@@ -129,6 +131,7 @@ export const getDefaultSettings = (): SettingsDef => ({HAS_OPENED_SPOTLIGHT: false,ENABLE_AI_EXPERIMENTS: true,AI_REQUEST_NAMING_STYLE: "DESCRIPTIVE_WITH_SPACES",+ CUSTOM_NAMING_STYLE: "",})type ApplySettingPayload = {diff --git a/packages/hoppscotch-common/src/pages/settings.vue b/packages/hoppscotch-common/src/pages/settings.vueindex f2325b20d..4da022180 100644--- a/packages/hoppscotch-common/src/pages/settings.vue+++ b/packages/hoppscotch-common/src/pages/settings.vue@@ -87,53 +87,70 @@<label class="text-secondaryLight">{{t("settings.ai_request_naming_style")}}</label>- <div class="flex">- <tippy- interactive- trigger="click"- theme="popover"- :on-shown="() => namingStyleTippyActions?.focus()"- >- <HoppSmartSelectWrapper>- <HoppButtonSecondary- class="flex flex-1 !justify-start rounded-none pr-8"- :label="activeNamingStyle?.label"- outline- />- </HoppSmartSelectWrapper>- <template #content="{ hide }">- <div- ref="namingStyleTippyActions"- class="flex flex-col focus:outline-none"- tabindex="0"- @keyup.escape="hide()"- >- <HoppSmartLink- v-for="style in supportedNamingStyles"- :key="style"- class="flex flex-1"- @click="- () => {- AI_REQUEST_NAMING_STYLE = style.id- hide()- }- "+ <div class="flex flex-col space-y-4">+ <div class="flex">+ <tippy+ interactive+ trigger="click"+ theme="popover"+ :on-shown="() => namingStyleTippyActions?.focus()"+ >+ <HoppSmartSelectWrapper>+ <HoppButtonSecondary+ class="flex flex-1 !justify-start rounded-none pr-8"+ :label="activeNamingStyle?.label"+ outline+ />+ </HoppSmartSelectWrapper>+ <template #content="{ hide }">+ <div+ ref="namingStyleTippyActions"+ class="flex flex-col focus:outline-none"+ tabindex="0"+ @keyup.escape="hide()">- <HoppSmartItem- :label="style.label"- :active-info-icon="- AI_REQUEST_NAMING_STYLE === style.id- "- :info-icon="- AI_REQUEST_NAMING_STYLE === style.id- ? IconDone- : null+ <HoppSmartLink+ v-for="style in supportedNamingStyles"+ :key="style.id"+ class="flex flex-1"+ @click="+ () => {+ AI_REQUEST_NAMING_STYLE = style.id+ hide()+ }"- />- </HoppSmartLink>- </div>- </template>- </tippy>+ >+ <HoppSmartItem+ :label="style.label"+ :active-info-icon="+ AI_REQUEST_NAMING_STYLE === style.id+ "+ :info-icon="+ AI_REQUEST_NAMING_STYLE === style.id+ ? IconDone+ : null+ "+ />+ </HoppSmartLink>+ </div>+ </template>+ </tippy>+ </div>+ <div+ v-if="AI_REQUEST_NAMING_STYLE === 'CUSTOM'"+ class="flex"+ >+ <textarea+ v-model="CUSTOM_NAMING_STYLE"+ class="flex flex-1 bg-primaryLight px-4 py-2 rounded border border-dividerLight focus:border-divider transition"+ :placeholder="+ t(+ 'settings.ai_request_naming_style_custom_placeholder'+ )+ "+ rows="4"+ />+ </div></div></div></div>@@ -274,6 +291,7 @@ const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")const ENABLE_AI_EXPERIMENTS = useSetting("ENABLE_AI_EXPERIMENTS")const AI_REQUEST_NAMING_STYLE = useSetting("AI_REQUEST_NAMING_STYLE")+const CUSTOM_NAMING_STYLE = useSetting("CUSTOM_NAMING_STYLE")const supportedNamingStyles = [{@@ -292,6 +310,10 @@ const supportedNamingStyles = [id: "PascalCase" as const,label: t("settings.ai_request_naming_style_pascal_case"),},+ {+ id: "CUSTOM" as const,+ label: t("settings.ai_request_naming_style_custom"),+ },]const activeNamingStyle = computed(() =>diff --git a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.tsindex c8116d4ae..b6faa3e81 100644--- a/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts+++ b/packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts@@ -79,6 +79,7 @@ const SettingsDefSchema = z.object({.string().optional().catch("DESCRIPTIVE_WITH_SPACES"),+ CUSTOM_NAMING_STYLE: z.string().optional().catch(""),})const HoppRESTRequestSchema = entityReference(HoppRESTRequest)