fix(web): show project settings for new threads (#9743)
This commit is contained in:
1 parent
cfc9bf3415
commit
cbe93e8dfb
2 files changed
+34
-3
No files matched your search
@@ -1970,6 +1970,18 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const handleNewThreadInActiveProject = useCallback(() => {
|
||||
startNewThreadForProject(activeProjectRef, handleNewThread);
|
||||
}, [activeProjectRef, handleNewThread]);
|
||||
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
||||
const activeDraftLogicalProjectKey =
|
||||
!isServerThread && activeProject
|
||||
? deriveLogicalProjectKeyFromSettings(activeProject, projectGroupingSettings)
|
||||
: undefined;
|
||||
const handleOpenDraftProjectSettings = useCallback(() => {
|
||||
if (!activeDraftLogicalProjectKey) return;
|
||||
void navigate({
|
||||
to: "/projects/$projectKey",
|
||||
params: { projectKey: activeDraftLogicalProjectKey },
|
||||
});
|
||||
}, [activeDraftLogicalProjectKey, navigate]);
|
||||
const activeEnvironmentShell = useEnvironmentQuery(
|
||||
activeThread ? environmentShell.stateAtom(activeThread.environmentId) : null,
|
||||
);
|
||||
@@ -1977,7 +1989,6 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const activeProjectKey = activeProject
|
||||
? `${activeProject.environmentId}:${activeProject.workspaceRoot}`
|
||||
: null;
|
||||
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
|
||||
const clientSettingsHydrated = useClientSettingsHydrated();
|
||||
const [pendingFileSurfaceIdsByProject, setPendingFileSurfaceIdsByProject] = useState<
|
||||
ReadonlyMap<string, ReadonlySet<string>>
|
||||
@@ -7729,6 +7740,9 @@ export default function ChatView(props: ChatViewProps) {
|
||||
rightPanelOpen={rightPanelOpen}
|
||||
gitCwd={gitCwd}
|
||||
onNewThreadInProject={handleNewThreadInActiveProject}
|
||||
{...(activeDraftLogicalProjectKey
|
||||
? { onOpenProjectSettings: handleOpenDraftProjectSettings }
|
||||
: {})}
|
||||
onRunProjectScript={runProjectScript}
|
||||
onAddProjectScript={saveProjectScript}
|
||||
onUpdateProjectScript={updateProjectScript}
|
||||
|
||||
@@ -35,6 +35,7 @@ import { useRemoteOpenState, type RemoteOpenMode } from "../../remoteOpen";
|
||||
import { usePrimaryEnvironmentId } from "../../state/environments";
|
||||
import { useT3ProjectFileScripts } from "~/hooks/useT3ProjectFileScripts";
|
||||
import { useThreadActionMenu } from "~/hooks/useThreadActionMenu";
|
||||
import { readLocalApi } from "~/localApi";
|
||||
import { threadEnvironment } from "../../state/threads";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { observeResponsiveBreakpointFade, usePanelAnimationSettings } from "../../panelAnimations";
|
||||
@@ -66,6 +67,7 @@ interface ChatHeaderProps {
|
||||
gitCwd: string | null;
|
||||
readonly onOpenPullRequest?: ((number: number) => void) | undefined;
|
||||
onNewThreadInProject: () => void;
|
||||
onOpenProjectSettings?: (() => void) | undefined;
|
||||
onRunProjectScript: (script: ProjectScript) => void;
|
||||
onAddProjectScript: (input: NewProjectScriptInput) => Promise<ProjectScriptActionResult>;
|
||||
onUpdateProjectScript: (
|
||||
@@ -137,6 +139,7 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
gitCwd,
|
||||
onOpenPullRequest,
|
||||
onNewThreadInProject,
|
||||
onOpenProjectSettings,
|
||||
onRunProjectScript,
|
||||
onAddProjectScript,
|
||||
onUpdateProjectScript,
|
||||
@@ -275,15 +278,29 @@ export const ChatHeader = memo(function ChatHeader({
|
||||
);
|
||||
const handleHeaderContextMenu = useCallback(
|
||||
(event: ReactMouseEvent) => {
|
||||
if (!isServerThread || renamingTitle !== null) return;
|
||||
if (renamingTitle !== null) return;
|
||||
// The right-side controls (git, scripts, open-in) keep their own
|
||||
// behavior; only the breadcrumb area opens the thread menu.
|
||||
if ((event.target as HTMLElement).closest("[data-chat-header-actions]")) return;
|
||||
if (!isServerThread && onOpenProjectSettings === undefined) return;
|
||||
cancelPendingTitleMenu();
|
||||
event.preventDefault();
|
||||
if (!isServerThread) {
|
||||
const api = readLocalApi();
|
||||
if (!api) return;
|
||||
void api.contextMenu
|
||||
.show([{ id: "project-settings", label: "Project settings", icon: "settings" }], {
|
||||
x: event.clientX,
|
||||
y: event.clientY,
|
||||
})
|
||||
.then((action) => {
|
||||
if (action === "project-settings") onOpenProjectSettings?.();
|
||||
});
|
||||
return;
|
||||
}
|
||||
openMenu({ x: event.clientX, y: event.clientY });
|
||||
},
|
||||
[cancelPendingTitleMenu, isServerThread, openMenu, renamingTitle],
|
||||
[cancelPendingTitleMenu, isServerThread, onOpenProjectSettings, openMenu, renamingTitle],
|
||||
);
|
||||
const handleRenameKeyDown = useCallback(
|
||||
(event: ReactKeyboardEvent<HTMLInputElement>) => {
|
||||
|
||||
Reference in new issue
Block a user