feat: add sessions endpoint with session management enhancements#8596
Conversation
…coding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests
…ssions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground
…y for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession
…default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce comprehensive session management improvements across both backend and frontend. A new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
User->>Frontend: Selects Flow or Session
Frontend->>Backend: GET /sessions?flow_id={flow_id}
Backend-->>Frontend: [session_id_1, session_id_2, ...]
Frontend->>Backend: GET /messages?flow_id={flow_id}&session_id={encoded_session_id}
Backend-->>Frontend: [messages...]
User->>Frontend: Deletes a session or message
Frontend->>Backend: DELETE /messages
Backend-->>Frontend: Success
Frontend->>Backend: (on settled) Invalidate /sessions query
Backend-->>Frontend: Updated sessions list
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
… code for better readability and maintainability
There was a problem hiding this comment.
Actionable comments posted: 5
🔭 Outside diff range comments (2)
src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx (2)
29-41:setActiveSessionis declared but never used inside the componentA new callback prop is threaded into the component signature, yet no logic invokes it.
Either wire it into the click / rename flows (e.g., when the user picks or renames a session) or remove the prop to avoid dead code and misleading API.@@ - const handleConfirm = () => { + const handleConfirm = () => { @@ updateSessionName( @@ onSuccess: () => { + // keep global active-session state in sync + setActiveSession(editedSession.trim());
68-88: Renaming allows empty / blank session IDs
editedSession.trim()can be an empty string which then propagates to the backend and the UI.
Add a guard to prevent empty names and give the user feedback.if (editedSession.trim() !== session) { + if (!editedSession.trim()) { + // early exit or toast error + return; + }
🧹 Nitpick comments (12)
src/frontend/src/utils/utils.ts (2)
938-955: Date-time session regexp is too restrictive
/^Session\s+\w{3}\s+\d{1,2},\s+\d{2}:\d{2}:\d{2}$/fails for:
- months with full names (“September”)
- AM/PM suffixes
- localisation differences (“Jun 16 2025” vs “Jun 16, 2025”)
Unless the backend guarantees this exact formatting, prefer a broader parse or reuse a date-library
parse/format routine to avoid false negatives.
905-916: Minor: avoid double-encoding by documenting usage
prepareSessionIdForAPI()already encodes; a careless caller might encode twice by
callingencodeSessionIdfirst. Add a JSDoc example or markencodeSessionIdas internal to reduce misuse.src/frontend/src/stores/flowStore.ts (1)
1064-1067: Flag-reset responsibility is unclear
newChatOnPlaygroundis written but never reset inside the store itself.
If downstream components forget to toggle it back tofalse, session refetching could be triggered only once (or, conversely, on every render depending on the consumer logic).Consider either:
- Resetting the flag to
falseinside the same setter after external side-effects occur, or- Providing a dedicated
resetNewChatOnPlayground()helper to make the lifecycle explicit.src/frontend/src/controllers/API/queries/messages/use-delete-messages.ts (1)
30-39: Nice: preserves caller’sonSettled, but generic typing feels offGood job forwarding
options?.onSettled.
Minor:UseMutationResult<DeleteMessagesParams, …>sets the data type toDeleteMessagesParams, while the mutation returnsundefined. Consider changing the first generic argument toundefined(or the actual response shape) to keep type-safety tight.-const mutation: UseMutationResult< - DeleteMessagesParams, +const mutation: UseMutationResult< + undefined,src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx (1)
51-53:setNewChatOnPlaygroundis imported but never referencedThis unused selector will be tree-shaken in prod builds but still fails the linter in dev.
Remove the destructuring or incorporate the flag where intended.- const setNewChatOnPlayground = useFlowStore( - (state) => state.setNewChatOnPlayground, - ); + // Uncomment when actually needed, otherwise drop: + // const setNewChatOnPlayground = useFlowStore( + // (state) => state.setNewChatOnPlayground, + // );src/frontend/src/controllers/API/queries/messages/use-get-messages.ts (1)
39-47: Param processing usesany– tighten typing & avoid in-place mutationUsing
anydefeats type-safety and mutatingprocessedParamsin-place risks accidental side-effects if the original object is reused elsewhere.
Clone with a typed interface instead.- const processedParams = { ...params } as any; + interface ProcessedParams extends Record<string, unknown> { + session_id?: string; + } + const processedParams: ProcessedParams = { ...params };src/backend/base/langflow/api/v1/monitor.py (1)
51-54: Trailing-whitespace flagged by RuffTwo blank lines contain stray spaces causing the CI failure (
W293).
Delete the whitespace.- - +src/frontend/src/controllers/API/queries/messages/use-get-sessions-from-flow.ts (2)
22-49:idcan be undefined – accessingsessionStorage.getItem(id ?? "")creates a “default” keyWhen
idis undefined in playground mode you silently read / write under the empty-string key, which couples unrelated flows.
Consider early-returning or throwing whenidis missing.- if (isPlaygroundPage) { + if (isPlaygroundPage) { + if (!id) return { data: [] };
51-56: Wrap backend errors to surface useful feedback
getSessionsFndoesn’t catch/propagate API errors; callers receive promise rejections without context.
Wrap the request in a try/catch and re-throw a more descriptive error or use React-Query’sretry/onError.src/backend/tests/unit/test_session_endpoint.py (3)
17-64: Clean up formatting issues.This section has multiple trailing whitespace and blank line issues that should be cleaned up for consistency.
Apply this diff to fix the formatting:
flow_id_1 = uuid4() flow_id_2 = uuid4() - + # Create MessageTable objects directly since MessageCreate doesn't have flow_id field messagetables = [ MessageTable( - text="Message 1", - sender="User", - sender_name="User", - session_id="session_A", + text="Message 1", + sender="User", + sender_name="User", + session_id="session_A", flow_id=flow_id_1 ), MessageTable( - text="Message 2", - sender="AI", - sender_name="AI", - session_id="session_A", + text="Message 2", + sender="AI", + sender_name="AI", + session_id="session_A", flow_id=flow_id_1 ), MessageTable( - text="Message 3", - sender="User", - sender_name="User", - session_id="session_B", + text="Message 3", + sender="User", + sender_name="User", + session_id="session_B", flow_id=flow_id_1 ), MessageTable( - text="Message 4", - sender="User", - sender_name="User", - session_id="session_C", + text="Message 4", + sender="User", + sender_name="User", + session_id="session_C", flow_id=flow_id_2 ), MessageTable( - text="Message 5", - sender="AI", - sender_name="AI", - session_id="session_D", + text="Message 5", + sender="AI", + sender_name="AI", + session_id="session_D", flow_id=flow_id_2 ), MessageTable( - text="Message 6", - sender="User", - sender_name="User", - session_id="session_E", + text="Message 6", + sender="User", + sender_name="User", + session_id="session_E", flow_id=None # No flow_id ), ] created_messages = await aadd_messagetables(messagetables, _session) - + return {
116-116: Consider shortening the function name.The function name exceeds the 120-character line limit.
Apply this diff to use a shorter but still descriptive name:
-async def test_get_sessions_with_different_flow_id_filter(client: AsyncClient, logged_in_headers, messages_with_flow_ids): +async def test_get_sessions_with_another_flow_id(client: AsyncClient, logged_in_headers, messages_with_flow_ids):
99-102: Fix formatting in HTTP request parameters.Clean up trailing whitespace in the client.get calls.
Apply this diff to fix the formatting:
response = await client.get( - "api/v1/monitor/sessions", - params={"flow_id": str(flow_id_1)}, + "api/v1/monitor/sessions", + params={"flow_id": str(flow_id_1)}, headers=logged_in_headers )And similar changes for lines 121-124, 143-146, and 169-172.
Also applies to: 121-124, 143-146, 169-172
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
pyproject.toml(1 hunks)src/backend/base/langflow/api/v1/monitor.py(2 hunks)src/backend/tests/unit/test_session_endpoint.py(1 hunks)src/frontend/src/controllers/API/helpers/constants.ts(1 hunks)src/frontend/src/controllers/API/queries/messages/use-delete-messages.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-messages-polling.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-messages.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-sessions-from-flow.ts(1 hunks)src/frontend/src/controllers/API/queries/messages/use-rename-session.ts(1 hunks)src/frontend/src/customization/components/custom-new-modal.tsx(1 hunks)src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx(4 hunks)src/frontend/src/modals/IOModal/components/sidebar-open-view.tsx(4 hunks)src/frontend/src/modals/IOModal/playground-modal.tsx(10 hunks)src/frontend/src/modals/IOModal/types/sidebar-open-view.ts(1 hunks)src/frontend/src/stores/flowStore.ts(1 hunks)src/frontend/src/types/zustand/flow/index.ts(1 hunks)src/frontend/src/utils/utils.ts(1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
src/backend/base/langflow/api/v1/monitor.py
51-51: Blank line contains whitespace
Remove whitespace from blank line
(W293)
54-54: Blank line contains whitespace
Remove whitespace from blank line
(W293)
src/backend/tests/unit/test_session_endpoint.py
6-6: langflow.services.database.models.message.MessageCreate imported but unused
Remove unused import: langflow.services.database.models.message.MessageCreate
(F401)
17-17: Blank line contains whitespace
Remove whitespace from blank line
(W293)
21-21: Trailing whitespace
Remove trailing whitespace
(W291)
22-22: Trailing whitespace
Remove trailing whitespace
(W291)
23-23: Trailing whitespace
Remove trailing whitespace
(W291)
24-24: Trailing whitespace
Remove trailing whitespace
(W291)
28-28: Trailing whitespace
Remove trailing whitespace
(W291)
29-29: Trailing whitespace
Remove trailing whitespace
(W291)
30-30: Trailing whitespace
Remove trailing whitespace
(W291)
31-31: Trailing whitespace
Remove trailing whitespace
(W291)
35-35: Trailing whitespace
Remove trailing whitespace
(W291)
36-36: Trailing whitespace
Remove trailing whitespace
(W291)
37-37: Trailing whitespace
Remove trailing whitespace
(W291)
38-38: Trailing whitespace
Remove trailing whitespace
(W291)
42-42: Trailing whitespace
Remove trailing whitespace
(W291)
43-43: Trailing whitespace
Remove trailing whitespace
(W291)
44-44: Trailing whitespace
Remove trailing whitespace
(W291)
45-45: Trailing whitespace
Remove trailing whitespace
(W291)
49-49: Trailing whitespace
Remove trailing whitespace
(W291)
50-50: Trailing whitespace
Remove trailing whitespace
(W291)
51-51: Trailing whitespace
Remove trailing whitespace
(W291)
52-52: Trailing whitespace
Remove trailing whitespace
(W291)
56-56: Trailing whitespace
Remove trailing whitespace
(W291)
57-57: Trailing whitespace
Remove trailing whitespace
(W291)
58-58: Trailing whitespace
Remove trailing whitespace
(W291)
59-59: Trailing whitespace
Remove trailing whitespace
(W291)
64-64: Blank line contains whitespace
Remove whitespace from blank line
(W293)
80-80: Blank line contains whitespace
Remove whitespace from blank line
(W293)
84-84: Blank line contains whitespace
Remove whitespace from blank line
(W293)
88-88: Blank line contains whitespace
Remove whitespace from blank line
(W293)
97-97: Blank line contains whitespace
Remove whitespace from blank line
(W293)
99-99: Trailing whitespace
Remove trailing whitespace
(W291)
100-100: Trailing whitespace
Remove trailing whitespace
(W291)
103-103: Blank line contains whitespace
Remove whitespace from blank line
(W293)
107-107: Blank line contains whitespace
Remove whitespace from blank line
(W293)
110-110: Blank line contains whitespace
Remove whitespace from blank line
(W293)
116-116: Line too long (122 > 120)
(E501)
119-119: Blank line contains whitespace
Remove whitespace from blank line
(W293)
121-121: Trailing whitespace
Remove trailing whitespace
(W291)
122-122: Trailing whitespace
Remove trailing whitespace
(W291)
125-125: Blank line contains whitespace
Remove whitespace from blank line
(W293)
129-129: Blank line contains whitespace
Remove whitespace from blank line
(W293)
132-132: Blank line contains whitespace
Remove whitespace from blank line
(W293)
138-138: Unused function argument: messages_with_flow_ids
(ARG001)
141-141: Blank line contains whitespace
Remove whitespace from blank line
(W293)
143-143: Trailing whitespace
Remove trailing whitespace
(W291)
144-144: Trailing whitespace
Remove trailing whitespace
(W291)
147-147: Blank line contains whitespace
Remove whitespace from blank line
(W293)
158-158: Blank line contains whitespace
Remove whitespace from blank line
(W293)
166-166: Unused function argument: messages_with_flow_ids
(ARG001)
169-169: Trailing whitespace
Remove trailing whitespace
(W291)
170-170: Trailing whitespace
Remove trailing whitespace
(W291)
173-173: Blank line contains whitespace
Remove whitespace from blank line
(W293)
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/base/langflow/api/v1/monitor.py
[failure] 54-54: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:54:1: W293 Blank line contains whitespace
[failure] 51-51: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:51:1: W293 Blank line contains whitespace
src/backend/tests/unit/test_session_endpoint.py
[failure] 29-29: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:29:29: W291 Trailing whitespace
[failure] 28-28: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:28:34: W291 Trailing whitespace
[failure] 24-24: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:24:40: W291 Trailing whitespace
[failure] 23-23: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:23:36: W291 Trailing whitespace
[failure] 22-22: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:22:31: W291 Trailing whitespace
[failure] 21-21: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:21:34: W291 Trailing whitespace
[failure] 17-17: Ruff (W293)
src/backend/tests/unit/test_session_endpoint.py:17:1: W293 Blank line contains whitespace
[failure] 6-6: Ruff (F401)
src/backend/tests/unit/test_session_endpoint.py:6:55: F401 langflow.services.database.models.message.MessageCreate imported but unused
🪛 GitHub Actions: Ruff Style Check
src/backend/base/langflow/api/v1/monitor.py
[error] 51-51: W293 Blank line contains whitespace.
🪛 Pylint (3.3.7)
src/backend/tests/unit/test_session_endpoint.py
[error] 5-5: No name 'memory' in module 'langflow'
(E0611)
[error] 6-6: No name 'services' in module 'langflow'
(E0611)
[error] 7-7: No name 'services' in module 'langflow'
(E0611)
[error] 8-8: No name 'services' in module 'langflow'
(E0611)
🔇 Additional comments (15)
pyproject.toml (1)
233-233: I’ll locate any--ignore=tests/integrationoccurrences, find wherecoverage runis invoked, and inspect the pytest config section in pyproject.toml.#!/bin/bash set -e echo "1) Searching for literal '--ignore=tests/integration':" rg -F '--ignore=tests/integration' -n . || echo "→ No matches found." echo echo "2) Finding 'coverage run' invocations in the repo:" rg 'coverage run' -n . || echo "→ No coverage run found." echo echo "3) Finding 'coverage run' in CI workflows:" find .github/workflows -type f -exec rg 'coverage run' -n {} + || echo "→ No coverage run in workflows." echo echo "4) Inspecting pytest config around testpaths in pyproject.toml:" sed -n '225,245p' pyproject.tomlsrc/frontend/src/customization/components/custom-new-modal.tsx (1)
1-1: Import path update looks goodPath switch to the new playground modal matches the refactor; no issues spotted.
src/frontend/src/controllers/API/helpers/constants.ts (1)
10-10: Constant added in correct namespace
SESSIONSkey slots neatly into the existingURLsmap; nothing else to add.src/frontend/src/modals/IOModal/types/sidebar-open-view.ts (1)
11-11: ```shell
#!/bin/bash1. Show the props defined in sidebar-open-view.ts
echo "=== sidebar-open-view.ts props ==="
sed -n '1,200p' src/frontend/src/modals/IOModal/types/sidebar-open-view.ts || true2. Find all JSX/TSX usages of <SidebarOpenView
echo -e "\n=== SidebarOpenView JSX usages ==="
rg -n "<SidebarOpenView" -g ".tsx" -g ".jsx" || true3. Check which of those usages pass the setActiveSession prop
echo -e "\n=== setActiveSession prop in JSX ==="
rg -n "setActiveSession" -g ".tsx" -g ".jsx" || true</details> <details> <summary>src/frontend/src/types/zustand/flow/index.ts (1)</summary> `288-290`: **Type additions look good** The new flag and setter are correctly typed and keep the public store contract in sync with the implementation. </details> <details> <summary>src/frontend/src/controllers/API/queries/messages/use-get-messages-polling.ts (1)</summary> `115-123`: **👍 Session-ID preprocessing** Encoding `session_id` via `prepareSessionIdForAPI` before sending the request keeps frontend/back-end behaviour consistent with the new decoding logic server-side. </details> <details> <summary>src/frontend/src/modals/IOModal/components/sidebar-open-view.tsx (1)</summary> `62-93`: **Down-propagated `setActiveSession` but not triggered by child** `SessionSelector` receives `setActiveSession` yet never calls it (see previous comment). Until the child uses the callback, passing the prop is ineffective. Keep interfaces consistent between parent and child. </details> <details> <summary>src/frontend/src/modals/IOModal/playground-modal.tsx (7)</summary> `7-7`: **LGTM! Well-structured state management.** The imports and new state hooks for handling new chat sessions on the playground are properly implemented. Also applies to: 14-14, 48-54 --- `91-111`: **Excellent session initialization logic.** The integration with `useGetSessionsFromFlowQuery` and the effect that ensures `currentFlowId` is always included in the sessions list is well implemented. This provides a good fallback behavior. --- `134-143`: **Good handling of session deletion edge cases.** The logic properly handles switching to another session when the visible one is deleted, with a sensible fallback to `currentFlowId`. --- `177-187`: **Proper integration with session-based message filtering.** The query correctly uses `visibleSession` to filter messages, maintaining consistency with the new session management approach. --- `306-314`: **Verify the toggle behavior for active sessions.** The current implementation toggles off the session when clicking the same one, setting `visibleSession` to `undefined`. This might be confusing UX and could lead to states where no session is visible. Consider whether this toggle behavior is intentional. Most UIs keep the current selection when clicking on an already selected item. If this is intentional, ensure the UI properly handles the case where `visibleSession` is `undefined`. --- `315-334`: **Well-implemented session change tracking.** The effect properly handles initialization and subsequent session changes, avoiding unnecessary refetches on mount while ensuring messages are refetched when the session actually changes. --- `400-400`: **Good loading state management.** The conditional rendering based on `sessionsLoading` prevents UI flicker and ensures components have the necessary data before rendering. Also applies to: 409-409, 448-448 </details> <details> <summary>src/backend/tests/unit/test_session_endpoint.py (1)</summary> `75-91`: **Excellent test coverage for the sessions endpoint.** The test properly verifies retrieval of all sessions and uses set comparison for order-independent validation. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| if (!encoded_session_id) return ""; | ||
| try { | ||
| return decodeURIComponent(encoded_session_id); | ||
| } catch (error) { | ||
| console.warn("Failed to decode session ID:", encoded_session_id, error); | ||
| return encoded_session_id; // Return as-is if decoding fails | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
“+” is not decoded to a space
decodeURIComponent leaves plus signs untouched, yet sessionIdFormatted treats “+” as a sign that the
value is URL-encoded.
If the BE encodes spaces as “+” (common for query parameters), they will survive the round-trip.
try {
- return decodeURIComponent(encoded_session_id);
+ return decodeURIComponent(encoded_session_id.replace(/\+/g, " "));
} catch (error) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!encoded_session_id) return ""; | |
| try { | |
| return decodeURIComponent(encoded_session_id); | |
| } catch (error) { | |
| console.warn("Failed to decode session ID:", encoded_session_id, error); | |
| return encoded_session_id; // Return as-is if decoding fails | |
| } | |
| } | |
| if (!encoded_session_id) return ""; | |
| try { | |
| return decodeURIComponent(encoded_session_id.replace(/\+/g, " ")); | |
| } catch (error) { | |
| console.warn("Failed to decode session ID:", encoded_session_id, error); | |
| return encoded_session_id; // Return as-is if decoding fails | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/frontend/src/utils/utils.ts around lines 924 to 931, the
decodeURIComponent call does not convert plus signs to spaces, causing issues if
the backend encodes spaces as "+". To fix this, before calling
decodeURIComponent, replace all "+" characters in encoded_session_id with
spaces, then decode the result. This ensures spaces encoded as "+" are properly
handled.
| onSettled: () => { | ||
| queryClient.invalidateQueries({ | ||
| queryKey: ["useGetSessionsFromFlowQuery"], | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Do not swallow consumer-provided onSettled
The custom onSettled invalidates the sessions cache but no longer calls any onSettled the caller might have passed, breaking backward compatibility with existing consumers.
- onSettled: () => {
+ onSettled: (data, error, variables, context) => {
queryClient.invalidateQueries({
queryKey: ["useGetSessionsFromFlowQuery"],
});
+ options?.onSettled?.(data, error, variables, context);
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onSettled: () => { | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| onSettled: (data, error, variables, context) => { | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| options?.onSettled?.(data, error, variables, context); | |
| }, |
🤖 Prompt for AI Agents
In src/frontend/src/controllers/API/queries/messages/use-rename-session.ts
around lines 51 to 54, the current onSettled handler invalidates the sessions
cache but does not call the consumer-provided onSettled callback, breaking
backward compatibility. To fix this, modify the onSettled function to first
invalidate the cache as it does now, then check if an onSettled callback was
passed by the caller and invoke it with the appropriate arguments to ensure the
original behavior is preserved.
| @router.get("/sessions") | ||
| async def get_sessions( | ||
| session: DbSession, | ||
| flow_id: Annotated[UUID | None, Query()] = None, | ||
| ) -> list[str]: | ||
| try: | ||
| stmt = select(MessageTable.session_id).distinct() | ||
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | ||
|
|
||
| if flow_id: | ||
| stmt = stmt.where(MessageTable.flow_id == flow_id) | ||
|
|
||
| sessions = await session.exec(stmt) | ||
| return list(sessions) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=str(e)) from e | ||
|
|
There was a problem hiding this comment.
Incorrect result extraction – you will return Row objects, not strings
session.exec(stmt) yields a Result object. Converting to list() produces rows like (<session_id>,), violating the annotated return type list[str] and breaking JSON serialisation.
- sessions = await session.exec(stmt)
- return list(sessions)
+ result = await session.exec(stmt)
+ sessions: list[str] = result.scalars().all()
+ return sessions📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @router.get("/sessions") | |
| async def get_sessions( | |
| session: DbSession, | |
| flow_id: Annotated[UUID | None, Query()] = None, | |
| ) -> list[str]: | |
| try: | |
| stmt = select(MessageTable.session_id).distinct() | |
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | |
| if flow_id: | |
| stmt = stmt.where(MessageTable.flow_id == flow_id) | |
| sessions = await session.exec(stmt) | |
| return list(sessions) | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) from e | |
| @router.get("/sessions") | |
| async def get_sessions( | |
| session: DbSession, | |
| flow_id: Annotated[UUID | None, Query()] = None, | |
| ) -> list[str]: | |
| try: | |
| stmt = select(MessageTable.session_id).distinct() | |
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | |
| if flow_id: | |
| stmt = stmt.where(MessageTable.flow_id == flow_id) | |
| result = await session.exec(stmt) | |
| sessions: list[str] = result.scalars().all() | |
| return sessions | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) from e |
🧰 Tools
🪛 Ruff (0.11.9)
51-51: Blank line contains whitespace
Remove whitespace from blank line
(W293)
54-54: Blank line contains whitespace
Remove whitespace from blank line
(W293)
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 54-54: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:54:1: W293 Blank line contains whitespace
[failure] 51-51: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:51:1: W293 Blank line contains whitespace
🪛 GitHub Actions: Ruff Style Check
[error] 51-51: W293 Blank line contains whitespace.
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/monitor.py lines 43 to 59, the function
get_sessions returns a list of Row objects instead of a list of strings as
annotated. To fix this, after executing the statement, extract the session_id
values from each row before returning. This can be done by iterating over the
result and collecting the first element of each row into a list of strings to
match the expected return type.
| if (newChatOnPlayground && !sessionsLoading) { | ||
| const handleRefetchAndSetSession = async () => { | ||
| try { | ||
| const result = await refetchSessions(); | ||
| if (result.data?.sessions && result.data.sessions.length > 0) { | ||
| setvisibleSession( | ||
| result.data.sessions[result.data.sessions.length - 1], | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error refetching sessions:", error); | ||
| } | ||
| }; | ||
|
|
||
| handleRefetchAndSetSession(); | ||
| setNewChatOnPlayground(false); | ||
| } | ||
| }, [messages]); |
There was a problem hiding this comment.
Fix the dependency array in the effect.
The effect depends on newChatOnPlayground and sessionsLoading but the dependency array contains messages. This could cause unnecessary re-runs or miss necessary updates.
Apply this diff to fix the dependency array:
- }, [messages]);
+ }, [newChatOnPlayground, sessionsLoading, refetchSessions, setNewChatOnPlayground]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (newChatOnPlayground && !sessionsLoading) { | |
| const handleRefetchAndSetSession = async () => { | |
| try { | |
| const result = await refetchSessions(); | |
| if (result.data?.sessions && result.data.sessions.length > 0) { | |
| setvisibleSession( | |
| result.data.sessions[result.data.sessions.length - 1], | |
| ); | |
| } | |
| } catch (error) { | |
| console.error("Error refetching sessions:", error); | |
| } | |
| }; | |
| handleRefetchAndSetSession(); | |
| setNewChatOnPlayground(false); | |
| } | |
| }, [messages]); | |
| if (newChatOnPlayground && !sessionsLoading) { | |
| const handleRefetchAndSetSession = async () => { | |
| try { | |
| const result = await refetchSessions(); | |
| if (result.data?.sessions && result.data.sessions.length > 0) { | |
| setvisibleSession( | |
| result.data.sessions[result.data.sessions.length - 1], | |
| ); | |
| } | |
| } catch (error) { | |
| console.error("Error refetching sessions:", error); | |
| } | |
| }; | |
| handleRefetchAndSetSession(); | |
| setNewChatOnPlayground(false); | |
| } | |
| }, [newChatOnPlayground, sessionsLoading, refetchSessions, setNewChatOnPlayground]); |
🤖 Prompt for AI Agents
In src/frontend/src/modals/IOModal/playground-modal.tsx around lines 220 to 237,
the useEffect hook's dependency array incorrectly includes only 'messages' while
the effect logic depends on 'newChatOnPlayground' and 'sessionsLoading'. Update
the dependency array to include 'newChatOnPlayground' and 'sessionsLoading'
instead of 'messages' to ensure the effect runs correctly when these values
change.
| import pytest | ||
| from httpx import AsyncClient | ||
| from langflow.memory import aadd_messagetables | ||
| from langflow.services.database.models.message import MessageCreate |
There was a problem hiding this comment.
Remove unused import.
The MessageCreate import is not used in this file.
Apply this diff to remove the unused import:
-from langflow.services.database.models.message import MessageCreate📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from langflow.services.database.models.message import MessageCreate |
🧰 Tools
🪛 Ruff (0.11.9)
6-6: langflow.services.database.models.message.MessageCreate imported but unused
Remove unused import: langflow.services.database.models.message.MessageCreate
(F401)
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 6-6: Ruff (F401)
src/backend/tests/unit/test_session_endpoint.py:6:55: F401 langflow.services.database.models.message.MessageCreate imported but unused
🪛 Pylint (3.3.7)
[error] 6-6: No name 'services' in module 'langflow'
(E0611)
🤖 Prompt for AI Agents
In src/backend/tests/unit/test_session_endpoint.py at line 6, the import of
MessageCreate from langflow.services.database.models.message is unused. Remove
this import statement entirely to clean up the code and avoid unnecessary
imports.
There was a problem hiding this comment.
Actionable comments posted: 7
🔭 Outside diff range comments (2)
src/frontend/src/controllers/API/queries/messages/use-get-messages-polling.ts (1)
95-123:session_iddropped when supplied via top-level prop
payload.session_idis read (line 99) but never merged intoconfigunless it’s nested insideparams.
Previously callers could pass{ session_id: "abc" }without wrapping it. The current change is a silent breaking change and also skips URL-encoding for that path.Suggested fix:
- const sessionId = payload.session_id; + const sessionId = payload.session_id; ... if (params) { // existing logic … } + + if (sessionId) { + config["params"] = { + ...config["params"], + session_id: prepareSessionIdForAPI(sessionId), + }; + }This restores backwards compatibility and keeps encoding consistent.
src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx (1)
29-41: PropsetActiveSessionis accepted but never used
SessionSelectorreceivessetActiveSession, yet the callback is not invoked anywhere inside the component.
Down-stream callers (e.g.SidebarOpenView) pass a handler expecting state updates that never happen, so the “active session” UI can become stale.Quick win – trigger it when the user selects a session:
- onClick={(e) => { - setNewSessionCloseVoiceAssistant(true); - if (isEditing) e.stopPropagation(); - else toggleVisibility(); + onClick={(e) => { + setNewSessionCloseVoiceAssistant(true); + if (isEditing) { + e.stopPropagation(); + } else { + setActiveSession(session); + toggleVisibility(); + } }}
🧹 Nitpick comments (13)
src/frontend/src/stores/flowStore.ts (1)
1064-1068: Expose the flag before its setter for consistencyThroughout the store the pattern is: state field ➜ setter ➜ helper(s).
Here the order is reversed (setNewChatOnPlaygroundprecedesnewChatOnPlayground). Nothing is functionally wrong, but re-ordering keeps the shape predictable and eases grep-based scanning.- setNewChatOnPlayground: (newChat: boolean) => { - set({ newChatOnPlayground: newChat }); - }, - newChatOnPlayground: false, + newChatOnPlayground: false, + setNewChatOnPlayground: (newChat: boolean) => { + set({ newChatOnPlayground: newChat }); + },src/frontend/src/utils/utils.ts (2)
949-954:isDateTimeSessionregex is overly strict on localeThe pattern fixes the prefix to
"Session "and month as English abbreviated name (\w{3}), making it unusable for i18n builds or minor format drifts (e.g.,"Sessão"/"Sep"/"Sept"). If backend control isn’t guaranteed, loosen or document the expectation; otherwise fallback tomomentparsing.
991-994: Minor: avoid double-encoding by short-circuiting
prepareSessionIdForAPIalways re-encodes even when the incoming id is already%-escaped. A quick guard prevents%25cascades:export function prepareSessionIdForAPI(session_id: string): string { - const formatted = sessionIdFormatted(session_id); - return encodeSessionId(formatted); + const formatted = sessionIdFormatted(session_id); + return /%[0-9A-Fa-f]{2}/.test(formatted) ? formatted : encodeSessionId(formatted); }src/frontend/src/modals/IOModal/types/sidebar-open-view.ts (1)
11-12: Consider aligning the new prop’s nullability withvisibleSessionAll other session–selection setters (
setvisibleSession,handleDeleteSession) accept a possibly-undefined value or deal with optionality.setActiveSessionis typed as(session: string) => void, so callers cannot clear the active session once it’s been set.- setActiveSession: (session: string) => void; + setActiveSession: (session: string | undefined) => void;This keeps the API symmetrical and prevents future
undefined→stringtype-errors.src/backend/base/langflow/api/v1/monitor.py (1)
49-55: Trailing-space violations flagged by RuffLines 51 & 54 contain whitespace-only lines →
W293 Blank line contains whitespace.
Trivial but it currently breaks the CI style check.- - - + # (blank lines trimmed to satisfy Ruff)src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx (1)
51-53: Unused selector causes needless re-renders
setNewChatOnPlaygroundis pulled from the store but never referenced, creating an unnecessary subscription and a TypeScriptnoUnusedLocalswarning if strict mode is enabled.Either use it or remove the lines:
- const setNewChatOnPlayground = useFlowStore( - (state) => state.setNewChatOnPlayground, - );src/frontend/src/modals/IOModal/components/sidebar-open-view.tsx (1)
88-91: Redundant wrapper lambda aroundsetActiveSession
SessionSelectoralready expects the exact signature(session: string) => void.
Passing a closure that does nothing but forward the argument adds noise and re-creates a new function on every render.- setActiveSession={(session) => { - setActiveSession(session); - }} + setActiveSession={setActiveSession}src/frontend/src/controllers/API/queries/messages/use-get-messages.ts (1)
39-46: Minor: guard against non-stringsession_id
prepareSessionIdForAPIpresumably expects a string. Ifparams.session_idis anything else (number, null), the call could mis-behave.- if (processedParams.session_id) { + if (typeof processedParams.session_id === "string") { processedParams.session_id = prepareSessionIdForAPI( processedParams.session_id, ); }src/backend/tests/unit/test_session_endpoint.py (5)
11-73: Clean up formatting issues in the fixture.The fixture logic is good, but there are multiple formatting issues that should be addressed.
Remove trailing whitespace from lines 17, 21-24, 28-31, 35-38, 42-45, 49-52, 56-59, 64, and remove whitespace from blank lines.
75-91: Test implementation is correct.Good use of sets for order-independent comparison. Clean up whitespace on blank lines 80, 84, 88.
93-113: Flow ID filtering test is well implemented.Test properly verifies the filtering functionality. Clean up formatting issues.
137-152: Add noqa comment for fixture parameter.The
messages_with_flow_idsfixture ensures test data exists before testing the non-existent case.-async def test_get_sessions_with_non_existent_flow_id(client: AsyncClient, logged_in_headers, messages_with_flow_ids): +async def test_get_sessions_with_non_existent_flow_id(client: AsyncClient, logged_in_headers, messages_with_flow_ids): # noqa: ARG001
165-178: Invalid flow_id test provides good input validation coverage.Add noqa comment for the fixture parameter and clean up formatting.
-async def test_get_sessions_invalid_flow_id_format(client: AsyncClient, logged_in_headers, messages_with_flow_ids): +async def test_get_sessions_invalid_flow_id_format(client: AsyncClient, logged_in_headers, messages_with_flow_ids): # noqa: ARG001
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
pyproject.toml(1 hunks)src/backend/base/langflow/api/v1/monitor.py(2 hunks)src/backend/tests/unit/test_session_endpoint.py(1 hunks)src/frontend/src/controllers/API/helpers/constants.ts(1 hunks)src/frontend/src/controllers/API/queries/messages/use-delete-messages.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-messages-polling.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-messages.ts(2 hunks)src/frontend/src/controllers/API/queries/messages/use-get-sessions-from-flow.ts(1 hunks)src/frontend/src/controllers/API/queries/messages/use-rename-session.ts(1 hunks)src/frontend/src/customization/components/custom-new-modal.tsx(1 hunks)src/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsx(4 hunks)src/frontend/src/modals/IOModal/components/sidebar-open-view.tsx(4 hunks)src/frontend/src/modals/IOModal/playground-modal.tsx(10 hunks)src/frontend/src/modals/IOModal/types/sidebar-open-view.ts(1 hunks)src/frontend/src/stores/flowStore.ts(1 hunks)src/frontend/src/types/zustand/flow/index.ts(1 hunks)src/frontend/src/utils/utils.ts(1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
src/backend/base/langflow/api/v1/monitor.py
51-51: Blank line contains whitespace
Remove whitespace from blank line
(W293)
54-54: Blank line contains whitespace
Remove whitespace from blank line
(W293)
src/backend/tests/unit/test_session_endpoint.py
6-6: langflow.services.database.models.message.MessageCreate imported but unused
Remove unused import: langflow.services.database.models.message.MessageCreate
(F401)
17-17: Blank line contains whitespace
Remove whitespace from blank line
(W293)
21-21: Trailing whitespace
Remove trailing whitespace
(W291)
22-22: Trailing whitespace
Remove trailing whitespace
(W291)
23-23: Trailing whitespace
Remove trailing whitespace
(W291)
24-24: Trailing whitespace
Remove trailing whitespace
(W291)
28-28: Trailing whitespace
Remove trailing whitespace
(W291)
29-29: Trailing whitespace
Remove trailing whitespace
(W291)
30-30: Trailing whitespace
Remove trailing whitespace
(W291)
31-31: Trailing whitespace
Remove trailing whitespace
(W291)
35-35: Trailing whitespace
Remove trailing whitespace
(W291)
36-36: Trailing whitespace
Remove trailing whitespace
(W291)
37-37: Trailing whitespace
Remove trailing whitespace
(W291)
38-38: Trailing whitespace
Remove trailing whitespace
(W291)
42-42: Trailing whitespace
Remove trailing whitespace
(W291)
43-43: Trailing whitespace
Remove trailing whitespace
(W291)
44-44: Trailing whitespace
Remove trailing whitespace
(W291)
45-45: Trailing whitespace
Remove trailing whitespace
(W291)
49-49: Trailing whitespace
Remove trailing whitespace
(W291)
50-50: Trailing whitespace
Remove trailing whitespace
(W291)
51-51: Trailing whitespace
Remove trailing whitespace
(W291)
52-52: Trailing whitespace
Remove trailing whitespace
(W291)
56-56: Trailing whitespace
Remove trailing whitespace
(W291)
57-57: Trailing whitespace
Remove trailing whitespace
(W291)
58-58: Trailing whitespace
Remove trailing whitespace
(W291)
59-59: Trailing whitespace
Remove trailing whitespace
(W291)
64-64: Blank line contains whitespace
Remove whitespace from blank line
(W293)
80-80: Blank line contains whitespace
Remove whitespace from blank line
(W293)
84-84: Blank line contains whitespace
Remove whitespace from blank line
(W293)
88-88: Blank line contains whitespace
Remove whitespace from blank line
(W293)
97-97: Blank line contains whitespace
Remove whitespace from blank line
(W293)
99-99: Trailing whitespace
Remove trailing whitespace
(W291)
100-100: Trailing whitespace
Remove trailing whitespace
(W291)
103-103: Blank line contains whitespace
Remove whitespace from blank line
(W293)
107-107: Blank line contains whitespace
Remove whitespace from blank line
(W293)
110-110: Blank line contains whitespace
Remove whitespace from blank line
(W293)
116-116: Line too long (122 > 120)
(E501)
119-119: Blank line contains whitespace
Remove whitespace from blank line
(W293)
121-121: Trailing whitespace
Remove trailing whitespace
(W291)
122-122: Trailing whitespace
Remove trailing whitespace
(W291)
125-125: Blank line contains whitespace
Remove whitespace from blank line
(W293)
129-129: Blank line contains whitespace
Remove whitespace from blank line
(W293)
132-132: Blank line contains whitespace
Remove whitespace from blank line
(W293)
138-138: Unused function argument: messages_with_flow_ids
(ARG001)
141-141: Blank line contains whitespace
Remove whitespace from blank line
(W293)
143-143: Trailing whitespace
Remove trailing whitespace
(W291)
144-144: Trailing whitespace
Remove trailing whitespace
(W291)
147-147: Blank line contains whitespace
Remove whitespace from blank line
(W293)
158-158: Blank line contains whitespace
Remove whitespace from blank line
(W293)
166-166: Unused function argument: messages_with_flow_ids
(ARG001)
169-169: Trailing whitespace
Remove trailing whitespace
(W291)
170-170: Trailing whitespace
Remove trailing whitespace
(W291)
173-173: Blank line contains whitespace
Remove whitespace from blank line
(W293)
🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/base/langflow/api/v1/monitor.py
[failure] 54-54: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:54:1: W293 Blank line contains whitespace
[failure] 51-51: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:51:1: W293 Blank line contains whitespace
src/backend/tests/unit/test_session_endpoint.py
[failure] 29-29: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:29:29: W291 Trailing whitespace
[failure] 28-28: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:28:34: W291 Trailing whitespace
[failure] 24-24: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:24:40: W291 Trailing whitespace
[failure] 23-23: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:23:36: W291 Trailing whitespace
[failure] 22-22: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:22:31: W291 Trailing whitespace
[failure] 21-21: Ruff (W291)
src/backend/tests/unit/test_session_endpoint.py:21:34: W291 Trailing whitespace
[failure] 17-17: Ruff (W293)
src/backend/tests/unit/test_session_endpoint.py:17:1: W293 Blank line contains whitespace
[failure] 6-6: Ruff (F401)
src/backend/tests/unit/test_session_endpoint.py:6:55: F401 langflow.services.database.models.message.MessageCreate imported but unused
🪛 GitHub Actions: Ruff Style Check
src/backend/base/langflow/api/v1/monitor.py
[error] 51-51: W293 Blank line contains whitespace.
🪛 Pylint (3.3.7)
src/backend/tests/unit/test_session_endpoint.py
[error] 5-5: No name 'memory' in module 'langflow'
(E0611)
[error] 6-6: No name 'services' in module 'langflow'
(E0611)
[error] 7-7: No name 'services' in module 'langflow'
(E0611)
[error] 8-8: No name 'services' in module 'langflow'
(E0611)
🔇 Additional comments (15)
pyproject.toml (1)
229-246: I’ll check whether any integration tests still exist under the old or new paths.#!/bin/bash # List any files under tests/integration echo "Checking for files in tests/integration:" find . -type f -path "./tests/integration/*" || echo "None found." # List any files under src/backend/tests/integration echo "Checking for files in src/backend/tests/integration:" find . -type f -path "./src/backend/tests/integration/*" || echo "None found."src/frontend/src/customization/components/custom-new-modal.tsx (1)
1-1: Import path change looks goodSwitching to the new playground-aware modal aligns this thin wrapper with the updated session workflow. No further action needed.
src/frontend/src/controllers/API/helpers/constants.ts (1)
10-11: Constant added – verify backend route stability
SESSIONSmirrors the/monitor/sessionsendpoint added server-side. Confirm that:
- The backend route uses the same prefix (
monitor/sessions);- It is covered by CORS/auth policies identical to
MESSAGES.If both hold, the addition is perfect.
src/frontend/src/types/zustand/flow/index.ts (1)
288-290: Verify store implementation keeps type & runtime in syncTypes now expose
newChatOnPlaygroundandsetNewChatOnPlayground, but adding them only here will compile while the store implementation may still lack initial state or the setter. Please confirmsrc/frontend/src/stores/flowStore.ts(or equivalent) initializes:newChatOnPlayground: false, setNewChatOnPlayground: (val) => set({ newChatOnPlayground: val }),to avoid runtime
undefinederrors.src/frontend/src/controllers/API/queries/messages/use-get-sessions-from-flow.ts (1)
22-48: Align return type with AxiosResponse for playground branchWhen
isPlaygroundPageistrue,getSessionsFnreturns a plain object{ data: string[] }, whereas the non-playground branch returns anAxiosResponse.
This breaks type safety for consumers that rely on AxiosResponse fields (status,headers, etc.).Simplest fix: model a minimal Axios-like shape or wrap with the same interface.
// For playground mode, get sessions from sessionStorage @@ - return { - data: sessionIds, - }; + return { + data: sessionIds, + status: 200, + statusText: "OK", + headers: {}, + config: {}, + } as const;src/frontend/src/modals/IOModal/playground-modal.tsx (9)
7-14: Import changes look good.The new query hook import and React hooks import are properly structured.
48-54: State management addition is appropriate.The
newChatOnPlaygroundstate and setter follow the established pattern for flow store integration.
91-101: Sessions query hook is well implemented.The hook correctly fetches sessions for the current flow and is properly optimized with the
enabledflag.
102-112: Sessions initialization logic is robust.Good defensive programming by ensuring the currentFlowId is always included as a fallback session.
134-143: Session deletion handling is comprehensive.The logic properly handles edge cases and ensures consistent UI state after deletion.
177-188: Messages query properly integrates session filtering.The query correctly uses the visible session to filter messages.
306-314: Toggle function is well implemented.The session toggle logic provides good UX by allowing deselection.
315-334: Session change handling is optimized.Good use of initialization flag and ref to prevent unnecessary refetches while ensuring data stays in sync.
400-410: UI updates properly handle loading states.Good practice to wait for data before rendering dependent components.
Also applies to: 448-449
src/backend/tests/unit/test_session_endpoint.py (1)
154-163: Empty database test is appropriate.Good coverage of the edge case when no messages exist.
| export function encodeSessionId(session_id: string): string { | ||
| if (!session_id) return ""; | ||
| // Use encodeURIComponent to properly encode spaces, commas, colons, etc. | ||
| return encodeURIComponent(session_id); | ||
| } | ||
|
|
||
| /** | ||
| * Decodes a session ID from URL encoding | ||
| * @param {string} encoded_session_id - The URL-encoded session ID | ||
| * @returns {string} The decoded session ID | ||
| */ | ||
| export function decodeSessionId(encoded_session_id: string): string { | ||
| if (!encoded_session_id) return ""; | ||
| try { | ||
| return decodeURIComponent(encoded_session_id); | ||
| } catch (error) { | ||
| console.warn("Failed to decode session ID:", encoded_session_id, error); | ||
| return encoded_session_id; // Return as-is if decoding fails | ||
| } | ||
| } |
There was a problem hiding this comment.
decodeSessionId leaves “+” untouched – spaces remain encoded
encodeURIComponent(" ") yields %20, but some BE/FE stacks still produce + for spaces (application/x-www-form-urlencoded).
sessionIdFormatted treats the presence of + as a cue to decode, yet decodeURIComponent does not convert + to space, resulting in "Session+Jun+16,+15:44:08" leaking into the UI/API.
- return decodeURIComponent(encoded_session_id);
+ // replace plus with space before decoding to handle form-urlencoded inputs
+ return decodeURIComponent(encoded_session_id.replace(/\+/g, " "));This keeps behaviour symmetric with encodeSessionId.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function encodeSessionId(session_id: string): string { | |
| if (!session_id) return ""; | |
| // Use encodeURIComponent to properly encode spaces, commas, colons, etc. | |
| return encodeURIComponent(session_id); | |
| } | |
| /** | |
| * Decodes a session ID from URL encoding | |
| * @param {string} encoded_session_id - The URL-encoded session ID | |
| * @returns {string} The decoded session ID | |
| */ | |
| export function decodeSessionId(encoded_session_id: string): string { | |
| if (!encoded_session_id) return ""; | |
| try { | |
| return decodeURIComponent(encoded_session_id); | |
| } catch (error) { | |
| console.warn("Failed to decode session ID:", encoded_session_id, error); | |
| return encoded_session_id; // Return as-is if decoding fails | |
| } | |
| } | |
| export function decodeSessionId(encoded_session_id: string): string { | |
| if (!encoded_session_id) return ""; | |
| try { | |
| // replace plus with space before decoding to handle form-urlencoded inputs | |
| return decodeURIComponent(encoded_session_id.replace(/\+/g, " ")); | |
| } catch (error) { | |
| console.warn("Failed to decode session ID:", encoded_session_id, error); | |
| return encoded_session_id; // Return as-is if decoding fails | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/frontend/src/utils/utils.ts around lines 912 to 931, the decodeSessionId
function does not convert plus signs (+) to spaces, causing encoded spaces
represented as '+' to remain incorrectly decoded. To fix this, before calling
decodeURIComponent, replace all '+' characters in the input string with spaces,
ensuring proper decoding of spaces encoded as '+'. This will keep
decodeSessionId behavior symmetric with encodeSessionId and prevent '+' from
leaking into the UI or API.
| onSettled: () => { | ||
| queryClient.invalidateQueries({ | ||
| queryKey: ["useGetSessionsFromFlowQuery"], | ||
| }); | ||
| }, |
There was a problem hiding this comment.
Original onSettled supplied by callers is silently discarded
...options is spread before your custom onSettled, so any handler passed by consumers is overwritten and never executed—unlike the pattern used in useDeleteMessages.
- onSettled: () => {
- queryClient.invalidateQueries({
- queryKey: ["useGetSessionsFromFlowQuery"],
- });
- },
+ onSettled: (data, error, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: ["useGetSessionsFromFlowQuery"],
+ });
+ options?.onSettled?.(data, error, variables, context);
+ },Restoring the pass-through preserves backwards compatibility and prevents hidden regressions for callers that relied on their own onSettled logic.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onSettled: () => { | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| }, | |
| onSettled: (data, error, variables, context) => { | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| options?.onSettled?.(data, error, variables, context); | |
| }, |
🤖 Prompt for AI Agents
In src/frontend/src/controllers/API/queries/messages/use-rename-session.ts
around lines 51 to 55, the custom onSettled handler overwrites any onSettled
function passed by callers because options are spread before defining onSettled.
To fix this, modify the onSettled handler to call the original onSettled from
options if it exists, ensuring both the custom logic and the caller's onSettled
are executed, preserving backward compatibility and preventing silent discarding
of caller handlers.
| > = mutate(["useDeleteMessages"], deleteMessage, { | ||
| ...options, | ||
| onSettled: (data, error, variables, context) => { | ||
| // Invalidate sessions query to refetch the updated session list | ||
| queryClient.invalidateQueries({ | ||
| queryKey: ["useGetSessionsFromFlowQuery"], | ||
| }); | ||
| // Call the original onSettled if provided | ||
| options?.onSettled?.(data, error, variables, context); | ||
| }, | ||
| }); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Return-type generic is wrong after refactor
UseMutationResult is parametrised <TData, TError, TVariables>.
The mutation resolves undefined (line 17 returns response.data, but hook signature advertises undefined), yet the generic is DeleteMessagesParams. This mismatch leaks to consumers.
- const mutation: UseMutationResult<
- DeleteMessagesParams,
- any,
- DeleteMessagesParams
+ const mutation: UseMutationResult<
+ undefined,
+ any,
+ DeleteMessagesParams
> = mutate(Aligning the generics avoids incorrect type inference downstream.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| > = mutate(["useDeleteMessages"], deleteMessage, { | |
| ...options, | |
| onSettled: (data, error, variables, context) => { | |
| // Invalidate sessions query to refetch the updated session list | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| // Call the original onSettled if provided | |
| options?.onSettled?.(data, error, variables, context); | |
| }, | |
| }); | |
| const mutation: UseMutationResult< | |
| undefined, | |
| any, | |
| DeleteMessagesParams | |
| > = mutate( | |
| ["useDeleteMessages"], deleteMessage, { | |
| ...options, | |
| onSettled: (data, error, variables, context) => { | |
| // Invalidate sessions query to refetch the updated session list | |
| queryClient.invalidateQueries({ | |
| queryKey: ["useGetSessionsFromFlowQuery"], | |
| }); | |
| // Call the original onSettled if provided | |
| options?.onSettled?.(data, error, variables, context); | |
| }, | |
| } | |
| ); |
🤖 Prompt for AI Agents
In src/frontend/src/controllers/API/queries/messages/use-delete-messages.ts
between lines 29 and 39, the generic parameters for UseMutationResult are
incorrectly set, causing a type mismatch where the mutation resolves undefined
but the generic is DeleteMessagesParams. To fix this, update the
UseMutationResult generic parameters to correctly reflect the mutation's
resolved data type as undefined, the error type, and the variables type,
ensuring proper type inference for consumers.
| stmt = select(MessageTable.session_id).distinct() | ||
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | ||
|
|
||
| if flow_id: | ||
| stmt = stmt.where(MessageTable.flow_id == flow_id) | ||
|
|
||
| sessions = await session.exec(stmt) | ||
| return list(sessions) | ||
| except Exception as e: |
There was a problem hiding this comment.
/sessions endpoint returns Row objects instead of plain strings
session.exec() yields SQLAlchemy/SQLModel Result rows.
Casting this straight to list() produces a list of Row objects (e.g. (<session_id>,)), not the raw str values the caller expects.
- sessions = await session.exec(stmt)
- return list(sessions)
+ # Fetch *scalar* values to obtain plain strings
+ sessions = (await session.exec(stmt)).scalars().all()
+ return sessionsWithout this change the frontend receives an array of objects it cannot render/parse.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| stmt = select(MessageTable.session_id).distinct() | |
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | |
| if flow_id: | |
| stmt = stmt.where(MessageTable.flow_id == flow_id) | |
| sessions = await session.exec(stmt) | |
| return list(sessions) | |
| except Exception as e: | |
| stmt = select(MessageTable.session_id).distinct() | |
| stmt = stmt.where(MessageTable.session_id.isnot(None)) | |
| if flow_id: | |
| stmt = stmt.where(MessageTable.flow_id == flow_id) | |
| # Fetch *scalar* values to obtain plain strings | |
| sessions = (await session.exec(stmt)).scalars().all() | |
| return sessions | |
| except Exception as e: |
🧰 Tools
🪛 Ruff (0.11.9)
51-51: Blank line contains whitespace
Remove whitespace from blank line
(W293)
54-54: Blank line contains whitespace
Remove whitespace from blank line
(W293)
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 54-54: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:54:1: W293 Blank line contains whitespace
[failure] 51-51: Ruff (W293)
src/backend/base/langflow/api/v1/monitor.py:51:1: W293 Blank line contains whitespace
🪛 GitHub Actions: Ruff Style Check
[error] 51-51: W293 Blank line contains whitespace.
🤖 Prompt for AI Agents
In src/backend/base/langflow/api/v1/monitor.py around lines 49 to 57, the
/sessions endpoint returns a list of Row objects instead of plain session_id
strings because session.exec(stmt) yields Result rows. To fix this, extract the
session_id values from each Row before returning by iterating over the results
and collecting the first element of each Row into a list, then return that list
of strings.
| if (newChatOnPlayground && !sessionsLoading) { | ||
| const handleRefetchAndSetSession = async () => { | ||
| try { | ||
| const result = await refetchSessions(); | ||
| if (result.data?.sessions && result.data.sessions.length > 0) { | ||
| setvisibleSession( | ||
| result.data.sessions[result.data.sessions.length - 1], | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error refetching sessions:", error); | ||
| } | ||
| }; | ||
|
|
||
| handleRefetchAndSetSession(); | ||
| setNewChatOnPlayground(false); | ||
| } | ||
| }, [messages]); |
There was a problem hiding this comment.
Remove unused dependency from useEffect.
The effect doesn't use messages but includes it in the dependency array. This could cause unnecessary re-runs.
- }, [messages]);
+ }, [newChatOnPlayground, sessionsLoading, refetchSessions, setvisibleSession, setNewChatOnPlayground]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (newChatOnPlayground && !sessionsLoading) { | |
| const handleRefetchAndSetSession = async () => { | |
| try { | |
| const result = await refetchSessions(); | |
| if (result.data?.sessions && result.data.sessions.length > 0) { | |
| setvisibleSession( | |
| result.data.sessions[result.data.sessions.length - 1], | |
| ); | |
| } | |
| } catch (error) { | |
| console.error("Error refetching sessions:", error); | |
| } | |
| }; | |
| handleRefetchAndSetSession(); | |
| setNewChatOnPlayground(false); | |
| } | |
| }, [messages]); | |
| if (newChatOnPlayground && !sessionsLoading) { | |
| const handleRefetchAndSetSession = async () => { | |
| try { | |
| const result = await refetchSessions(); | |
| if (result.data?.sessions && result.data.sessions.length > 0) { | |
| setvisibleSession( | |
| result.data.sessions[result.data.sessions.length - 1], | |
| ); | |
| } | |
| } catch (error) { | |
| console.error("Error refetching sessions:", error); | |
| } | |
| }; | |
| handleRefetchAndSetSession(); | |
| setNewChatOnPlayground(false); | |
| } | |
| }, [newChatOnPlayground, sessionsLoading, refetchSessions, setvisibleSession, setNewChatOnPlayground]); |
🤖 Prompt for AI Agents
In src/frontend/src/modals/IOModal/playground-modal.tsx around lines 220 to 237,
the useEffect hook includes 'messages' in its dependency array but does not
actually use it inside the effect, causing unnecessary re-runs. Remove
'messages' from the dependency array to ensure the effect only runs when
necessary based on the actual dependencies used within it.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
| from uuid import uuid4 | ||
|
|
||
| import pytest | ||
| from httpx import AsyncClient | ||
| from langflow.memory import aadd_messagetables | ||
| from langflow.services.database.models.message import MessageCreate | ||
| from langflow.services.database.models.message.model import MessageTable | ||
| from langflow.services.deps import session_scope | ||
|
|
There was a problem hiding this comment.
Remove unused import.
MessageCreate is imported but not used in the code.
-from langflow.services.database.models.message import MessageCreate
from langflow.services.database.models.message.model import MessageTable📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from uuid import uuid4 | |
| import pytest | |
| from httpx import AsyncClient | |
| from langflow.memory import aadd_messagetables | |
| from langflow.services.database.models.message import MessageCreate | |
| from langflow.services.database.models.message.model import MessageTable | |
| from langflow.services.deps import session_scope | |
| from uuid import uuid4 | |
| import pytest | |
| from httpx import AsyncClient | |
| from langflow.memory import aadd_messagetables | |
| from langflow.services.database.models.message.model import MessageTable | |
| from langflow.services.deps import session_scope |
🧰 Tools
🪛 Ruff (0.11.9)
6-6: langflow.services.database.models.message.MessageCreate imported but unused
Remove unused import: langflow.services.database.models.message.MessageCreate
(F401)
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 6-6: Ruff (F401)
src/backend/tests/unit/test_session_endpoint.py:6:55: F401 langflow.services.database.models.message.MessageCreate imported but unused
🪛 Pylint (3.3.7)
[error] 5-5: No name 'memory' in module 'langflow'
(E0611)
[error] 6-6: No name 'services' in module 'langflow'
(E0611)
[error] 7-7: No name 'services' in module 'langflow'
(E0611)
[error] 8-8: No name 'services' in module 'langflow'
(E0611)
🤖 Prompt for AI Agents
In src/backend/tests/unit/test_session_endpoint.py at lines 1 to 9, the import
of MessageCreate is unused. Remove the import statement for MessageCreate to
clean up the code and avoid unnecessary imports.
| @pytest.mark.api_key_required | ||
| async def test_get_sessions_with_different_flow_id_filter(client: AsyncClient, logged_in_headers, messages_with_flow_ids): | ||
| """Test getting sessions filtered by a different flow_id.""" | ||
| flow_id_2 = messages_with_flow_ids["flow_id_2"] | ||
|
|
||
| response = await client.get( | ||
| "api/v1/monitor/sessions", | ||
| params={"flow_id": str(flow_id_2)}, | ||
| headers=logged_in_headers | ||
| ) | ||
|
|
||
| assert response.status_code == 200, response.text | ||
| sessions = response.json() | ||
| assert isinstance(sessions, list) | ||
|
|
||
| returned_sessions = set(sessions) | ||
| expected_sessions = messages_with_flow_ids["expected_sessions_flow_2"] | ||
|
|
||
| assert returned_sessions == expected_sessions | ||
| assert len(sessions) == len(expected_sessions) | ||
|
|
There was a problem hiding this comment.
Fix line length issue.
Line 116 exceeds the 120 character limit. Also clean up formatting.
-async def test_get_sessions_with_different_flow_id_filter(client: AsyncClient, logged_in_headers, messages_with_flow_ids):
+async def test_get_sessions_with_different_flow_id_filter(
+ client: AsyncClient, logged_in_headers, messages_with_flow_ids
+):📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @pytest.mark.api_key_required | |
| async def test_get_sessions_with_different_flow_id_filter(client: AsyncClient, logged_in_headers, messages_with_flow_ids): | |
| """Test getting sessions filtered by a different flow_id.""" | |
| flow_id_2 = messages_with_flow_ids["flow_id_2"] | |
| response = await client.get( | |
| "api/v1/monitor/sessions", | |
| params={"flow_id": str(flow_id_2)}, | |
| headers=logged_in_headers | |
| ) | |
| assert response.status_code == 200, response.text | |
| sessions = response.json() | |
| assert isinstance(sessions, list) | |
| returned_sessions = set(sessions) | |
| expected_sessions = messages_with_flow_ids["expected_sessions_flow_2"] | |
| assert returned_sessions == expected_sessions | |
| assert len(sessions) == len(expected_sessions) | |
| @pytest.mark.api_key_required | |
| async def test_get_sessions_with_different_flow_id_filter( | |
| client: AsyncClient, logged_in_headers, messages_with_flow_ids | |
| ): | |
| """Test getting sessions filtered by a different flow_id.""" | |
| flow_id_2 = messages_with_flow_ids["flow_id_2"] | |
| response = await client.get( | |
| "api/v1/monitor/sessions", | |
| params={"flow_id": str(flow_id_2)}, | |
| headers=logged_in_headers | |
| ) | |
| assert response.status_code == 200, response.text | |
| sessions = response.json() | |
| assert isinstance(sessions, list) | |
| returned_sessions = set(sessions) | |
| expected_sessions = messages_with_flow_ids["expected_sessions_flow_2"] | |
| assert returned_sessions == expected_sessions | |
| assert len(sessions) == len(expected_sessions) |
🧰 Tools
🪛 Ruff (0.11.9)
116-116: Line too long (122 > 120)
(E501)
119-119: Blank line contains whitespace
Remove whitespace from blank line
(W293)
121-121: Trailing whitespace
Remove trailing whitespace
(W291)
122-122: Trailing whitespace
Remove trailing whitespace
(W291)
125-125: Blank line contains whitespace
Remove whitespace from blank line
(W293)
129-129: Blank line contains whitespace
Remove whitespace from blank line
(W293)
132-132: Blank line contains whitespace
Remove whitespace from blank line
(W293)
🤖 Prompt for AI Agents
In src/backend/tests/unit/test_session_endpoint.py around lines 115 to 135, line
116 exceeds the 120 character limit. Break the long line into multiple shorter
lines to comply with the line length restriction and improve readability. Also,
adjust the surrounding formatting to maintain consistent indentation and style.
39c6364 to
041df22
Compare
📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py
…t_message_sessions function
* 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
* Update Vector Store RAG.json * fix: make starter projects auto refactor not remove selected output (#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (#8490) * update templates * update templates * First round of template updates * Update templates * fix: Update SaaS, Social Media, and YouTube json file (#8441) * update SaaS, Social Media, and YouTube json file * fix: make starter projects auto refactor not remove selected output (#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (#8490) * update json * fix custom component * revert change --------- Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> * fix: templates (#8499) * basic-prompting-template-updated * show-system-message * names * blog-writer-tested * financial-report-parser * image-sentiment-analysis * seo-keyword-generator * seo-keyword-generator * Merge branch 'fix-vector-search-template' into mendons-template-branch --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> * Update Basic Prompting.json * Update Blog Writer.json * Further template updates * Update Image Sentiment Analysis.json * Update templates * Update Financial Report Parser.json * Update Market Research.json * Update Market Research.json * update several templates * Update Image Sentiment Analysis.json * Update Market Research.json * Update image sentiment analysis template * Update Market Research.json * Update Custom Component Maker.json * Update Custom Component Maker.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * More template updates * Update Financial Report Parser.json * updated templates * change custom component maker * Update Twitter Thread Generator.json * updates from main * change model * Update Research Translation Loop.json * expanded output component to fix tests * update template * autofix * fix error * fix change back * change back * ci: Skip truncated values test for refactoring (#8670) * refactor: simplify init target by removing cache cleanup and adding pre-commit hook (#8590) * build: add pyyaml dependency * refactor: simplify init command by removing cache cleaning and langflow run call * refactor: simplify init target by removing cache cleanup and adding pre-commit hook * refactor: update langchain_core.prompts import paths to use specific modules --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * feat: update structured output to multiline input and revise system prompt (#8585) * Update structured_output.py * [autofix.ci] apply automated fixes * Update structured_output.py * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * update to prompt * template updates * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: add sessions endpoint with session management enhancements (#8596) * 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: implemented cached values and temporary MCP servers on MCP component (#8628) * Added actionCount to fetch only servers without actionCount * Updated queries and uses to use servers without action data first, and then to fetch them * removed comment * updated constants * Added loading dropdown * Make options persist * Implemented new value format for McpComponent and implemented saving and removing temp Mcp Server if config is existent * Changed value type * Implemented cache and saving the server config * Fixed mcp server test * fix backend formatting * fixed lint * Added await * Fixed save button not appearing when no servers are available * added condition to only show save button when options is not null * template autofix * change template * update text sentiment analysis * change basic prompt back * change image sentiment back * update text sentiment and twitter * Update Twitter Thread Generator.json * Add back the input for the chat * add change * fix text sentiment * update research translation * Update Research Translation Loop.json --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…gflow-ai#8596) * 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
* Update Vector Store RAG.json * fix: make starter projects auto refactor not remove selected output (langflow-ai#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (langflow-ai#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (langflow-ai#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (langflow-ai#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (langflow-ai#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (langflow-ai#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (langflow-ai#8490) * update templates * update templates * First round of template updates * Update templates * fix: Update SaaS, Social Media, and YouTube json file (langflow-ai#8441) * update SaaS, Social Media, and YouTube json file * fix: make starter projects auto refactor not remove selected output (langflow-ai#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (langflow-ai#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (langflow-ai#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (langflow-ai#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (langflow-ai#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (langflow-ai#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (langflow-ai#8490) * update json * fix custom component * revert change --------- Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> * fix: templates (langflow-ai#8499) * basic-prompting-template-updated * show-system-message * names * blog-writer-tested * financial-report-parser * image-sentiment-analysis * seo-keyword-generator * seo-keyword-generator * Merge branch 'fix-vector-search-template' into mendons-template-branch --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> * Update Basic Prompting.json * Update Blog Writer.json * Further template updates * Update Image Sentiment Analysis.json * Update templates * Update Financial Report Parser.json * Update Market Research.json * Update Market Research.json * update several templates * Update Image Sentiment Analysis.json * Update Market Research.json * Update image sentiment analysis template * Update Market Research.json * Update Custom Component Maker.json * Update Custom Component Maker.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * More template updates * Update Financial Report Parser.json * updated templates * change custom component maker * Update Twitter Thread Generator.json * updates from main * change model * Update Research Translation Loop.json * expanded output component to fix tests * update template * autofix * fix error * fix change back * change back * ci: Skip truncated values test for refactoring (langflow-ai#8670) * refactor: simplify init target by removing cache cleanup and adding pre-commit hook (langflow-ai#8590) * build: add pyyaml dependency * refactor: simplify init command by removing cache cleaning and langflow run call * refactor: simplify init target by removing cache cleanup and adding pre-commit hook * refactor: update langchain_core.prompts import paths to use specific modules --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * feat: update structured output to multiline input and revise system prompt (langflow-ai#8585) * Update structured_output.py * [autofix.ci] apply automated fixes * Update structured_output.py * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * update to prompt * template updates * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: add sessions endpoint with session management enhancements (langflow-ai#8596) * 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: implemented cached values and temporary MCP servers on MCP component (langflow-ai#8628) * Added actionCount to fetch only servers without actionCount * Updated queries and uses to use servers without action data first, and then to fetch them * removed comment * updated constants * Added loading dropdown * Make options persist * Implemented new value format for McpComponent and implemented saving and removing temp Mcp Server if config is existent * Changed value type * Implemented cache and saving the server config * Fixed mcp server test * fix backend formatting * fixed lint * Added await * Fixed save button not appearing when no servers are available * added condition to only show save button when options is not null * template autofix * change template * update text sentiment analysis * change basic prompt back * change image sentiment back * update text sentiment and twitter * Update Twitter Thread Generator.json * Add back the input for the chat * add change * fix text sentiment * update research translation * Update Research Translation Loop.json --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
…gflow-ai#8596) * 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
* Update Vector Store RAG.json * fix: make starter projects auto refactor not remove selected output (langflow-ai#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (langflow-ai#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (langflow-ai#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (langflow-ai#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (langflow-ai#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (langflow-ai#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (langflow-ai#8490) * update templates * update templates * First round of template updates * Update templates * fix: Update SaaS, Social Media, and YouTube json file (langflow-ai#8441) * update SaaS, Social Media, and YouTube json file * fix: make starter projects auto refactor not remove selected output (langflow-ai#8400) * Fixed bug where starter projects were refactored incorrectly * fix: improve handling of selected outputs in custom component template builder - Added checks to ensure selected output is valid before attempting to set its state. - Enhanced code readability with comments explaining the logic for selecting outputs. * Set selected output as the previous selected output * Update base.py --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * fix: made clean edges clean after changing dropdown of output (langflow-ai#8460) fixed output considering all outputs not just selected one * refactor(docker): remove --extra deploy flag from uv sync commands (langflow-ai#8485) 🔧 (build_and_push_with_extras.Dockerfile): remove unnecessary uv sync command options to improve build efficiency and reduce redundancy Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: refactor mcp and freeze tests to be less prone to flaky results (langflow-ai#8486) * Fixed mcp test to be less prone to errors * Fix freeze spec * fix: made button disabled state more congruent, made edit flow details submit on enter (langflow-ai#8339) * Changed textarea classes * Changed flowsettingscomponent to use form * changed edit flow settings to use form and to submit on enter * Reset form data on close * Updated disabled state to have lower opacity instead of to have set background * Fixed loading state of button * Fix: chat memory store issue and fix output types (langflow-ai#8463) * fix chat memory * update template * update update outputs * update update outputs --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * ci: update setup-uv to possibly fix caching (langflow-ai#8490) * update json * fix custom component * revert change --------- Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> * fix: templates (langflow-ai#8499) * basic-prompting-template-updated * show-system-message * names * blog-writer-tested * financial-report-parser * image-sentiment-analysis * seo-keyword-generator * seo-keyword-generator * Merge branch 'fix-vector-search-template' into mendons-template-branch --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> * Update Basic Prompting.json * Update Blog Writer.json * Further template updates * Update Image Sentiment Analysis.json * Update templates * Update Financial Report Parser.json * Update Market Research.json * Update Market Research.json * update several templates * Update Image Sentiment Analysis.json * Update Market Research.json * Update image sentiment analysis template * Update Market Research.json * Update Custom Component Maker.json * Update Custom Component Maker.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * Update Hybrid Search RAG.json * More template updates * Update Financial Report Parser.json * updated templates * change custom component maker * Update Twitter Thread Generator.json * updates from main * change model * Update Research Translation Loop.json * expanded output component to fix tests * update template * autofix * fix error * fix change back * change back * ci: Skip truncated values test for refactoring (langflow-ai#8670) * refactor: simplify init target by removing cache cleanup and adding pre-commit hook (langflow-ai#8590) * build: add pyyaml dependency * refactor: simplify init command by removing cache cleaning and langflow run call * refactor: simplify init target by removing cache cleanup and adding pre-commit hook * refactor: update langchain_core.prompts import paths to use specific modules --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com> * feat: update structured output to multiline input and revise system prompt (langflow-ai#8585) * Update structured_output.py * [autofix.ci] apply automated fixes * Update structured_output.py * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * update to prompt * template updates * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * Update src/backend/base/langflow/components/processing/structured_output.py * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * feat: add sessions endpoint with session management enhancements (langflow-ai#8596) * 📝 (monitor.py): Add endpoint to get sessions and handle session_id encoding for API requests 📝 (use-get-messages-mutation.ts): Implement a mutation function to fetch messages with query parameters and handle session_id encoding for API requests 📝 (use-get-messages-polling.ts): Ensure proper encoding of session_id for API requests in polling mutation 📝 (use-get-messages.ts): Handle session_id encoding for API requests in messages query 📝 (new-modal.tsx): Implement functions to handle session deletion and proper encoding of session_id for API requests 📝 (utils.ts): Add functions to encode, decode, validate, format, and prepare session IDs for API requests * 📝 (constants.ts): Add SESSIONS constant to API URLs for monitoring sessions 🔧 (use-delete-messages.ts): Add queryClient to UseRequestProcessor to invalidate sessions query ✨ (use-get-sessions-from-flow.ts): Introduce useGetSessionsFromFlowQuery to fetch sessions from flow 🔧 (use-rename-session.ts): Change refetchQueries to invalidateQueries for useGetSessionsFromFlowQuery 🔧 (custom-new-modal.tsx): Update import path for IOModal to playground-modal 🔧 (session-selector.tsx): Add setActiveSession function to handle setting active session 🔧 (sidebar-open-view.tsx): Add setActiveSession function to handle setting active session ♻️ (new-modal.tsx): Refactor IOModal into playground-modal and update functionality ♻️ (playground-modal.tsx): Refactor IOModal to handle playground-specific functionality ⬆️ (flowStore.ts): Add newChatOnPlayground state and setNewChatOnPlayground function ⬆️ (index.ts): Update FlowStoreType to include newChatOnPlayground and setNewChatOnPlayground * 🔧 (pyproject.toml): update testpaths to point to the correct directory for tests ✨ (test_session_endpoint.py): add unit tests for sessions endpoint with flow_id filtering ♻️ (session-selector.tsx): refactor to trim editedSession before setting it ♻️ (sidebar-open-view.tsx): refactor to set visibleSession instead of activeSession * ✨ (use-get-sessions-from-flow.ts): Always include the flow ID as the default session if it's not already present ♻️ (playground-modal.tsx): Refactor setting sessions to include currentFlowId as the default session if not present, and handle visibility of sessions more efficiently * ♻️ (use-get-messages-mutation.ts): remove unused imports and refactor code for better readability and maintainability * ✨ (test_session_endpoint.py): refactor test function names for better clarity and consistency * ✨ (create-new-session-name.ts): add function to generate a new session name based on the current date and time 🔧 (playground-modal.tsx): import createNewSessionName function to dynamically set a new session name when no session is visible * [autofix.ci] apply automated fixes * ✨ (monitor.py): rename get_sessions endpoint to get_message_sessions for clarity and consistency 🔧 (constants.ts): remove unused SESSIONS constant from API URLs 🔧 (use-delete-messages.ts): remove commented out code and unnecessary comments ✨ (use-delete-sessions.ts): add functionality to delete sessions in frontend 🔧 (use-get-sessions-from-flow.ts): update API endpoint for getting sessions to match backend changes 🔧 (playground-modal.tsx): add functionality to delete sessions and associated messages in the UI, update UI optimistically, and handle errors appropriately * [autofix.ci] apply automated fixes * 🐛 (monitor.py): Fix type hinting issue in delete_messages function 📝 (monitor.py): Add comments and improve readability in test_messages_endpoints.py 📝 (session_endpoint.py): Update endpoint paths for consistency and clarity in test_session_endpoint.py * [autofix.ci] apply automated fixes * fix: update SQL statement to use col() for session_id filtering in get_message_sessions function --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * fix: implemented cached values and temporary MCP servers on MCP component (langflow-ai#8628) * Added actionCount to fetch only servers without actionCount * Updated queries and uses to use servers without action data first, and then to fetch them * removed comment * updated constants * Added loading dropdown * Make options persist * Implemented new value format for McpComponent and implemented saving and removing temp Mcp Server if config is existent * Changed value type * Implemented cache and saving the server config * Fixed mcp server test * fix backend formatting * fixed lint * Added await * Fixed save button not appearing when no servers are available * added condition to only show save button when options is not null * template autofix * change template * update text sentiment analysis * change basic prompt back * change image sentiment back * update text sentiment and twitter * Update Twitter Thread Generator.json * Add back the input for the chat * add change * fix text sentiment * update research translation * Update Research Translation Loop.json --------- Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Edwin Jose <edwin.jose@datastax.com> Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: Mendon Kissling <59585235+mendonk@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This pull request introduces several backend and frontend changes to enhance session management and improve API functionality. Key updates include the addition of a new
/sessionsendpoint, encoding improvements for session IDs, and frontend adjustments to support session-related operations. Below is a categorized list of the most important changes:Backend Enhancements:
/sessionsEndpoint: Added a new endpoint insrc/backend/base/langflow/api/v1/monitor.pyto retrieve distinct session IDs, optionally filtered byflow_id. This improves session management capabilities.get_messagesinsrc/backend/base/langflow/api/v1/monitor.pyto decodesession_idusingurllib.parse.unquote, ensuring proper handling of encoded session IDs./sessionsEndpoint: Added comprehensive tests insrc/backend/tests/unit/test_session_endpoint.pyto validate the/sessionsendpoint, including scenarios for filtering byflow_id, handling empty databases, and invalidflow_idformats.Frontend Enhancements:
SESSIONSinsrc/frontend/src/controllers/API/helpers/constants.tsto represent the/sessionsendpoint.useDeleteMessagesinsrc/frontend/src/controllers/API/queries/messages/use-delete-messages.tsto invalidate the sessions query after message deletion, ensuring the session list stays up-to-date.SessionSelectorinsrc/frontend/src/modals/IOModal/components/IOFieldView/components/session-selector.tsxto handle session trimming and integrate with playground-specific session management. [1] [2]API Improvements:
use-get-messages,use-get-messages-polling, anduse-get-messages-mutation) to ensure proper encoding ofsession_idusingprepareSessionIdForAPI. [1] [2] [3]useGetSessionsFromFlowQueryinsrc/frontend/src/controllers/API/queries/messages/use-get-sessions-from-flow.tsto fetch sessions associated with a specificflow_id.These changes collectively improve the system's handling of sessions, streamline API interactions, and enhance the user experience on the frontend.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores