Skip to content

Commit

Permalink
Merge pull request #16 from jhnnsrs/with_next
Browse files Browse the repository at this point in the history
more and more
  • Loading branch information
jhnnsrs authored Oct 26, 2023
2 parents 1650fc2 + 0eead9d commit 81c8ad4
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 24 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub fn start_with_config<F: FnMut(String) + Send + 'static>(
None => TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0))),
}?;



let port = listener.local_addr()?.port();

thread::spawn(move || {
Expand Down
56 changes: 53 additions & 3 deletions src/components/MyAgents.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from "react";
import React, { useEffect } from "react";
import { useNavigate } from "react-router";
import { notEmpty } from "../floating/utils";
import { SectionTitle } from "../layout/SectionTitle";
import { useBounceAgentMate } from "../mates/agent/useBounceAgentMate";
import { useDeleteAgentMate } from "../mates/agent/useDeleteAgentMate";
import { useKickAgentMate } from "../mates/agent/useKickAgentMate";
import { withRekuest } from "../rekuest";
import { ListAgentFragment, useMyAgentsQuery } from "../rekuest/api/graphql";
import { AgentsEventDocument, AgentsEventSubscription, ListAgentFragment, MyAgentsQuery, useMyAgentsQuery } from "../rekuest/api/graphql";
import { AgentCard } from "../rekuest/components/cards/AgentCard";
import { ResponsiveContainerGrid } from "./layout/ResponsiveContainerGrid";

Expand All @@ -17,10 +17,60 @@ export const AgentItem = ({ agent }: { agent: ListAgentFragment }) => {};
const MyAgents: React.FC<IActiveClientsProps> = ({}) => {
const navigate = useNavigate();

const { data } = withRekuest(useMyAgentsQuery)({
const { data, subscribeToMore} = withRekuest(useMyAgentsQuery)({
fetchPolicy: "cache-and-network",
});

useEffect(() => {
console.log("Subscribing to My Representations");
const unsubscribe = subscribeToMore<AgentsEventSubscription>({
document: AgentsEventDocument,
updateQuery: (prev, { subscriptionData }) => {
console.log("Received Representation", subscriptionData);
var data = subscriptionData;
let action = data.data?.agentsEvent;
let newelements;
// Try to update
if (action?.updated) {
let updated_res = action.updated;
newelements = prev.myagents?.map((item: any) =>
item.id === updated_res?.id
? { ...item, data: { ...item.data, ...updated_res } }
: item
);
}

if (action?.deleted) {
let ended_res = action.deleted;
newelements = prev.myagents
?.map((item: any) => (item.id === ended_res ? null : item))
.filter((item) => item != null);
}

if (action?.created) {
let updated_res = action.created;
if (prev.myagents) {
newelements = [updated_res, ...prev.myagents];
} else {
newelements = [updated_res];
}
}

console.log("Received ", subscriptionData);
return {
...prev,
myrepresentations: newelements,
} as MyAgentsQuery;
},
});
return () => unsubscribe();
}, [subscribeToMore]);






const kickagent = useKickAgentMate();
const bounceagent = useBounceAgentMate();
const deleteagent = useDeleteAgentMate();
Expand Down
2 changes: 1 addition & 1 deletion src/components/buttons/LoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const LoginButton: React.FC<{}> = (props) => {
try {
let redirect_uri: string;
if (window.__TAURI__) {
let port = await invoke("oauth_start", { config: { ports: [7890] } });
let port = await invoke("oauth_start", { config: { ports: [7890, 4567, 7888, 8345, 2389, 5839, 6895, 23893, 2349, 23939] } });
console.log("Server started on port", port);
redirect_uri = `http://127.0.0.1:${port}/`;
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/mikro/components/Representation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,8 @@ const RepresentationScreen: React.FC<ISampleProps> = ({ id }) => {
object={met.id}
className="font-light"
>
{met?.key}
{met.key && <div className="text-xs">{met.key}</div>}
{met.value && <div className="text-md">{met.value}</div>}
</MikroMetric.DetailLink>
</div>
</MikroMetric.Smart>
Expand Down
2 changes: 1 addition & 1 deletion src/mikro/components/dialogs/CreateContextModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const CreateContextModal = (
{(formikProps) => (
<Form>
<TwDialog
title="Scan Github Repo"
title="Create New Context"
buttons={
<>
<button
Expand Down
45 changes: 28 additions & 17 deletions src/mikro/sidepanels/DataSidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,78 +243,89 @@ const DataSidebar: React.FunctionComponent<IDataSidebarProps> = (props) => {
className="flex-grow flex flex-col gap-2 p-5 overflow-y-scroll direct"
data-enableselect={true}
>
{data?.experiments && data?.experiments.length > 0 && (
{data?.experiments && data?.experiments.length > 0 && (<>
<div className="font-semibold text-center text-xs dark:text-slate-50 mt-2">
Experiments
</div>
)}
<ResponsiveContainerGrid>
<ResponsiveContainerGrid>
{data?.experiments?.map((experiment, index) => (
<ExperimentItem key={index} experiment={experiment} />
))}
</ResponsiveContainerGrid>
{data?.datasets && data?.datasets.length > 0 && (
</>
)}

{data?.datasets && data?.datasets.length > 0 && (<>
<div className="font-semibold text-center text-xs dark:text-slate-50 mt-2">
Datasets
</div>
)}

<ResponsiveContainerGrid>
{data?.datasets?.map((dataset, index) => (
<DatasetItem key={index} dataset={dataset} />
))}
</ResponsiveContainerGrid>
</>)}
{data?.samples && data?.samples.length > 0 && (
<>
<div
className="font-semibold text-center text-xs dark:text-slate-50 mt-2"
data-enableselect={true}
>
Samples
</div>
)}
<ResponsiveContainerGrid>
<ResponsiveContainerGrid>
{data?.samples?.map((sa, index) => (
<SampleItem key={index} sa={sa} />
))}
</ResponsiveContainerGrid>
{data?.tables && data?.tables.length > 0 && (
</>
)}

{data?.tables && data?.tables.length > 0 && (<>
<div
className="font-semibold text-center text-xs dark:text-slate-50 mt-2"
data-enableselect={true}
>
Tables
</div>
)}
<ResponsiveContainerGrid>
<ResponsiveContainerGrid>
{data?.tables?.map((ta, index) => (
<TableItem table={ta} key={index} />
))}
</ResponsiveContainerGrid>
{data?.representations && data?.representations.length > 0 && (
</ResponsiveContainerGrid></>
)}

{data?.representations && data?.representations.length > 0 && (<>
<div
className="font-semibold text-center text-xs dark:text-slate-50 mt-2"
data-enableselect={true}
>
Images
</div>
)}
<ResponsiveContainerGrid>
<ResponsiveContainerGrid>
{data?.representations?.map((re, index) => (
<RepresentationItem key={index} re={re} />
))}
</ResponsiveContainerGrid>
{data?.files && data?.files.length > 0 && (
</>
)}

{data?.files && data?.files.length > 0 && (<>
<div
className="font-semibold text-center text-xs dark:text-slate-50 mt-2"
data-enableselect={true}
>
Files
</div>
)}
<ResponsiveContainerGrid>
<ResponsiveContainerGrid>
{data?.files?.map((f, index) => (
<FileItem key={index} file={f} />
))}
</ResponsiveContainerGrid>
</>
)}

</div>
</div>
</>
Expand Down
12 changes: 11 additions & 1 deletion src/rekuest/selection/SmartModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const SmartModel = ({

const [progress, setProgress] = useState<number | undefined>(undefined);
const [show, setShow] = useState(false);
const [focus, setFocus] = useState(false);

const on_progress = async (x: number | undefined) => {
setProgress(x);
Expand Down Expand Up @@ -95,6 +96,9 @@ export const SmartModel = ({
}
}, [show]);




const [{ isOver, canDrop, overItems }, drop] = useDrop(() => {
return {
accept: [SMART_MODEL_DROP_TYPE],
Expand Down Expand Up @@ -182,6 +186,12 @@ export const SmartModel = ({
progress,
})
}
onFocus={() => {
setShow(true);
}}
onBlur={() => {
setShow(false);
}}
onDoubleClick={() => {
setShow(!show);
}}
Expand Down Expand Up @@ -233,7 +243,7 @@ export const SmartModel = ({
)}
</>
)}
{((isFocused && !isOver) || show) && (
{((isFocused && !isOver) || show ) && (
<div
ref={setPopperElement}
style={{
Expand Down
3 changes: 3 additions & 0 deletions src/rekuest/selection/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const useModelSelect = (
item.id === proposedSelection.id
);


const mefocus =
focus?.identifier === proposedSelection.identifier &&
focus?.id === proposedSelection.id;
Expand Down Expand Up @@ -160,6 +161,8 @@ export const useModelSelect = (
// }
};



const bind = {
onMouseDown,
};
Expand Down

0 comments on commit 81c8ad4

Please sign in to comment.