Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: allow the user to close the prompt hint (#15177)

ecmadao7f250004abf9
diff --git a/frontend/src/components/v2/Model/PagedTable.vue b/frontend/src/components/v2/Model/PagedTable.vue
index cdc4bb74db..c426899ac2 100644
--- a/frontend/src/components/v2/Model/PagedTable.vue
+++ b/frontend/src/components/v2/Model/PagedTable.vue
@@ -32,10 +32,10 @@
</template>
<script lang="ts" setup generic="T extends object">
-import { useSessionStorage } from "@vueuse/core";
import { NSelect, NButton } from "naive-ui";
import { computed, reactive, watch, ref, type Ref } from "vue";
-import { useIsLoggedIn } from "@/store";
+import { useIsLoggedIn, useCurrentUserV1 } from "@/store";
+import { useDynamicLocalStorage } from "@/utils";
type LocalState = {
loading: boolean;
@@ -82,15 +82,19 @@ const state = reactive<LocalState>({
loading: false,
paginationToken: "",
});
+const currentUser = useCurrentUserV1();
// https://stackoverflow.com/questions/69813587/vue-unwraprefsimplet-generics-type-cant-assignable-to-t-at-reactive
const dataList = ref([]) as Ref<T[]>;
-const sessionState = useSessionStorage<SessionState>(props.sessionKey, {
- page: 1,
- updatedTs: 0,
- pageSize: options.value[0].value,
-});
+const sessionState = useDynamicLocalStorage<SessionState>(
+ computed(() => `${props.sessionKey}.${currentUser.value.name}`),
+ {
+ page: 1,
+ updatedTs: 0,
+ pageSize: options.value[0].value,
+ }
+);
const isLoggedIn = useIsLoggedIn();
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f8bb9a17e6..f474b82561 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2315,7 +2315,7 @@
},
"plugin": {
"ai": {
- "text-to-sql-placeholder": "在此输入自然语言后,Bytebase 会马上转换成 SQL 语句",
+ "text-to-sql-placeholder": "在此输入自然语言后,Bytebase 会将其转换成 SQL 语句",
"conversation": {
"untitled": "未命名会话",
"delete": "删除会话",
diff --git a/frontend/src/plugins/ai/components/DynamicSuggestions.vue b/frontend/src/plugins/ai/components/DynamicSuggestions.vue
index d3e9866ed1..a46d46d8d1 100644
--- a/frontend/src/plugins/ai/components/DynamicSuggestions.vue
+++ b/frontend/src/plugins/ai/components/DynamicSuggestions.vue
@@ -8,7 +8,7 @@
</template>
<div
- v-if="ready"
+ v-if="ready && showSuggestion"
class="relative flex items-center gap-1 overflow-hidden text-xs leading-4"
>
<NButton
@@ -23,16 +23,26 @@
</NButton>
<BBSpin v-if="state === 'LOADING'" :size="16" class="shrink-0" />
- <NButton
- v-if="state === 'IDLE'"
- size="tiny"
- type="primary"
- quaternary
- class="shrink-0"
- @click="dynamicSuggestions?.consume()"
- >
- <RefreshCwIcon class="w-3.5 h-3.5" />
- </NButton>
+ <div v-if="state === 'IDLE'" class="flex items-center">
+ <NButton
+ size="tiny"
+ type="primary"
+ quaternary
+ class="shrink-0"
+ @click="dynamicSuggestions?.consume()"
+ >
+ <RefreshCwIcon class="w-3.5 h-3.5" />
+ </NButton>
+ <NButton
+ size="tiny"
+ type="primary"
+ quaternary
+ class="shrink-0"
+ @click="() => (showSuggestion = false)"
+ >
+ <XIcon class="w-3.5 h-3.5" />
+ </NButton>
+ </div>
<span v-if="state === 'ENDED'" class="shrink-0 text-gray-500">
{{ $t("plugin.ai.conversation.tips.no-more") }}
</span>
@@ -41,10 +51,12 @@
</template>
<script lang="ts" setup>
-import { RefreshCwIcon } from "lucide-vue-next";
+import { RefreshCwIcon, XIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { computed } from "vue";
import { BBSpin } from "@/bbkit";
+import { useCurrentUserV1 } from "@/store";
+import { useDynamicLocalStorage } from "@/utils";
import { useDynamicSuggestions } from "../logic";
const emit = defineEmits<{
@@ -52,12 +64,18 @@ const emit = defineEmits<{
}>();
const dynamicSuggestions = useDynamicSuggestions();
+const currentUser = useCurrentUserV1();
const ready = computed(() => dynamicSuggestions.value?.ready ?? false);
const state = computed(() => dynamicSuggestions.value?.state ?? "IDLE");
const suggestions = computed(() => dynamicSuggestions.value?.suggestions ?? []);
const current = computed(() => dynamicSuggestions.value?.current());
+const showSuggestion = useDynamicLocalStorage<boolean>(
+ computed(() => `bb.sql-editor.ai-suggestion.${currentUser.value.name}`),
+ true
+);
+
const show = computed(() => {
if (!ready.value) return true; // show a spinner
return suggestions.value.length > 0 || state.value === "LOADING";