🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: preserve static image and cloud installation URLs (#20998)
Innei0a7f5c9f23e5
diff --git a/packages/const/src/url.ts b/packages/const/src/url.tsindex 9fda22d57f4..e27599fce71 100644--- a/packages/const/src/url.ts+++ b/packages/const/src/url.ts@@ -88,7 +88,8 @@ export const GROUP_CHAT_TOPIC_URL = (groupId: string, topicId: string) =>export const LIBRARY_URL = (id: string) => urlJoin('/resource/library', id);-export const imageUrl = (filename: string) => `/app-images/${filename}`;+// Fixed product imagery is mirrored to the static origin; /app-images belongs to the App.+export const imageUrl = (filename: string) => `/static/app-images/${filename}`;export const LOBE_URL_IMPORT_NAME = 'settings';diff --git a/public/app-images/agent-artwork-styles/line-art-reference.webp b/public/static/app-images/agent-artwork-styles/line-art-reference.webpsimilarity index 100%rename from public/app-images/agent-artwork-styles/line-art-reference.webprename to public/static/app-images/agent-artwork-styles/line-art-reference.webpdiff --git a/public/app-images/agent-artwork-styles/style-anime.webp b/public/static/app-images/agent-artwork-styles/style-anime.webpsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-anime.webprename to public/static/app-images/agent-artwork-styles/style-anime.webpdiff --git a/public/app-images/agent-artwork-styles/style-clay.jpg b/public/static/app-images/agent-artwork-styles/style-clay.jpgsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-clay.jpgrename to public/static/app-images/agent-artwork-styles/style-clay.jpgdiff --git a/public/app-images/agent-artwork-styles/style-geometric.jpg b/public/static/app-images/agent-artwork-styles/style-geometric.jpgsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-geometric.jpgrename to public/static/app-images/agent-artwork-styles/style-geometric.jpgdiff --git a/public/app-images/agent-artwork-styles/style-lineArt.webp b/public/static/app-images/agent-artwork-styles/style-lineArt.webpsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-lineArt.webprename to public/static/app-images/agent-artwork-styles/style-lineArt.webpdiff --git a/public/app-images/agent-artwork-styles/style-painterly.webp b/public/static/app-images/agent-artwork-styles/style-painterly.webpsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-painterly.webprename to public/static/app-images/agent-artwork-styles/style-painterly.webpdiff --git a/public/app-images/agent-artwork-styles/style-pixel.jpg b/public/static/app-images/agent-artwork-styles/style-pixel.jpgsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-pixel.jpgrename to public/static/app-images/agent-artwork-styles/style-pixel.jpgdiff --git a/public/app-images/agent-artwork-styles/style-pixel.webp b/public/static/app-images/agent-artwork-styles/style-pixel.webpsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-pixel.webprename to public/static/app-images/agent-artwork-styles/style-pixel.webpdiff --git a/public/app-images/agent-artwork-styles/style-sticker.jpg b/public/static/app-images/agent-artwork-styles/style-sticker.jpgsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-sticker.jpgrename to public/static/app-images/agent-artwork-styles/style-sticker.jpgdiff --git a/public/app-images/agent-artwork-styles/style-watercolor.jpg b/public/static/app-images/agent-artwork-styles/style-watercolor.jpgsimilarity index 100%rename from public/app-images/agent-artwork-styles/style-watercolor.jpgrename to public/static/app-images/agent-artwork-styles/style-watercolor.jpgdiff --git a/public/app-images/agent_gateway_dark.webp b/public/static/app-images/agent_gateway_dark.webpsimilarity index 100%rename from public/app-images/agent_gateway_dark.webprename to public/static/app-images/agent_gateway_dark.webpdiff --git a/public/app-images/agent_gateway_light.webp b/public/static/app-images/agent_gateway_light.webpsimilarity index 100%rename from public/app-images/agent_gateway_light.webprename to public/static/app-images/agent_gateway_light.webpdiff --git a/public/app-images/banner_creator.png b/public/static/app-images/banner_creator.pngsimilarity index 100%rename from public/app-images/banner_creator.pngrename to public/static/app-images/banner_creator.pngdiff --git a/public/app-images/banner_market_modal.webp b/public/static/app-images/banner_market_modal.webpsimilarity index 100%rename from public/app-images/banner_market_modal.webprename to public/static/app-images/banner_market_modal.webpdiff --git a/public/app-images/chatmode_chat_dark.webp b/public/static/app-images/chatmode_chat_dark.webpsimilarity index 100%rename from public/app-images/chatmode_chat_dark.webprename to public/static/app-images/chatmode_chat_dark.webpdiff --git a/public/app-images/chatmode_chat_light.webp b/public/static/app-images/chatmode_chat_light.webpsimilarity index 100%rename from public/app-images/chatmode_chat_light.webprename to public/static/app-images/chatmode_chat_light.webpdiff --git a/public/app-images/chatmode_docs_dark.webp b/public/static/app-images/chatmode_docs_dark.webpsimilarity index 100%rename from public/app-images/chatmode_docs_dark.webprename to public/static/app-images/chatmode_docs_dark.webpdiff --git a/public/app-images/chatmode_docs_light.webp b/public/static/app-images/chatmode_docs_light.webpsimilarity index 100%rename from public/app-images/chatmode_docs_light.webprename to public/static/app-images/chatmode_docs_light.webpdiff --git a/public/app-images/community_footer_dark.webp b/public/static/app-images/community_footer_dark.webpsimilarity index 100%rename from public/app-images/community_footer_dark.webprename to public/static/app-images/community_footer_dark.webpdiff --git a/public/app-images/community_footer_light.webp b/public/static/app-images/community_footer_light.webpsimilarity index 100%rename from public/app-images/community_footer_light.webprename to public/static/app-images/community_footer_light.webpdiff --git a/public/app-images/community_header_dark.webp b/public/static/app-images/community_header_dark.webpsimilarity index 100%rename from public/app-images/community_header_dark.webprename to public/static/app-images/community_header_dark.webpdiff --git a/public/app-images/community_header_light.webp b/public/static/app-images/community_header_light.webpsimilarity index 100%rename from public/app-images/community_header_light.webprename to public/static/app-images/community_header_light.webpdiff --git a/public/app-images/empty_topic_dark.webp b/public/static/app-images/empty_topic_dark.webpsimilarity index 100%rename from public/app-images/empty_topic_dark.webprename to public/static/app-images/empty_topic_dark.webpdiff --git a/public/app-images/empty_topic_light.webp b/public/static/app-images/empty_topic_light.webpsimilarity index 100%rename from public/app-images/empty_topic_light.webprename to public/static/app-images/empty_topic_light.webpdiff --git a/public/app-images/mode_lite_dark.webp b/public/static/app-images/mode_lite_dark.webpsimilarity index 100%rename from public/app-images/mode_lite_dark.webprename to public/static/app-images/mode_lite_dark.webpdiff --git a/public/app-images/mode_lite_light.webp b/public/static/app-images/mode_lite_light.webpsimilarity index 100%rename from public/app-images/mode_lite_light.webprename to public/static/app-images/mode_lite_light.webpdiff --git a/public/app-images/mode_pro_dark.webp b/public/static/app-images/mode_pro_dark.webpsimilarity index 100%rename from public/app-images/mode_pro_dark.webprename to public/static/app-images/mode_pro_dark.webpdiff --git a/public/app-images/mode_pro_light.webp b/public/static/app-images/mode_pro_light.webpsimilarity index 100%rename from public/app-images/mode_pro_light.webprename to public/static/app-images/mode_pro_light.webpdiff --git a/public/app-images/screenshot_background.webp b/public/static/app-images/screenshot_background.webpsimilarity index 100%rename from public/app-images/screenshot_background.webprename to public/static/app-images/screenshot_background.webpdiff --git a/public/app-images/theme_auto.webp b/public/static/app-images/theme_auto.webpsimilarity index 100%rename from public/app-images/theme_auto.webprename to public/static/app-images/theme_auto.webpdiff --git a/public/app-images/theme_dark.webp b/public/static/app-images/theme_dark.webpsimilarity index 100%rename from public/app-images/theme_dark.webprename to public/static/app-images/theme_dark.webpdiff --git a/public/app-images/theme_light.webp b/public/static/app-images/theme_light.webpsimilarity index 100%rename from public/app-images/theme_light.webprename to public/static/app-images/theme_light.webpdiff --git a/src/features/ArtworkStudio/styleReferences.test.ts b/src/features/ArtworkStudio/styleReferences.test.tsindex 0e8645188f6..05b767bbf1d 100644--- a/src/features/ArtworkStudio/styleReferences.test.ts+++ b/src/features/ArtworkStudio/styleReferences.test.ts@@ -1,3 +1,9 @@+import { readFileSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++import { imageUrl } from '@lobechat/const';+import { AGENT_ARTWORK_STYLES } from '@lobechat/prompts';import { describe, expect, it } from 'vitest';import { styleReferencesForArtworkStyle } from './styleReferences';@@ -8,11 +14,40 @@ describe('styleReferencesForArtworkStyle', () => {const references = styleReferencesForArtworkStyle('lineArt', appOrigin);const reference = references?.[0];- expect(reference).toBe(`${appOrigin}/app-images/agent-artwork-styles/line-art-reference.webp`);+ expect(reference).toBe(+ `${appOrigin}/static/app-images/agent-artwork-styles/line-art-reference.webp`,+ );expect(new URL(reference!).origin).toBe(appOrigin);++ const bytes = readFileSync(+ path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ '../../../public',+ new URL(reference!).pathname.slice(1),+ ),+ );+ expect(bytes.toString('ascii', 0, 4)).toBe('RIFF');+ expect(bytes.toString('ascii', 8, 12)).toBe('WEBP');});it('omits the line-art reference until an app origin is available', () => {expect(styleReferencesForArtworkStyle('lineArt')).toBeUndefined();});++ it.each(AGENT_ARTWORK_STYLES.filter((style) => style !== 'lobe'))(+ 'ships the %s preview at the URL requested by the artwork gallery',+ (style) => {+ const pathname = imageUrl(`agent-artwork-styles/style-${style}.webp`);+ expect(pathname.startsWith('/static/')).toBe(true);+ const bytes = readFileSync(+ path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ '../../../public',+ pathname.slice(1),+ ),+ );+ expect(bytes.toString('ascii', 0, 4)).toBe('RIFF');+ expect(bytes.toString('ascii', 8, 12)).toBe('WEBP');+ },+ );});diff --git a/src/features/ChatInput/ActionBar/Plus/index.tsx b/src/features/ChatInput/ActionBar/Plus/index.tsxindex 409c9764ccb..53769755a90 100644--- a/src/features/ChatInput/ActionBar/Plus/index.tsx+++ b/src/features/ChatInput/ActionBar/Plus/index.tsx@@ -20,6 +20,7 @@ import type { ReactNode } from 'react';import { memo, Suspense, useCallback, useMemo, useRef } from 'react';import { useTranslation } from 'react-i18next';+import { imageUrl } from '@/const/url';import { openAttachKnowledgeModal } from '@/features/LibraryModal';import { useIsDark } from '@/hooks/useIsDark';import { useMediaUploadAbility } from '@/hooks/useMediaUploadAbility';@@ -335,9 +336,7 @@ const usePlusMenuItems = ({ close }: { close: () => void }): ActionDropdownMenuI<imgalt=""className="cover"- src={- isDark ? '/app-images/agent_gateway_dark.webp' : '/app-images/agent_gateway_light.webp'- }+ src={imageUrl(isDark ? 'agent_gateway_dark.webp' : 'agent_gateway_light.webp')}/><div className="body"><div className="title">{t('gatewayMode.cardTitle')}</div>diff --git a/src/features/Integrations/Github/installHref.test.ts b/src/features/Integrations/Github/installHref.test.tsindex f6f3abe32c7..b5a040d7545 100644--- a/src/features/Integrations/Github/installHref.test.ts+++ b/src/features/Integrations/Github/installHref.test.ts@@ -6,6 +6,27 @@ const INSTALL_PATH = '/api/webhooks/github/install';const ORIGIN = 'https://app.lobehub.com';describe('buildGithubInstallHref', () => {+ it('keeps the app login origin and workspace scope when starting from the cloud gateway', () => {+ const href = buildGithubInstallHref(INSTALL_PATH, {+ appOrigin: 'https://lobehub.com/',+ workspaceId: 'ws_123',+ workspaceSlug: 'acme',+ });+ const url = new URL(href!);+ expect(url.origin).toBe('https://app.lobehub.com');+ expect(url.pathname).toBe(INSTALL_PATH);+ expect(url.searchParams.get('workspaceId')).toBe('ws_123');+ expect(url.searchParams.get('returnTo')).toBe('/acme/settings/integrations/github');+ });++ it('preserves a self-hosted install origin and path prefix', () => {+ const href = buildGithubInstallHref(INSTALL_PATH, {+ appOrigin: 'https://chat.example.com/lobe/',+ });+ expect(new URL(href!).origin).toBe('https://chat.example.com');+ expect(new URL(href!).pathname).toBe(`/lobe${INSTALL_PATH}`);+ });+it('returns undefined until the app origin is known', () => {expect(buildGithubInstallHref(INSTALL_PATH, { workspaceId: null, workspaceSlug: null })).toBe(undefined,diff --git a/src/features/Integrations/Github/installHref.ts b/src/features/Integrations/Github/installHref.tsindex 3d5008958c9..29c1f5cae0d 100644--- a/src/features/Integrations/Github/installHref.ts+++ b/src/features/Integrations/Github/installHref.ts@@ -1,5 +1,7 @@import urlJoin from 'url-join';+import { integrationInstallOrigin } from '@/utils/integrationInstallOrigin';+/** Where the install callback sends the user back to. */export const GITHUB_RETURN_TO = '/settings/integrations/github';@@ -32,5 +34,5 @@ export const buildGithubInstallHref = (});if (workspaceId) query.set('workspaceId', workspaceId);- return `${urlJoin(appOrigin, installPath)}?${query}`;+ return `${urlJoin(integrationInstallOrigin(appOrigin), installPath)}?${query}`;};diff --git a/src/features/Messenger/installHref.test.ts b/src/features/Messenger/installHref.test.tsindex a2919d44adc..1c3625b6e9d 100644--- a/src/features/Messenger/installHref.test.ts+++ b/src/features/Messenger/installHref.test.ts@@ -3,9 +3,18 @@ import { describe, expect, it } from 'vitest';import { resolveMessengerInstallHref } from './installHref';describe('resolveMessengerInstallHref', () => {- it('builds an absolute install URL against the app origin on web', () => {+ it('keeps official cloud installs on the app login origin', () => {expect(resolveMessengerInstallHref('discord', 'https://lobehub.com')).toBe(- 'https://lobehub.com/api/agent/messenger/discord/install',+ 'https://app.lobehub.com/api/agent/messenger/discord/install',+ );+ expect(resolveMessengerInstallHref('slack', 'https://lobehub.com/')).toBe(+ 'https://app.lobehub.com/api/agent/messenger/slack/install',+ );+ });++ it('preserves the configured self-hosted install origin and path prefix', () => {+ expect(resolveMessengerInstallHref('slack', 'https://chat.example.com/lobe/')).toBe(+ 'https://chat.example.com/lobe/api/agent/messenger/slack/install',);});diff --git a/src/features/Messenger/installHref.ts b/src/features/Messenger/installHref.tsindex 2c47a1d2d21..0622858421f 100644--- a/src/features/Messenger/installHref.ts+++ b/src/features/Messenger/installHref.ts@@ -1,6 +1,7 @@import urlJoin from 'url-join';import { useAppOrigin } from '@/hooks/useAppOrigin';+import { integrationInstallOrigin } from '@/utils/integrationInstallOrigin';/** Platforms whose "Connect" flow starts at the LobeHub OAuth install endpoint. */export type MessengerOAuthInstallPlatform = 'discord' | 'slack';@@ -24,7 +25,7 @@ export const resolveMessengerInstallHref = (): string | undefined => {if (!appOrigin) return undefined;- return urlJoin(appOrigin, MESSENGER_INSTALL_PATHS[platform]);+ return urlJoin(integrationInstallOrigin(appOrigin), MESSENGER_INSTALL_PATHS[platform]);};export const useMessengerInstallHref = (diff --git a/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx b/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsxindex 9e09a7f9235..e5e64c38288 100644--- a/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx+++ b/src/layout/AuthProvider/MarketAuth/MarketAuthConfirmModal.tsx@@ -8,7 +8,7 @@ import { memo } from 'react';import { Trans, useTranslation } from 'react-i18next';import ImperativeModal from '@/components/ImperativeModal';-import { PRIVACY_URL, TERMS_URL } from '@/const/url';+import { imageUrl, PRIVACY_URL, TERMS_URL } from '@/const/url';import AuthCard from '@/features/AuthCard';import { useIsDark } from '@/hooks/useIsDark';@@ -18,14 +18,14 @@ const styles = createStaticStyles(({ css }) => ({container: css`padding-block-start: 32px;- background-image: url('/app-images/community_header_light.webp');+ background-image: url(${imageUrl('community_header_light.webp')});background-repeat: no-repeat;background-position: 400% 0;background-size: 400px auto;background-blend-mode: multiply;`,container_dark: css`- background-image: url('/app-images/community_header_dark.webp');+ background-image: url(${imageUrl('community_header_dark.webp')});background-blend-mode: screen;`,}));diff --git a/src/libs/next/config/define-config.ts b/src/libs/next/config/define-config.tsindex 064e83d2bbe..6b82709e82e 100644--- a/src/libs/next/config/define-config.ts+++ b/src/libs/next/config/define-config.ts@@ -143,7 +143,7 @@ export function defineConfig(config: CustomNextConfig) {value: 'public, max-age=31536000, immutable',},],- source: '/app-images/(.*).(png|jpe?g|gif|svg|ico|webp)',+ source: '/static/app-images/(.*).(png|jpe?g|gif|svg|ico|webp)',},{headers: [diff --git a/src/routes/(main)/community/(list)/(home)/features/CreatorRewardBanner.tsx b/src/routes/(main)/community/(list)/(home)/features/CreatorRewardBanner.tsxindex a303b5c8e34..e29233dab5c 100644--- a/src/routes/(main)/community/(list)/(home)/features/CreatorRewardBanner.tsx+++ b/src/routes/(main)/community/(list)/(home)/features/CreatorRewardBanner.tsx@@ -6,7 +6,7 @@ import { createStaticStyles, cx, responsive } from 'antd-style';import { memo } from 'react';import { useTranslation } from 'react-i18next';-import { OFFICIAL_SITE } from '@/const/url';+import { imageUrl, OFFICIAL_SITE } from '@/const/url';import { useIsDark } from '@/hooks/useIsDark';const styles = createStaticStyles(({ css }) => ({@@ -57,7 +57,7 @@ const styles = createStaticStyles(({ css }) => ({width: 50%;border-radius: 0 12px 12px 0;- background: url('/app-images/banner_creator.png') right center / auto 100% no-repeat;+ background: url(${imageUrl('banner_creator.png')}) right center / auto 100% no-repeat;${responsive.sm} {display: none;diff --git a/src/routes/(main)/community/(list)/_layout/Footer.tsx b/src/routes/(main)/community/(list)/_layout/Footer.tsxindex f7b0b9203a2..cf095320eda 100644--- a/src/routes/(main)/community/(list)/_layout/Footer.tsx+++ b/src/routes/(main)/community/(list)/_layout/Footer.tsx@@ -4,6 +4,7 @@ import { createStaticStyles, cx } from 'antd-style';import { memo, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';+import { imageUrl } from '@/const/url';import DefaultFooter from '@/features/Setting/Footer';import { useIsDark } from '@/hooks/useIsDark';import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';@@ -18,11 +19,11 @@ const styles = createStaticStyles(({ css }) => ({background-size: 512px auto;`,footer_dark: css`- background-image: url('/app-images/community_footer_dark.webp');+ background-image: url(${imageUrl('community_footer_dark.webp')});background-blend-mode: screen;`,footer_light: css`- background-image: url('/app-images/community_footer_light.webp');+ background-image: url(${imageUrl('community_footer_light.webp')});background-blend-mode: multiply;`,}));diff --git a/src/utils/integrationInstallOrigin.ts b/src/utils/integrationInstallOrigin.tsnew file mode 100644index 00000000000..7e30aa4e8b3--- /dev/null+++ b/src/utils/integrationInstallOrigin.ts@@ -0,0 +1,5 @@+import { OFFICIAL_CLOUD_URL, OFFICIAL_URL } from '@lobechat/const';++// shortcut: keep cloud installs on the app origin until gateway login redirects are fixed.+export const integrationInstallOrigin = (appOrigin: string): string =>+ appOrigin.replace(/\/+$/, '') === OFFICIAL_CLOUD_URL ? OFFICIAL_URL : appOrigin;