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
170 changes: 145 additions & 25 deletions refact-agent/gui/generated/documents.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions refact-agent/gui/generated/graphql/gql.ts

Large diffs are not rendered by default.

133 changes: 118 additions & 15 deletions refact-agent/gui/generated/graphql/graphql.ts

Large diffs are not rendered by default.

74 changes: 61 additions & 13 deletions refact-agent/gui/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ type FAuditRecordOutput {
audit_ts: Float!
}

type FBotInstallOutput {
marketable_name: String!
marketable_version: String!
}

type FCloudTool {
ctool_confirmed_exists_ts: Float
ctool_description: String!
Expand Down Expand Up @@ -151,6 +156,11 @@ type FExternalDataSourceSubs {
news_payload_id: String!
}

input FKanbanTaskInput {
state: String!
title: String!
}

input FKnowledgeItemInput {
iknow_is_core: Boolean! = false
iknow_memory: String!
Expand Down Expand Up @@ -192,6 +202,14 @@ type FKnowledgeItemSubs {
news_pubsub: String!
}

input FMarketplaceExpertInput {
fexp_allow_tools: String!
fexp_block_tools: String!
fexp_name: String!
fexp_python_kernel: String!
fexp_system_prompt: String!
}

type FMassInvitationOutput {
fuser_id: String!
result: String!
Expand Down Expand Up @@ -220,32 +238,55 @@ type FPermissionSubs {

input FPersonaInput {
located_fgroup_id: String!
persona_expert1_fexp_name: String = null
persona_expert2_fexp_name: String = null
persona_module: String!
persona_discounts: String = null
persona_marketable_name: String!
persona_marketable_version: String!
persona_name: String!
persona_setup: String!
}

type FPersonaKanbanSubs {
news_action: String!
news_bucket: String!
news_payload_id: String!
news_payload_task: FPersonaKanbanTaskOutput
}

type FPersonaKanbanTaskOutput {
ktask_blocks_ktask_id: String
ktask_budget: Int!
ktask_details: JSON!
ktask_done_ts: Float!
ktask_failed_ts: Float!
ktask_id: String!
ktask_inbox_provenance: JSON!
ktask_inbox_ts: Float!
ktask_inprogress_ft_id: String!
ktask_inprogress_ts: Float!
ktask_title: String!
ktask_todo_ts: Float!
persona_id: String!
}

type FPersonaOutput {
located_fgroup_id: String!
owner_fuser_id: String!
persona_archived_ts: Float!
persona_created_ts: Float!
persona_expert1_fexp_name: String
persona_expert2_fexp_name: String
persona_discounts: JSON
persona_enabled: Boolean!
persona_id: String!
persona_module: String!
persona_marketable_name: String!
persona_marketable_version: String!
persona_name: String!
persona_setup: JSON!
}

input FPersonaPatch {
located_fgroup_id: String = null
persona_archived_ts: Float = null
persona_expert1_fexp_name: String = null
persona_expert2_fexp_name: String = null
persona_module: String = null
persona_enabled: Boolean = null
persona_marketable_version: String = null
persona_name: String = null
persona_setup: String = null
}
Expand Down Expand Up @@ -295,11 +336,12 @@ input FThreadInput {
ft_app_specific: String! = "null"
ft_error: String! = "null"
ft_fexp_id: String!
ft_persona_id: String = null
ft_subchat_dest_ft_id: String = null
ft_title: String!
ft_toolset: String! = "null"
located_fgroup_id: String!
owner_shared: Boolean!
parent_ft_id: String = null
}

input FThreadMessageInput {
Expand Down Expand Up @@ -369,13 +411,14 @@ type FThreadOutput {
ft_need_assistant: Int!
ft_need_tool_calls: Int!
ft_need_user: Int!
ft_persona_id: String
ft_subchat_dest_ft_id: String
ft_title: String!
ft_toolset: JSON
ft_updated_ts: Float!
located_fgroup_id: String!
owner_fuser_id: String!
owner_shared: Boolean!
parent_ft_id: String
}

input FThreadPatch {
Expand All @@ -385,11 +428,11 @@ input FThreadPatch {
ft_confirmation_request: String = null
ft_confirmation_response: String = null
ft_error: String = null
ft_subchat_dest_ft_id: String = null
ft_title: String = null
ft_toolset: String = null
located_fgroup_id: String = null
owner_shared: Boolean = null
parent_ft_id: String = null
}

type FThreadSubs {
Expand Down Expand Up @@ -462,6 +505,9 @@ scalar JSON
type Mutation {
api_key_delete(apikey_id: String!): Boolean!
api_key_generate: FApiKeyOutput!
bot_activate(activation_type: String!, first_calls: String!, first_question: String!, localtools: String!, persona_id: String!, title: String!, who_is_asking: String!): FThreadOutput!
bot_arrange_kanban_situation(persona_id: String!, tasks: [FKanbanTaskInput!]!, ws_id: String!): Boolean!
bot_install_from_marketplace(inside_fgroup_id: String!, new_setup: String!, persona_id: String!, persona_marketable_name: String!, persona_marketable_version: String!, persona_name: String!): Boolean!
cloudtool_post_result(input: CloudtoolResultInput!): Boolean!
create_captured_thread(input: FThreadInput!, on_behalf_of_fuser_id: String = null): FThreadOutput!
email_confirm(token: String!): EmailConfirmResult!
Expand All @@ -482,7 +528,8 @@ type Mutation {
knowledge_item_delete(id: String!): Boolean!
knowledge_item_mass_group_patch(dst_group_id: String!, src_group_id: String!): Int!
knowledge_item_patch(id: String!, patch: FKnowledgeItemPatch!): FKnowledgeItemOutput!
make_sure_have_expert(fexp_name_without_version: String!, fgroup_id: String, owner_fuser_id: String, system_prompt: String!): String!
make_sure_have_expert(fexp_name: String!, fgroup_id: String, owner_fuser_id: String, python_kernel: String!, system_prompt: String!): String!
marketplace_upsert_dev_bot(marketable_description: String!, marketable_expert_scheduled: FMarketplaceExpertInput!, marketable_expert_setup: FMarketplaceExpertInput!, marketable_expert_subchat: FMarketplaceExpertInput!, marketable_expert_todo: FMarketplaceExpertInput!, marketable_github_repo: String!, marketable_name: String!, marketable_run_this: String!, marketable_setup_default: String!, marketable_version: String!, ws_id: String!): FBotInstallOutput!
password_change(new_password: String!, old_password: String!): Boolean!
permission_delete(fgroup_id: String!, fuser_id: String!): Boolean!
permission_patch(fgroup_id: String!, fuser_id: String!, patch: FPermissionPatch!): FPermissionOutput!
Expand Down Expand Up @@ -578,6 +625,7 @@ type Subscription {
external_data_sources_in_group(filter: [String!]! = [], limit: Int! = 0, located_fgroup_id: String!, sort_by: [String!]! = []): FExternalDataSourceSubs!
knowledge_items_in_group(filter: [String!]! = [], limit: Int! = 0, located_fgroup_id: String!, sort_by: [String!]! = []): FKnowledgeItemSubs!
permissions_in_group_subs(fgroup_id: String!, limit: Int!, quicksearch: String!): FPermissionSubs!
persona_kanban_subs(limit_done: Int! = 30, limit_garbage: Int! = 30, limit_inbox: Int! = 30, persona_id: String!): FPersonaKanbanSubs!
personas_in_group(filter: [String!]! = [], limit: Int! = 0, located_fgroup_id: String!, sort_by: [String!]! = []): FPersonaSubs!
threads_in_group(filter: [String!]! = [], limit: Int! = 0, located_fgroup_id: String!, sort_by: [String!]! = []): FThreadSubs!
tree_subscription(ws_id: String!): TreeUpdateSubs!
Expand Down
104 changes: 46 additions & 58 deletions refact-agent/gui/src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import React, { useCallback, useState } from "react";
import React, { useCallback, useMemo, useState } from "react";
import { ChatForm, ChatFormProps } from "../ChatForm";
import { ChatContent } from "../ChatContent";
import { Flex } from "@radix-ui/themes";
import { useAppSelector, useSendMessages } from "../../hooks";
import { type Config } from "../../features/Config/configSlice";
import { useAppDispatch, useAppSelector, useSendMessages } from "../../hooks";
import { selectConfig, type Config } from "../../features/Config/configSlice";

import { DropzoneProvider } from "../Dropzone";
import { useCheckpoints } from "../../hooks/useCheckpoints";
import { Checkpoints } from "../../features/Checkpoints";
// TODO: remove this?
// import { SuggestNewChat } from "../ChatForm/SuggestNewChat";

import { useMessageSubscription } from "./useMessageSubscription";
import { selectThreadId } from "../../features/ThreadMessages";
import {
selectIsStreaming,
selectIsWaiting,
selectThreadId,
selectTotalMessagesInThread,
} from "../../features/ThreadMessages";
import { ThreadHistoryButton } from "../Buttons";
import { push } from "../../features/Pages/pagesSlice";

export type ChatProps = {
host: Config["host"];
Expand All @@ -23,34 +29,36 @@ export type ChatProps = {
};

export const Chat: React.FC<ChatProps> = ({ style, maybeSendToSidebar }) => {
// const dispatch = useAppDispatch();
const dispatch = useAppDispatch();
// const unCalledTools = useAppSelector(selectBranchHasUncalledTools);

const [isViewingRawJSON, setIsViewingRawJSON] = useState(false);
// const isStreaming = useAppSelector(selectIsStreaming);
const isStreaming = useAppSelector(selectIsStreaming);
const isWaiting = useAppSelector(selectIsWaiting);
useMessageSubscription();
const { sendMessage } = useSendMessages();
// const totalMessages = useAppSelector(selectTotalMessagesInThread, {
// devModeChecks: { stabilityCheck: "never" },
// });
const totalMessages = useAppSelector(selectTotalMessagesInThread, {
devModeChecks: { stabilityCheck: "never" },
});

const config = useAppSelector(selectConfig);

const canShowDebugButton = useMemo(() => {
if (config.host === "web") return true;
if (config.features?.connections) return true;
return !isWaiting && !isStreaming && totalMessages > 0;
}, [
config.features?.connections,
config.host,
isStreaming,
isWaiting,
totalMessages,
]);

const chatId = useAppSelector(selectThreadId);
// TODO: figure out features removed here
// const { submit, abort, retryFromIndex } = useSendChatRequest();

// const chatToolUse = useAppSelector(getSelectedToolUse);
// const threadNewChatSuggested = useAppSelector(selectThreadNewChatSuggested);
// const messages = useAppSelector(selectMessages);
// const capsForToolUse = useCapsForToolUse();

const { shouldCheckpointsPopupBeShown } = useCheckpoints();

// const [isDebugChatHistoryVisible, setIsDebugChatHistoryVisible] =
// useState(false);

// const preventSend = useAppSelector(selectPreventSend);
// const onEnableSend = () => dispatch(enableSend({ id: chatId }));

const handleSummit = useCallback(
(value: string) => {
// submit({ question: value });
Expand All @@ -63,9 +71,9 @@ export const Chat: React.FC<ChatProps> = ({ style, maybeSendToSidebar }) => {
);

// TODO: this
// const handleThreadHistoryPage = useCallback(() => {
// dispatch(push({ name: "thread history page", chatId }));
// }, [chatId, dispatch]);
const handleThreadHistoryPage = useCallback(() => {
dispatch(push({ name: "thread history page", chatId: chatId ?? "" }));
}, [chatId, dispatch]);

return (
<DropzoneProvider asChild>
Expand All @@ -82,44 +90,24 @@ export const Chat: React.FC<ChatProps> = ({ style, maybeSendToSidebar }) => {

{shouldCheckpointsPopupBeShown && <Checkpoints />}

{/* <SuggestNewChat
shouldBeVisible={
threadNewChatSuggested.wasSuggested &&
!threadNewChatSuggested.wasRejectedByUser
}
/> */}

<ChatForm
key={chatId} // TODO: think of how can we not trigger re-render on chatId change (checkboxes)
onSubmit={handleSummit}
onClose={maybeSendToSidebar}
/>

{/* <Flex justify="between" pl="1" pr="1" pt="1"> */}
{/* Two flexboxes are left for the future UI element on the right side */}
{/* {totalMessages > 0 && (
<Flex align="center" justify="between" width="100%">
<Flex align="center" gap="1">
<Text size="1">model: {capsForToolUse.currentModel} </Text> •{" "}
<Text
size="1"
onClick={() => setIsDebugChatHistoryVisible((prev) => !prev)}
>
mode: {chatToolUse}{" "}
</Text>
</Flex>
{totalMessages !== 0 &&
!isStreaming &&
isDebugChatHistoryVisible && (
<ThreadHistoryButton
title="View history of current thread"
size="1"
onClick={handleThreadHistoryPage}
/>
)}
<Flex justify="between" pl="1" pr="1" pt="1">
{/* Two flexboxes are left for the future UI element on the right side */}
{canShowDebugButton && (
<Flex align="center" justify="end" width="100%">
<ThreadHistoryButton
title="View history of current thread"
size="1"
onClick={handleThreadHistoryPage}
/>
</Flex>
)} */}
{/* </Flex> */}
)}
</Flex>
</Flex>
</DropzoneProvider>
);
Expand Down
11 changes: 4 additions & 7 deletions refact-agent/gui/src/components/ChatRawJSON/ChatRawJSON.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Box, Button, Flex, Heading } from "@radix-ui/themes";
import { ScrollArea } from "../ScrollArea";
import { MarkdownCodeBlock } from "../Markdown/CodeBlock";
import {
FThreadMessageOutput,
FThreadOutput,
} from "../../../generated/documents";
import { MessagesSubscriptionSubscription } from "../../../generated/documents";

type ChatRawJSONProps = {
thread: FThreadOutput;
messages: FThreadMessageOutput;
thread: MessagesSubscriptionSubscription["comprehensive_thread_subs"]["news_payload_thread"];
messages: MessagesSubscriptionSubscription["comprehensive_thread_subs"]["news_payload_thread_message"][];
copyHandler: () => void;
};

Expand Down Expand Up @@ -39,7 +36,7 @@ export const ChatRawJSON = ({
<Heading as="h3" align="center" mb="2">
Thread History
</Heading>
{thread.ft_title && (
{thread?.ft_title && (
<Heading as="h6" size="2" align="center" mb="4">
{thread.ft_title}
</Heading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const MockedStore: React.FC<{
ft_need_assistant: -1,
ft_fexp_id: "id:ask:1.0",
located_fgroup_id: "0000000",
ft_title: "test",
},
ft_id: "foo",
streamingBranches: [],
Expand Down
Loading