Skip to content

Commit 3f86a3a

Browse files
[autofix.ci] apply automated fixes
1 parent cd31041 commit 3f86a3a

5 files changed

Lines changed: 37 additions & 28 deletions

File tree

src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/components/session-selector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function SessionSelector({
4949
setIsEditing(false);
5050
const trimmed = newSessionId.trim();
5151
if (!trimmed || trimmed === session) return;
52-
52+
5353
// Use handleRename if provided (from sidebar), otherwise use mutation directly (from header)
5454
if (handleRename) {
5555
await handleRename(session, trimmed);

src/frontend/src/components/core/playgroundComponent/chat-view/chat-header/hooks/use-edit-session-info.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const useEditSessionInfo = ({
4545
}
4646
};
4747

48-
const handleRename = async (sessionId: string, newSessionId: string) => {
48+
const handleRename = async (sessionId: string, newSessionId: string) => {
4949
// Update session name via API or sessionStorage
5050
await updateSessionName({
5151
old_session_id: sessionId,
@@ -55,7 +55,7 @@ export const useEditSessionInfo = ({
5555
// Update local sessions list using the provided function
5656
if (renameLocalSession) {
5757
renameLocalSession(sessionId, newSessionId);
58-
}
58+
}
5959

6060
// Update selected session if the renamed session is currently selected
6161
if (flowId && sessionId === selectedSession) {

src/frontend/src/components/core/playgroundComponent/chat-view/chat-messages/hooks/use-chat-history.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const useChatHistory = (visibleSession: string | null) => {
2929
queryFn: () => {
3030
// Return cached data immediately - this makes the query active and reactive
3131
// We're using useQuery purely as a subscription mechanism, not for fetching
32-
const cachedData = queryClient.getQueryData<Message[]>(sessionCacheKey) || [];
32+
const cachedData =
33+
queryClient.getQueryData<Message[]>(sessionCacheKey) || [];
3334
return cachedData;
3435
},
3536
staleTime: Infinity, // Never refetch - updates come from setQueryData, not server
@@ -70,7 +71,8 @@ export const useChatHistory = (visibleSession: string | null) => {
7071
// In the default session, we show messages that have the same session_id as the flow_id
7172
// OR messages that have NO session_id (legacy behavior)
7273
if (visibleSession === currentFlowId) {
73-
const matches = isCurrentFlow &&
74+
const matches =
75+
isCurrentFlow &&
7476
(message.session_id === visibleSession || !message.session_id);
7577
return matches;
7678
}

src/frontend/src/components/core/playgroundComponent/sliding-container/components/flow-page-sliding-container.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ export function FlowPageSlidingContainerContent({
3737
);
3838
const [openLogsModal, setOpenLogsModal] = useState(false);
3939

40-
const { sessions, addNewSession, removeLocalSession, renameLocalSession, fetchedSessions } =
41-
useGetAddSessions({
42-
flowId: currentFlowId,
43-
currentSessionId,
44-
});
40+
const {
41+
sessions,
42+
addNewSession,
43+
removeLocalSession,
44+
renameLocalSession,
45+
fetchedSessions,
46+
} = useGetAddSessions({
47+
flowId: currentFlowId,
48+
currentSessionId,
49+
});
4550
const { handleDelete } = useEditSessionInfo({
4651
flowId: currentFlowId,
4752
dbSessions: fetchedSessions,

src/frontend/src/controllers/API/queries/messages/use-rename-session.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,24 @@ export const useUpdateSessionName: useMutationFunctionType<
2424

2525
const updateSessionApi = async (data: UpdateSessionParams) => {
2626
const isPlaygroundFromFlow = useFlowStore.getState().playgroundPage;
27-
const isPlaygroundFromPlayground = usePlaygroundStore.getState().isPlayground;
27+
const isPlaygroundFromPlayground =
28+
usePlaygroundStore.getState().isPlayground;
2829
const isPlayground = isPlaygroundFromFlow || isPlaygroundFromPlayground;
2930
// if we are in playground we will edit the local storage instead of the API
3031
if (isPlayground && flowId) {
31-
const messages = JSON.parse(sessionStorage.getItem(flowId) || "[]");
32+
const messages = JSON.parse(sessionStorage.getItem(flowId) || "[]");
3233
const messagesWithNewSessionId = messages.map((message: Message) => {
3334
if (message.session_id === data.old_session_id) {
3435
message.session_id = data.new_session_id;
3536
}
3637
return message;
3738
});
38-
sessionStorage.setItem(flowId, JSON.stringify(messagesWithNewSessionId));
39+
sessionStorage.setItem(flowId, JSON.stringify(messagesWithNewSessionId));
3940
// Update the messages store to reflect the new session_id
40-
useMessagesStore.getState().renameSession(data.old_session_id, data.new_session_id);
41-
41+
useMessagesStore
42+
.getState()
43+
.renameSession(data.old_session_id, data.new_session_id);
44+
4245
// CRITICAL: Move messages from old cache key to new cache key
4346
const oldCacheKey = [
4447
"useGetMessagesQuery",
@@ -48,26 +51,26 @@ export const useUpdateSessionName: useMutationFunctionType<
4851
"useGetMessagesQuery",
4952
{ id: flowId, session_id: data.new_session_id },
5053
];
51-
52-
const oldCacheData = queryClient.getQueryData<Message[]>(oldCacheKey);
54+
55+
const oldCacheData = queryClient.getQueryData<Message[]>(oldCacheKey);
5356
// Get fresh messages from sessionStorage (source of truth after rename)
5457
const freshMessages = JSON.parse(sessionStorage.getItem(flowId) || "[]");
5558
const messagesForNewSession = freshMessages.filter(
56-
(msg: Message) => msg.session_id === data.new_session_id
59+
(msg: Message) => msg.session_id === data.new_session_id,
5760
);
58-
61+
5962
// Set the new cache with fresh messages from sessionStorage
6063
queryClient.setQueryData(newCacheKey, messagesForNewSession);
61-
64+
6265
// Remove the old cache key
6366
if (oldCacheData && oldCacheData.length > 0) {
6467
queryClient.removeQueries({ queryKey: oldCacheKey });
6568
}
66-
69+
6770
queryClient.invalidateQueries({
6871
queryKey: ["useGetSessionsFromFlowQuery"],
6972
});
70-
73+
7174
return {
7275
data: messagesWithNewSessionId,
7376
};
@@ -79,32 +82,31 @@ export const useUpdateSessionName: useMutationFunctionType<
7982
params: { new_session_id: data.new_session_id },
8083
},
8184
);
82-
85+
8386
// Update React Query cache with the renamed messages
8487
if (result.data && flowId) {
8588
const newCacheKey = [
8689
"useGetMessagesQuery",
8790
{ id: flowId, session_id: data.new_session_id },
8891
];
89-
92+
9093
queryClient.setQueryData(newCacheKey, result.data);
91-
94+
9295
// Remove old cache key
9396
const oldCacheKey = [
9497
"useGetMessagesQuery",
9598
{ id: flowId, session_id: data.old_session_id },
9699
];
97100
queryClient.removeQueries({ queryKey: oldCacheKey });
98101
}
99-
102+
100103
return result.data;
101104
}
102105
};
103106

104107
const mutation: UseMutationResult<Message[], any, UpdateSessionParams> =
105108
mutate(["useUpdateSessionName"], updateSessionApi, {
106-
onMutate: (variables) => {
107-
},
109+
onMutate: (variables) => {},
108110
onSuccess: (data, variables, context, ...rest) => {
109111
// Call the original onSuccess if provided
110112
options?.onSuccess?.(data, variables, context, ...rest);

0 commit comments

Comments
 (0)