mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 06:53:14 +00:00
* feat(dashboard): refactor UI into Cursor-style sidebar layout
Replace the top-bar AppHeader with a left sidebar that holds the four
primary sections (My Settings, Cloud Agents, Open SWE Review,
Integrations) and the user account menu at the bottom. Admin remains a
hidden route reachable from the sidebar only when is_admin.
UI:
- AppShell + AppSidebar with bottom-anchored avatar/sign-out menu.
- My Settings: profile (first/last name) + PR destination preference.
- Cloud Agents: model/effort, default repo, base branch, branch prefix,
PR toggles (auto-fix CI, create PRs, allow artifacts), Slack
notifications.
- Open SWE Review: trigger mode, draft reviews, PR summaries, autofix
mode + severity threshold, plus the existing per-repo review-style
prompts (was /review-styles).
- Integrations: GitHub install status + Slack/Linear status rows.
- New Switch and Menu primitives.
Backend:
- Extend ProfileUpdate with first_name, last_name, base_branch,
branch_prefix, auto_fix_ci, create_prs, allow_artifacts,
slack_notifications, preferred_pr_destination.
- Add team_settings module + /team-settings GET (any session) / PUT
(admin only) for the reviewer configuration.
* fix(dashboard): replace base-ui Menu with plain dropdown, stabilise Selects
- base-ui's Menu hit an "Invalid hook call / Cannot read properties of
null (reading 'useRef')" crash inside fastComponent under Vite's dep
optimisation. The sidebar account menu is the only consumer, so swap
it for a useState-driven dropdown with click-outside + Esc handling
and drop the unused Menu wrapper.
- Initialise the Open SWE Review settings form with the same defaults
the server returns instead of `null`, so the Selects don't switch
from uncontrolled (`undefined`) to controlled on first data load.
* fix(dashboard): address review feedback on admin overwrite + form reset
- admin PUT /admin/profiles/{login} only sent model/effort/repo from the
admin form. ProfileUpdate's Pydantic defaults then wrote auto_fix_ci /
create_prs / slack_notifications etc back onto the target user's
profile, clobbering whatever they had configured. Switch to
model_dump(exclude_unset=True) and overlay the incoming fields on the
user's existing stored profile so only sent fields change.
- my-settings.tsx and cloud-agents.tsx initialised local state from
profile.data on every change. Because useSaveProfile updates the
cached profile on success, toggling any control would overwrite the
user's typed-but-unsaved input in another field. Guard the
initialisation effect with a ref so it runs once on first load.
---------
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
142 lines
4.5 KiB
TypeScript
142 lines
4.5 KiB
TypeScript
import { Navigate, createFileRoute } from "@tanstack/react-router";
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
|
import { AppShell, SettingsRow, SettingsSection } from "@/components/AppShell";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import {
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from "@/components/ui/select";
|
|
import { Skeleton } from "@/components/ui/skeleton";
|
|
import { buildProfileUpdate, useOptions, useProfile, useSaveProfile } from "@/lib/profile";
|
|
import { useSession } from "@/lib/session";
|
|
|
|
export const Route = createFileRoute("/my-settings")({ component: MySettingsPage });
|
|
|
|
function MySettingsPage() {
|
|
const session = useSession();
|
|
const profile = useProfile();
|
|
const options = useOptions();
|
|
const save = useSaveProfile();
|
|
|
|
const [firstName, setFirstName] = useState("");
|
|
const [lastName, setLastName] = useState("");
|
|
const [prDestination, setPrDestination] = useState<string>("team_default");
|
|
const [error, setError] = useState<string | null>(null);
|
|
const initialized = useRef(false);
|
|
|
|
useEffect(() => {
|
|
if (!profile.data || initialized.current) return;
|
|
initialized.current = true;
|
|
setFirstName(profile.data.first_name ?? "");
|
|
setLastName(profile.data.last_name ?? "");
|
|
setPrDestination(profile.data.preferred_pr_destination ?? "team_default");
|
|
}, [profile.data]);
|
|
|
|
if (session.isLoading) {
|
|
return (
|
|
<main className="p-6">
|
|
<Skeleton className="h-40 w-full" />
|
|
</main>
|
|
);
|
|
}
|
|
if (!session.data) return <Navigate to="/login" />;
|
|
|
|
const firstModel = options.data?.models[0];
|
|
const handleSaveProfile = () => {
|
|
setError(null);
|
|
const body = buildProfileUpdate(
|
|
profile.data,
|
|
{ first_name: firstName || null, last_name: lastName || null },
|
|
firstModel?.id ?? "",
|
|
firstModel?.default_effort ?? "",
|
|
);
|
|
save
|
|
.mutateAsync(body)
|
|
.catch((e: Error) => setError(e.message));
|
|
};
|
|
|
|
const handleSavePrDestination = (value: string | null) => {
|
|
if (!value) return;
|
|
setPrDestination(value);
|
|
const body = buildProfileUpdate(
|
|
profile.data,
|
|
{ preferred_pr_destination: value === "team_default" ? null : value },
|
|
firstModel?.id ?? "",
|
|
firstModel?.default_effort ?? "",
|
|
);
|
|
save.mutateAsync(body).catch((e: Error) => setError(e.message));
|
|
};
|
|
|
|
return (
|
|
<AppShell user={session.data} title="My Settings">
|
|
<SettingsSection title="Profile">
|
|
<div className="divide-y divide-border">
|
|
<SettingsRow
|
|
label="Email"
|
|
control={
|
|
<span className="text-xs text-muted-foreground">
|
|
{session.data.email ?? "—"}
|
|
</span>
|
|
}
|
|
/>
|
|
<SettingsRow
|
|
label="First Name"
|
|
htmlFor="first-name"
|
|
control={
|
|
<Input
|
|
id="first-name"
|
|
className="w-56"
|
|
value={firstName}
|
|
onChange={(e) => setFirstName(e.target.value)}
|
|
/>
|
|
}
|
|
/>
|
|
<SettingsRow
|
|
label="Last Name"
|
|
htmlFor="last-name"
|
|
control={
|
|
<Input
|
|
id="last-name"
|
|
className="w-56"
|
|
value={lastName}
|
|
onChange={(e) => setLastName(e.target.value)}
|
|
/>
|
|
}
|
|
/>
|
|
<div className="flex justify-end px-4 py-3">
|
|
<Button size="sm" onClick={handleSaveProfile} disabled={save.isPending}>
|
|
{save.isPending ? "Saving…" : "Save"}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</SettingsSection>
|
|
|
|
<SettingsSection title="PR Preferences">
|
|
<SettingsRow
|
|
label="Preferred PR destination"
|
|
description="Choose where PR links open across web, the desktop app and IDE."
|
|
control={
|
|
<Select value={prDestination} onValueChange={handleSavePrDestination}>
|
|
<SelectTrigger className="w-40">
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="team_default">Team default</SelectItem>
|
|
<SelectItem value="web">Web</SelectItem>
|
|
<SelectItem value="desktop">Desktop App</SelectItem>
|
|
<SelectItem value="ide">IDE</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
}
|
|
/>
|
|
</SettingsSection>
|
|
|
|
{error && <p className="text-xs text-destructive">{error}</p>}
|
|
</AppShell>
|
|
);
|
|
}
|