feat: add enableWelcomeBack setting to control welcome back dialog

- Add enableWelcomeBack boolean setting to settings schema with default true
- Update useWelcomeBack hook to respect the enableWelcomeBack setting
- Pass settings to useWelcomeBack hook in App component
- Update settings schema test to include the new enableWelcomeBack setting
- Allow users to disable the welcome back dialog through settings
This commit is contained in:
pomelo-nwu
2025-09-10 15:10:39 +08:00
parent ab7a3259c5
commit c0e9dceabc
4 changed files with 20 additions and 2 deletions

View File

@@ -52,6 +52,7 @@ describe('SettingsSchema', () => {
'model', 'model',
'hasSeenIdeIntegrationNudge', 'hasSeenIdeIntegrationNudge',
'folderTrustFeature', 'folderTrustFeature',
'enableWelcomeBack',
]; ];
expectedSettings.forEach((setting) => { expectedSettings.forEach((setting) => {

View File

@@ -604,6 +604,16 @@ export const SETTINGS_SCHEMA = {
description: 'Skip the next speaker check.', description: 'Skip the next speaker check.',
showInDialog: true, showInDialog: true,
}, },
enableWelcomeBack: {
type: 'boolean',
label: 'Enable Welcome Back',
category: 'UI',
requiresRestart: false,
default: true,
description:
'Show welcome back dialog when returning to a project with conversation history.',
showInDialog: true,
},
} as const; } as const;
type InferSettings<T extends SettingsSchema> = { type InferSettings<T extends SettingsSchema> = {

View File

@@ -624,7 +624,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
welcomeBackChoice, welcomeBackChoice,
handleWelcomeBackSelection, handleWelcomeBackSelection,
handleWelcomeBackClose, handleWelcomeBackClose,
} = useWelcomeBack(config, submitQuery, buffer); } = useWelcomeBack(config, submitQuery, buffer, settings.merged);
// Message queue for handling input during streaming // Message queue for handling input during streaming
const { messageQueue, addMessage, clearQueue, getQueuedMessagesText } = const { messageQueue, addMessage, clearQueue, getQueuedMessagesText } =

View File

@@ -10,6 +10,7 @@ import {
type ProjectSummaryInfo, type ProjectSummaryInfo,
type Config, type Config,
} from '@qwen-code/qwen-code-core'; } from '@qwen-code/qwen-code-core';
import { type Settings } from '../../config/settingsSchema.js';
export interface WelcomeBackState { export interface WelcomeBackState {
welcomeBackInfo: ProjectSummaryInfo | null; welcomeBackInfo: ProjectSummaryInfo | null;
@@ -30,6 +31,7 @@ export function useWelcomeBack(
config: Config, config: Config,
submitQuery: (query: string) => void, submitQuery: (query: string) => void,
buffer: { setText: (text: string) => void }, buffer: { setText: (text: string) => void },
settings: Settings,
): WelcomeBackState & WelcomeBackActions { ): WelcomeBackState & WelcomeBackActions {
const [welcomeBackInfo, setWelcomeBackInfo] = const [welcomeBackInfo, setWelcomeBackInfo] =
useState<ProjectSummaryInfo | null>(null); useState<ProjectSummaryInfo | null>(null);
@@ -42,6 +44,11 @@ export function useWelcomeBack(
// Check for conversation history on startup // Check for conversation history on startup
const checkWelcomeBack = useCallback(async () => { const checkWelcomeBack = useCallback(async () => {
// Check if welcome back is enabled in settings
if (settings.enableWelcomeBack === false) {
return;
}
try { try {
const info = await getProjectSummaryInfo(); const info = await getProjectSummaryInfo();
if (info.hasHistory) { if (info.hasHistory) {
@@ -52,7 +59,7 @@ export function useWelcomeBack(
// Silently ignore errors - welcome back is not critical // Silently ignore errors - welcome back is not critical
console.debug('Welcome back check failed:', error); console.debug('Welcome back check failed:', error);
} }
}, []); }, [settings.enableWelcomeBack]);
// Handle welcome back dialog selection // Handle welcome back dialog selection
const handleWelcomeBackSelection = useCallback( const handleWelcomeBackSelection = useCallback(