Files
yaak-mountain-loop/src-web/hooks/useSyncWorkspaceRequestTitle.ts
Gregory Schier 5919fae739 Run oxfmt across repo, add format script and ignore config
Format all non-generated files with oxfmt via `vp fmt`. Add
.oxfmtignore to skip bindings/ and wasm-pack output. Add npm
format script and update DEVELOPMENT.md docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 09:52:11 -07: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]);
}