mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-05 04:52:57 +08:00
* fix(shell): hide prompt options on desktop * fix(chat): group continuous same-tool runs more consistently Consecutive tool calls (Edit, Read, Grep, etc.) grouped inconsistently: - The group threshold was 3, so a run of only 2 calls stayed ungrouped while a run of 3 collapsed — making two back-to-back edits look different from three. - A run was broken by any interleaved message, including ones that render nothing (reasoning hidden when showThinking is off). Providers like Codex interleave hidden reasoning between tool calls, so visually continuous edits intermittently failed to group. Lower TOOL_GROUP_THRESHOLD to 2 and skip non-rendered messages when extending a run, so any 2+ consecutive same-tool calls collapse reliably. ChatMessagesPane now passes showThinking into groupConsecutiveTools. * fix(chat): stabilize message scroll controls * fix: update command menu positioning * fix(chat): refine load all overlay behavior * fix(chat): hide load all prompt after final page * fix(chat): remove auto scroll quick setting * fix(chat): unify messages and composer into centered column Constrain both ChatMessagesPane content and ChatComposer to the same max-w-3xl centered column. Previously only the composer had a max-width, causing messages to fill the full width while the input stayed narrow, making them visually misaligned with large empty gutters on either side. * style(ui): rework light/dark theme to make it visually consistent Rework the color system around warm neutrals and route hardcoded surfaces through theme tokens for consistency. - Theme tokens (index.css, ThemeContext): warm cream light mode and neutral charcoal dark mode, replacing the pure-white/blue-tinted palette; update PWA theme-color meta - Code blocks: soft grey background in light mode via oneLight/oneDark, and drop the Tailwind Typography <pre> shell that framed the highlighter in a dark box - Dropdowns/panels: convert CommandMenu, Quick Settings, and the JSON response block from hardcoded gray/slate to popover/muted/border tokens - Git panel: Publish button purple -> primary blue - Composer: drop top padding so the input sits flush with the thread * fix: use app theme for code editor * style(chat): unify composer toolbar heights and declutter slash-command modal - Composer: give the permission-mode and token-usage buttons a fixed h-8 so every bottom-toolbar control shares one height - CommandResultModal: replace the blue gradient header (gradient fill, glow blobs, blue eyebrow + icon chip) with a clean neutral header on popover/muted tokens * fix(chat): header ellipsis, Codex logo on light theme, portal copy menu - MainContentTitle: truncate the session title with an ellipsis instead of horizontal-scrolling it - MessageComponent: use text-foreground for the provider logo chip so the currentColor Codex/OpenAI mark is visible on the light theme - MessageCopyControl: render the copy-format dropdown in a portal so it escapes the chat message's `contain: paint` clip box; anchor it to the trigger, flip above near the viewport bottom, close on scroll/resize * style(mcp): remove purple accents and portal the server form modal - Replace the purple provider-button colors, heading icon, and form submit button with the primary token (no purple in the MCP UI) - Portal the add/edit MCP server modal to document.body so its fixed overlay covers the full viewport, fixing the white band at the top caused by the Settings dialog's transformed tab content becoming the containing block * style(ui): use Merriweather serif for chat text and Encode Sans for the rest of the UI * fix: align activity indicator with composer input width Wrap ActivityIndicator in the same mx-auto max-w-3xl container as the text input so the "Analyzing…" label and Stop button stay within the input's boundaries instead of spanning the full window width. * style: improve thinking and stop button placements * style(auth): modernize login, setup, and onboarding screens * fix(chat): correct invalid dark-mode hover on AskUserQuestion options * fix: remove unnecessary auto expand tools * fix: resolve coderabbit comments * fix(chat): widen chat layout and sidebar titles * fix(branding): update CloudCLI wordmark styling --------- Co-authored-by: Simos Mikelatos <simosmik@gmail.com>
253 lines
9.2 KiB
TypeScript
253 lines
9.2 KiB
TypeScript
import { Check, ChevronLeft, ChevronRight, Loader2 } from 'lucide-react';
|
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
import type { LLMProvider } from '../../../types/app';
|
|
import { authenticatedFetch } from '../../../utils/api';
|
|
import { useProviderAuthStatus } from '../../provider-auth/hooks/useProviderAuthStatus';
|
|
import ProviderLoginModal from '../../provider-auth/view/ProviderLoginModal';
|
|
import AgentConnectionsStep from './subcomponents/AgentConnectionsStep';
|
|
import GitConfigurationStep from './subcomponents/GitConfigurationStep';
|
|
import OnboardingStepProgress from './subcomponents/OnboardingStepProgress';
|
|
import {
|
|
gitEmailPattern,
|
|
readErrorMessageFromResponse,
|
|
} from './utils';
|
|
|
|
type OnboardingProps = {
|
|
onComplete?: () => void | Promise<void>;
|
|
};
|
|
|
|
export default function Onboarding({ onComplete }: OnboardingProps) {
|
|
const [currentStep, setCurrentStep] = useState(0);
|
|
const [gitName, setGitName] = useState('');
|
|
const [gitEmail, setGitEmail] = useState('');
|
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
const [errorMessage, setErrorMessage] = useState('');
|
|
const [activeLoginProvider, setActiveLoginProvider] = useState<LLMProvider | null>(null);
|
|
const {
|
|
providerAuthStatus,
|
|
checkProviderAuthStatus,
|
|
refreshProviderAuthStatuses,
|
|
} = useProviderAuthStatus();
|
|
|
|
const previousActiveLoginProviderRef = useRef<LLMProvider | null | undefined>(undefined);
|
|
|
|
const loadGitConfig = useCallback(async () => {
|
|
try {
|
|
const response = await authenticatedFetch('/api/user/git-config');
|
|
if (!response.ok) {
|
|
return;
|
|
}
|
|
|
|
const payload = (await response.json()) as { gitName?: string; gitEmail?: string };
|
|
if (payload.gitName) {
|
|
setGitName(payload.gitName);
|
|
}
|
|
if (payload.gitEmail) {
|
|
setGitEmail(payload.gitEmail);
|
|
}
|
|
} catch (caughtError) {
|
|
console.error('Error loading git config:', caughtError);
|
|
}
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
void loadGitConfig();
|
|
void refreshProviderAuthStatuses();
|
|
}, [loadGitConfig, refreshProviderAuthStatuses]);
|
|
|
|
useEffect(() => {
|
|
const previousProvider = previousActiveLoginProviderRef.current;
|
|
previousActiveLoginProviderRef.current = activeLoginProvider;
|
|
|
|
const didCloseModal = previousProvider !== undefined
|
|
&& previousProvider !== null
|
|
&& activeLoginProvider === null;
|
|
|
|
// Refresh statuses after the login modal is closed.
|
|
if (didCloseModal) {
|
|
void refreshProviderAuthStatuses();
|
|
}
|
|
}, [activeLoginProvider, refreshProviderAuthStatuses]);
|
|
|
|
const handleProviderLoginOpen = (provider: LLMProvider) => {
|
|
setActiveLoginProvider(provider);
|
|
};
|
|
|
|
const handleLoginComplete = (exitCode: number) => {
|
|
if (exitCode === 0 && activeLoginProvider) {
|
|
void checkProviderAuthStatus(activeLoginProvider);
|
|
}
|
|
};
|
|
|
|
const handleNextStep = async () => {
|
|
setErrorMessage('');
|
|
|
|
if (currentStep !== 0) {
|
|
setCurrentStep((previous) => previous + 1);
|
|
return;
|
|
}
|
|
|
|
if (!gitName.trim() || !gitEmail.trim()) {
|
|
setErrorMessage('Both git name and email are required.');
|
|
return;
|
|
}
|
|
|
|
if (!gitEmailPattern.test(gitEmail)) {
|
|
setErrorMessage('Please enter a valid email address.');
|
|
return;
|
|
}
|
|
|
|
setIsSubmitting(true);
|
|
try {
|
|
const response = await authenticatedFetch('/api/user/git-config', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ gitName, gitEmail }),
|
|
});
|
|
|
|
if (!response.ok) {
|
|
const message = await readErrorMessageFromResponse(response, 'Failed to save git configuration');
|
|
throw new Error(message);
|
|
}
|
|
|
|
setCurrentStep((previous) => previous + 1);
|
|
} catch (caughtError) {
|
|
setErrorMessage(caughtError instanceof Error ? caughtError.message : 'Failed to save git configuration');
|
|
} finally {
|
|
setIsSubmitting(false);
|
|
}
|
|
};
|
|
|
|
const handlePreviousStep = () => {
|
|
setErrorMessage('');
|
|
setCurrentStep((previous) => previous - 1);
|
|
};
|
|
|
|
const handleFinish = async () => {
|
|
setIsSubmitting(true);
|
|
setErrorMessage('');
|
|
|
|
try {
|
|
const response = await authenticatedFetch('/api/user/complete-onboarding', { method: 'POST' });
|
|
if (!response.ok) {
|
|
const message = await readErrorMessageFromResponse(response, 'Failed to complete onboarding');
|
|
throw new Error(message);
|
|
}
|
|
|
|
await onComplete?.();
|
|
} catch (caughtError) {
|
|
setErrorMessage(caughtError instanceof Error ? caughtError.message : 'Failed to complete onboarding');
|
|
} finally {
|
|
setIsSubmitting(false);
|
|
}
|
|
};
|
|
|
|
const isCurrentStepValid = currentStep === 0
|
|
? Boolean(gitName.trim() && gitEmail.trim() && gitEmailPattern.test(gitEmail))
|
|
: true;
|
|
|
|
return (
|
|
<>
|
|
<div className="relative h-screen overflow-y-auto bg-background">
|
|
<div aria-hidden className="pointer-events-none fixed inset-0">
|
|
<div className="absolute -top-40 left-1/2 h-[36rem] w-[36rem] -translate-x-1/2 rounded-full bg-primary/10 blur-3xl" />
|
|
<div className="absolute -bottom-32 -left-24 h-[26rem] w-[26rem] rounded-full bg-primary/5 blur-3xl" />
|
|
<div className="absolute inset-0 bg-[radial-gradient(hsl(var(--foreground)/0.04)_1px,transparent_1px)] [background-size:22px_22px] opacity-60" />
|
|
</div>
|
|
|
|
<div className="relative mx-auto flex min-h-full w-full max-w-2xl items-center justify-center p-4">
|
|
<div className="w-full py-6">
|
|
<OnboardingStepProgress currentStep={currentStep} />
|
|
|
|
<div className="rounded-2xl border border-border/70 bg-card/90 p-6 shadow-[0_24px_60px_-20px_hsl(var(--foreground)/0.18)] ring-1 ring-foreground/5 backdrop-blur-xl">
|
|
{currentStep === 0 ? (
|
|
<GitConfigurationStep
|
|
gitName={gitName}
|
|
gitEmail={gitEmail}
|
|
isSubmitting={isSubmitting}
|
|
onGitNameChange={setGitName}
|
|
onGitEmailChange={setGitEmail}
|
|
/>
|
|
) : (
|
|
<AgentConnectionsStep
|
|
providerStatuses={providerAuthStatus}
|
|
onOpenProviderLogin={handleProviderLoginOpen}
|
|
/>
|
|
)}
|
|
|
|
{errorMessage && (
|
|
<div
|
|
role="alert"
|
|
className="mt-5 rounded-xl border border-destructive/30 bg-destructive/10 p-3.5"
|
|
>
|
|
<p className="text-sm text-destructive">{errorMessage}</p>
|
|
</div>
|
|
)}
|
|
|
|
<div className="mt-6 flex items-center justify-between border-t border-border pt-5">
|
|
<button
|
|
onClick={handlePreviousStep}
|
|
disabled={currentStep === 0 || isSubmitting}
|
|
className="flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"
|
|
>
|
|
<ChevronLeft className="h-4 w-4" />
|
|
Previous
|
|
</button>
|
|
|
|
<div className="flex items-center gap-3">
|
|
{currentStep < 1 ? (
|
|
<button
|
|
onClick={handleNextStep}
|
|
disabled={!isCurrentStepValid || isSubmitting}
|
|
className="flex items-center gap-2 rounded-xl bg-primary px-6 py-2.5 font-medium text-primary-foreground shadow-lg shadow-primary/25 transition-all duration-200 hover:brightness-110 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-60 disabled:shadow-none"
|
|
>
|
|
{isSubmitting ? (
|
|
<>
|
|
<Loader2 className="h-4 w-4 animate-spin" />
|
|
Saving...
|
|
</>
|
|
) : (
|
|
<>
|
|
Next
|
|
<ChevronRight className="h-4 w-4" />
|
|
</>
|
|
)}
|
|
</button>
|
|
) : (
|
|
<button
|
|
onClick={handleFinish}
|
|
disabled={isSubmitting}
|
|
className="flex items-center gap-2 rounded-xl bg-emerald-600 px-6 py-2.5 font-medium text-white shadow-lg shadow-emerald-600/25 transition-all duration-200 hover:bg-emerald-700 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-60 disabled:shadow-none"
|
|
>
|
|
{isSubmitting ? (
|
|
<>
|
|
<Loader2 className="h-4 w-4 animate-spin" />
|
|
Completing...
|
|
</>
|
|
) : (
|
|
<>
|
|
<Check className="h-4 w-4" />
|
|
Complete Setup
|
|
</>
|
|
)}
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{activeLoginProvider && (
|
|
<ProviderLoginModal
|
|
isOpen={Boolean(activeLoginProvider)}
|
|
onClose={() => setActiveLoginProvider(null)}
|
|
provider={activeLoginProvider}
|
|
onComplete={handleLoginComplete}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|