Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/desktop/src/ai/prompts/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function PromptDetailsColumn({
return (
<div className="flex h-full items-center justify-center">
<p className="text-sm text-neutral-500">
Select a task type to view or customize its prompt
Select a meeting-note task to view or customize its instructions
</p>
</div>
);
Expand Down Expand Up @@ -163,7 +163,7 @@ function PromptDetails({ selectedTask }: { selectedTask: TaskType }) {
<PromptEditor
value={localValue}
onChange={setLocalValue}
placeholder="Enter your custom prompt template using Jinja2 syntax..."
placeholder="Enter custom meeting-note instructions using Jinja2 syntax..."
variables={variables as string[]}
filters={[...AVAILABLE_FILTERS]}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/ai/prompts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const TabItemPrompt: TabItem<Extract<Tab, { type: "prompts" }>> = ({
return (
<TabItemBase
icon={<SparklesIcon className="h-4 w-4" />}
title={"Prompts"}
title={"Meeting Notes"}
selected={tab.active}
pinned={tab.pinned}
tabIndex={tabIndex}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/ai/prompts/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function PromptsListColumn({
return (
<div className="flex h-full w-full flex-col">
<div className="flex h-12 items-center justify-between border-b border-neutral-200 py-2 pr-1 pl-3">
<h3 className="text-sm font-medium">Custom Prompts</h3>
<h3 className="text-sm font-medium">Meeting Notes</h3>
</div>

<div className="flex-1 overflow-y-auto">
Expand Down
86 changes: 49 additions & 37 deletions apps/desktop/src/chat/transport/use-transport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useQuery } from "@tanstack/react-query";
import type { LanguageModel, ToolSet } from "ai";
import { useEffect, useMemo, useState } from "react";
import { useMemo } from "react";

import { commands as templateCommands } from "@hypr/plugin-template";

Expand All @@ -10,6 +11,7 @@ import { useLanguageModel } from "~/ai/hooks";
import type { ContextRef } from "~/chat/context/entities";
import { hydrateSessionContextFromFs } from "~/chat/context/session-context-hydrator";
import { useToolRegistry } from "~/contexts/tool";
import { useConfigValues } from "~/shared/config";
import * as main from "~/store/tinybase/store/main";

function renderHumanContext(
Expand Down Expand Up @@ -82,49 +84,59 @@ export function useTransport(
const registry = useToolRegistry();
const configuredModel = useLanguageModel("chat");
const model = modelOverride ?? configuredModel;
const language = main.UI.useValue("ai_language", main.STORE_ID) ?? "en";
const [systemPrompt, setSystemPrompt] = useState<string | undefined>();

useEffect(() => {
if (systemPromptOverride) {
setSystemPrompt(systemPromptOverride);
return;
}

let stale = false;

templateCommands
.render({
const {
ai_language: language,
chat_style_tone: styleTone,
chat_warmth: warmth,
chat_enthusiasm: enthusiasm,
chat_headers_lists: headersLists,
chat_emoji: emoji,
chat_custom_instructions: customInstructions,
} = useConfigValues([
"ai_language",
"chat_style_tone",
"chat_warmth",
"chat_enthusiasm",
"chat_headers_lists",
"chat_emoji",
"chat_custom_instructions",
] as const);
const normalizedCustomInstructions = customInstructions.trim();

const systemPromptQuery = useQuery({
queryKey: [
"chat-system-prompt",
language,
styleTone,
warmth,
enthusiasm,
headersLists,
emoji,
normalizedCustomInstructions,
],
enabled: systemPromptOverride === undefined,
staleTime: Infinity,
queryFn: async () => {
const result = await templateCommands.render({
chatSystem: {
language,
styleTone,
warmth,
enthusiasm,
headersLists,
emoji,
customInstructions: normalizedCustomInstructions,
},
})
.then((result) => {
if (stale) {
return;
}

if (result.status === "ok") {
setSystemPrompt(result.data);
} else {
setSystemPrompt("");
}
})
.catch((error) => {
console.error(error);
if (!stale) {
setSystemPrompt("");
}
});

return () => {
stale = true;
};
}, [language, systemPromptOverride]);
return result.status === "ok" ? result.data : "";
},
});

const effectiveSystemPrompt = systemPromptOverride ?? systemPrompt;
const effectiveSystemPrompt = systemPromptOverride ?? systemPromptQuery.data;
const isSystemPromptReady =
typeof systemPromptOverride === "string" || systemPrompt !== undefined;
typeof systemPromptOverride === "string" ||
systemPromptQuery.data !== undefined;

const tools = useMemo(() => {
const localTools = registry.getTools("chat-general");
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { SettingsLab } from "./lab";
import { AgentIntegrations } from "./lab/agent-integrations";
import { DeveloperSettings } from "./lab/developer";
import { SettingsPersonalization } from "./personalization";
import { SettingsTodo } from "./todo";

import { LLM } from "~/settings/ai/llm";
Expand Down Expand Up @@ -85,6 +86,8 @@ function SettingsView({ tab }: { tab: Extract<Tab, { type: "settings" }> }) {
return <STT />;
case "intelligence":
return <LLM />;
case "personalization":
return <SettingsPersonalization />;
case "memory":
return <SettingsMemory />;
case "todo":
Expand Down
Loading
Loading