Files
upstream-yaak/apps/yaak-client/hooks/useSyncWorkspaceRequestTitle.ts
upstream-mirror 906fb231cc
Some checks failed
Lint and Test / Lint/Test (push) Has been cancelled
Generate Sponsors README / deploy (push) Has been skipped
snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 17:39:41 +05:00

35 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { setWindowTitle } from "@yaakapp-internal/mac-window";
import { settingsAtom } from "@yaakapp-internal/models";
import { useAtomValue } from "jotai";
import { useEffect } from "react";
import { appInfo } from "../lib/appInfo";
import { jotaiStore } from "../lib/jotai";
import { resolvedModelName } from "../lib/resolvedModelName";
import { useActiveEnvironment } from "./useActiveEnvironment";
import { activeRequestAtom } from "./useActiveRequest";
import { activeWorkspaceAtom } from "./useActiveWorkspace";
export function useSyncWorkspaceRequestTitle() {
const activeWorkspace = useAtomValue(activeWorkspaceAtom);
const activeEnvironment = useActiveEnvironment();
const activeRequest = useAtomValue(activeRequestAtom);
useEffect(() => {
const settings = jotaiStore.get(settingsAtom);
let newTitle = activeWorkspace ? activeWorkspace.name : "Yaak";
if (activeEnvironment) {
newTitle += ` (${activeEnvironment.name})`;
}
if (!settings.useNativeTitlebar && activeRequest) {
newTitle += ` › ${resolvedModelName(activeRequest)}`;
}
if (appInfo.isDev) {
newTitle = `[DEV] ${newTitle}`;
}
setWindowTitle(newTitle);
}, [activeEnvironment, activeRequest, activeWorkspace]);
}