Skip to content
Merged
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
6 changes: 5 additions & 1 deletion echo/frontend/src/components/auth/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const useCurrentUser = () =>
useQuery({
queryFn: () => {
try {
return directus.request(readUser("me"));
return directus.request(
readUser("me", {
fields: ["id", "first_name", "email", "disable_create_project"],
}),
);
} catch (_error) {
return null;
}
Expand Down
11 changes: 4 additions & 7 deletions echo/frontend/src/components/chat/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import { directus } from "@/lib/directus";

export const useChatHistory = (chatId: string) => {
return useQuery({
queryFn: () => getChatHistory(chatId ?? ""),
enabled: chatId !== "",
queryFn: () => getChatHistory(chatId),
queryKey: ["chats", "history", chatId],
});
};
Expand Down Expand Up @@ -121,12 +122,8 @@ export const useChat = (chatId: string) => {
queryFn: () =>
directus.request(
readItem("project_chat", chatId, {
fields: [
"*",
{
used_conversations: ["*"],
},
],
// Only fetch fields used in chat UI: id, name, project_id
fields: ["id", "name", "project_id"],
}),
),
queryKey: ["chats", chatId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ interface OpenForParticipationSummaryCardProps {
export const OpenForParticipationSummaryCard = ({
projectId,
}: OpenForParticipationSummaryCardProps) => {
const projectQuery = useProjectById({ projectId });
const projectQuery = useProjectById({
projectId,
query: {
fields: ["id", "is_conversation_allowed"],
},
});
const updateProjectMutation = useUpdateProjectByIdMutation();

const handleOpenForParticipationCheckboxChange = (
Expand Down
61 changes: 44 additions & 17 deletions echo/frontend/src/components/conversation/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const useUpdateConversationTagsMutation = () => {
try {
const validTags = await directus.request<ProjectTag[]>(
readItems("project_tag", {
fields: ["*"],
fields: ["id"],
filter: {
id: {
_in: projectTagIdList,
Expand All @@ -153,9 +153,6 @@ export const useUpdateConversationTagsMutation = () => {
{
project_tag_id: ["id"],
},
{
conversation_id: ["id"],
},
],
filter: {
conversation_id: { _eq: conversationId },
Expand Down Expand Up @@ -644,6 +641,7 @@ export const useConversationChunks = (
_eq: conversationId,
},
},
limit: 1, // Only need to check if chunks exist
sort: "timestamp",
}),
),
Expand Down Expand Up @@ -681,7 +679,18 @@ export const useConversationsByProjectId = (
},
],
},
{ chunks: ["*"] },
{
chunks: [
"id",
"conversation_id",
"transcript",
"source",
"path",
"timestamp",
"created_at",
"error",
],
},
],
filter: {
chunks: {
Expand Down Expand Up @@ -765,21 +774,13 @@ export const CONVERSATION_FIELDS_WITHOUT_PROCESSING_STATUS: QueryFields<
"project_id",
"participant_name",
"participant_email",
"participant_user_agent",
"tags",
"summary",
"source",
"chunks",
"project_chats",
"project_chat_messages",
"replies",
"conversation_segments",
"duration",
"merged_transcript",
"merged_audio_path",
"is_finished",
"is_audio_processing_finished",
"is_all_chunks_transcribed",
"linked_conversations",
"linking_conversations",
];
Expand Down Expand Up @@ -825,11 +826,26 @@ export const useConversationById = ({
{
tags: [
{
project_tag_id: ["id", "text", "created_at"],
project_tag_id: ["id", "text"],
},
],
},
...(loadConversationChunks ? [{ chunks: ["*"] as any }] : []),
...(loadConversationChunks
? [
{
chunks: [
"id",
"conversation_id",
"transcript",
"source",
"path",
"timestamp",
"created_at",
"error",
],
},
]
: []),
],
...query,
}),
Expand Down Expand Up @@ -871,11 +887,22 @@ export const useInfiniteConversationsByProjectId = (
{
tags: [
{
project_tag_id: ["id", "text", "created_at"],
project_tag_id: ["id", "text"],
},
],
},
{ chunks: ["*"] },
{
chunks: [
"id",
"conversation_id",
"transcript",
"source",
"path",
"timestamp",
"created_at",
"error",
],
},
],
filter: {
chunks: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ export const UploadConversationDropzone = (
const uploader = useConversationUploader();
const projectQuery = useProjectById({
projectId: props.projectId,
query: {
fields: ["id"],
},
});

// Handle file rename with the custom hook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { t } from "@lingui/core/macro";
import { Stack, Title } from "@mantine/core";
import { useParams } from "react-router";
import { ConversationStatusIndicators } from "../conversation/ConversationAccordion";
import {
CONVERSATION_FIELDS_WITHOUT_PROCESSING_STATUS,
useConversationById,
} from "../conversation/hooks";
import { useConversationById } from "../conversation/hooks";
import { TabsWithRouter } from "./TabsWithRouter";

export const ProjectConversationLayout = () => {
Expand All @@ -21,8 +18,14 @@ export const ProjectConversationLayout = () => {
},
},
fields: [
...CONVERSATION_FIELDS_WITHOUT_PROCESSING_STATUS,
{ chunks: ["transcript"] },
"id",
"participant_name",
"duration",
"is_finished",
"is_audio_processing_finished",
"created_at",
"updated_at",
{ chunks: ["source", "transcript"] },
],
},
});
Expand Down
12 changes: 11 additions & 1 deletion echo/frontend/src/components/layout/ProjectOverviewLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ import { TabsWithRouter } from "./TabsWithRouter";

export const ProjectOverviewLayout = () => {
const projectId = useParams().projectId;
const projectQuery = useProjectById({ projectId: projectId ?? "" });
const projectQuery = useProjectById({
projectId: projectId ?? "",
query: {
fields: [
"id",
"language",
"is_conversation_allowed",
"default_conversation_title",
],
},
});

useDocumentTitle(t`Project Overview | Dembrane`);

Expand Down
27 changes: 22 additions & 5 deletions echo/frontend/src/components/library/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,20 @@ export const useViewById = (projectId: string, viewId: string) => {
} as any,
},
fields: [
"*",
"id",
"name",
"summary",
"created_at",
{
aspects: ["*", "count(aspect_segment)"],
aspects: [
"id",
"name",
"short_summary",
"description",
"image_url",
"view_id",
"image_generation_model",
],
},
],
}),
Expand All @@ -41,13 +52,19 @@ export const useAspectById = (projectId: string, aspectId: string) => {
directus.request<Aspect>(
readItem("aspect", aspectId, {
fields: [
"*",
"id",
"name",
"image_url",
"long_summary",
{
aspect_segment: [
"*",
"id",
"description",
"verbatim_transcript",
"relevant_index",
{
segment: [
"*",
"id",
{
conversation_id: ["id", "participant_name"],
},
Expand Down
13 changes: 12 additions & 1 deletion echo/frontend/src/components/project/ProjectSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ export const ProjectSidebar = () => {
const { projectId, conversationId } = useParams();
const qrCodeRef = useRef<HTMLDivElement>(null);

const projectQuery = useProjectById({ projectId: projectId ?? "" });
const projectQuery = useProjectById({
projectId: projectId ?? "",
query: {
fields: [
"id",
"name",
"language",
"is_conversation_allowed",
"default_conversation_title",
],
},
});
const { pathname } = useLocation();

// const { isCollapsed, toggleSidebar } = useSidebarCollapsed();
Expand Down
18 changes: 17 additions & 1 deletion echo/frontend/src/components/project/ProjectTagsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,23 @@ export const ProjectTagPill = ({ tag }: { tag: ProjectTag }) => {
};

export const ProjectTagsInput = (props: { project: Project }) => {
const projectQuery = useProjectById({ projectId: props.project.id });
const projectQuery = useProjectById({
projectId: props.project.id,
query: {
deep: {
// @ts-expect-error tags won't be typed
tags: {
_sort: "sort",
},
},
fields: [
"id",
{
tags: ["id", "created_at", "text", "sort"],
},
],
},
});
const createTagMutation = useCreateProjectTagMutation();
const updateTagMutation = useUpdateProjectTagByIdMutation();

Expand Down
4 changes: 3 additions & 1 deletion echo/frontend/src/components/project/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export const useCreateChatMutation = () => {
};
}) => {
const project = await directus.request(
readItem("project", payload.project_id.id),
readItem("project", payload.project_id.id, {
fields: ["is_enhanced_audio_processing_enabled"],
}),
);

const chat = await directus.request(
Expand Down
Loading
Loading