diff --git a/src/lib/commandCenter/panels/ai.svelte b/src/lib/commandCenter/panels/ai.svelte
index e44d0e28e..58407c678 100644
--- a/src/lib/commandCenter/panels/ai.svelte
+++ b/src/lib/commandCenter/panels/ai.svelte
@@ -148,7 +148,12 @@
})}
clearOnCallback={false}
on:keydown={(e) => {
- if (e.detail.key !== 'Escape') {
+ const showingExamples = !$isLoading && !answer;
+ if (e.detail.key === 'Enter' && $input.trim()) {
+ e.detail.cancel();
+ return;
+ }
+ if (e.detail.key !== 'Escape' && !showingExamples) {
e.detail.cancel();
}
}}
@@ -302,15 +307,27 @@
}
}
- :global(.answer ul),
- :global(.answer ol) {
- gap: 1rem;
+ :global(.answer ul) {
+ padding-inline-start: 1rem;
+ list-style-type: disc;
display: grid;
+ gap: 1rem;
+ }
+
+ :global(.answer ol) {
+ padding-inline-start: 1.1rem;
+ list-style-type: decimal;
+ display: grid;
+ gap: 1rem;
}
:global(.answer a) {
text-decoration: underline;
}
+
+ :global(.answer a:hover) {
+ opacity: 0.8;
+ }
}
.experimental {
diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte
index 406b40222..1c0f24a9f 100644
--- a/src/lib/components/bottomModalAlert.svelte
+++ b/src/lib/components/bottomModalAlert.svelte
@@ -3,7 +3,6 @@
import { hideNotification, shouldShowNotification } from '$lib/helpers/notifications';
import { app } from '$lib/stores/app';
import {
- type BottomModalAlertAction,
type BottomModalAlertItem,
bottomModalAlertsConfig,
dismissBottomModalAlert,
@@ -20,18 +19,18 @@
import { goto } from '$app/navigation';
import { Typography } from '@appwrite.io/pink-svelte';
- let currentIndex = 0;
- let openModalOnMobile = false;
+ let currentIndex = $state(0);
+ let openModalOnMobile = $state(false);
- function getPageScope(pathname: string) {
- const isProjectPage = pathname.includes('project-[region]-[project]');
- const isOrganizationPage = pathname.includes('organization-[organization]');
+ function getPageScope(route: string) {
+ const isProjectPage = route.includes('project-[region]-[project]');
+ const isOrganizationPage = route.includes('organization-[organization]');
return { isProjectPage, isOrganizationPage };
}
- function filterModalAlerts(alerts: BottomModalAlertItem[], pathname: string) {
- const { isProjectPage, isOrganizationPage } = getPageScope(pathname);
+ function filterModalAlerts(alerts: BottomModalAlertItem[], route: string) {
+ const { isProjectPage, isOrganizationPage } = getPageScope(route);
return alerts
.sort((a, b) => b.importance - a.importance)
@@ -51,19 +50,32 @@
});
}
- $: filteredModalAlerts = filterModalAlerts($bottomModalAlertsConfig.alerts, page.route.id);
+ const bottomModalAlerts = $derived($bottomModalAlertsConfig.alerts);
- $: currentModalAlert = filteredModalAlerts[currentIndex] as BottomModalAlertItem;
+ const filteredModalAlerts = $derived(filterModalAlerts(bottomModalAlerts, page.route.id));
- $: hasOnlyPrimaryCta = typeof currentModalAlert?.learnMore === 'undefined';
+ const currentModalAlert = $derived(filteredModalAlerts[currentIndex] as BottomModalAlertItem);
- function handleClose() {
- filteredModalAlerts.forEach((alert) => {
+ const hasOnlyPrimaryCta = $derived(typeof currentModalAlert?.learnMore === 'undefined');
+
+ const isOnOnboarding = $derived(page.route.id.includes('(console)/onboarding'));
+
+ function handleClose(id: string | null = null) {
+ const alerts = !id
+ ? filteredModalAlerts
+ : filteredModalAlerts.filter((alert) => alert.id === id);
+
+ alerts.forEach((alert) => {
const modalAlert = alert;
dismissBottomModalAlert(modalAlert.id);
hideNotification(modalAlert.id, { coolOffPeriod: 24 * 365 });
if (modalAlert.closed) modalAlert.closed();
});
+
+ // reset `currentIndex` if we removed the last item
+ if (currentIndex >= filteredModalAlerts.length - 1) {
+ currentIndex = Math.max(0, filteredModalAlerts.length - 2);
+ }
}
function showNext() {
@@ -114,8 +126,13 @@
}
// the button component cannot have both href and on:click!
- function triggerWindowLink(alertAction: BottomModalAlertAction, event?: string) {
+ function triggerWindowLink(alert: BottomModalAlertItem, event?: string) {
+ const alertAction = alert.cta;
const shouldShowUpgrade = showUpgrade();
+
+ // for correct event tracking after removal
+ const currentModalId = currentModalAlert.id;
+
const url = shouldShowUpgrade
? $upgradeURL
: alertAction.link({
@@ -130,14 +147,12 @@
}
if (alertAction?.hideOnClick === true) {
- // be careful of this one.
- // once clicked, its gone!
- handleClose();
+ handleClose(alert.id); // gone!
}
trackEvent(Click.PromoClick, {
- promo: currentModalAlert.id,
- type: shouldShowUpgrade ? 'upgrade' : (event ?? `cta_click_${currentModalAlert.id}`)
+ promo: currentModalId,
+ type: shouldShowUpgrade ? 'upgrade' : (event ?? `cta_click_${currentModalId}`)
});
}
@@ -156,12 +171,10 @@
}
}
- onMount(() => {
- addBottomModalAlerts();
- });
+ onMount(addBottomModalAlerts);
-{#if filteredModalAlerts.length > 0 && currentModalAlert && !page.url.pathname.includes('console/onboarding')}
+{#if !isOnOnboarding && filteredModalAlerts.length > 0 && currentModalAlert}
{@const shouldShowUpgrade = showUpgrade()}
@@ -170,7 +183,7 @@
@@ -243,7 +261,7 @@
fullWidthMobile
secondary={!hasOnlyPrimaryCta}
class={`${hasOnlyPrimaryCta ? 'only-primary-cta' : ''}`}
- on:click={() => triggerWindowLink(currentModalAlert.cta)}>
+ on:click={() => triggerWindowLink(currentModalAlert)}>
{currentModalAlert.cta.text}
@@ -276,7 +294,7 @@