mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(sidebar): re-ordering based on last edit is confusing (#1248)
This commit is contained in:
committed by
GitHub
parent
57c98d86ba
commit
e31627c7c2
@@ -1101,21 +1101,11 @@ export function ControlBar({ hasValidationErrors = false }: ControlBarProps) {
|
||||
* Get workflows in the exact order they appear in the sidebar
|
||||
*/
|
||||
const getSidebarOrderedWorkflows = () => {
|
||||
// Get and sort regular workflows by last modified (newest first)
|
||||
// Get and sort regular workflows by name alphabetically for stable ordering
|
||||
const regularWorkflows = Object.values(workflows)
|
||||
.filter((workflow) => workflow.workspaceId === workspaceId)
|
||||
.filter((workflow) => workflow.marketplaceData?.status !== 'temp')
|
||||
.sort((a, b) => {
|
||||
const dateA =
|
||||
a.lastModified instanceof Date
|
||||
? a.lastModified.getTime()
|
||||
: new Date(a.lastModified).getTime()
|
||||
const dateB =
|
||||
b.lastModified instanceof Date
|
||||
? b.lastModified.getTime()
|
||||
: new Date(b.lastModified).getTime()
|
||||
return dateB - dateA
|
||||
})
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
|
||||
// Group workflows by folder
|
||||
const workflowsByFolder = regularWorkflows.reduce(
|
||||
|
||||
@@ -393,11 +393,9 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
|
||||
const workspaceFiltered = items.filter(
|
||||
(w: any) => w.workspaceId === workspaceId || !w.workspaceId
|
||||
)
|
||||
// Sort by last modified/updated (newest first), matching sidebar behavior
|
||||
// Sort by name alphabetically for stable ordering, matching sidebar behavior
|
||||
const sorted = [...workspaceFiltered].sort((a: any, b: any) => {
|
||||
const ta = new Date(a.lastModified || a.updatedAt || a.createdAt || 0).getTime()
|
||||
const tb = new Date(b.lastModified || b.updatedAt || b.createdAt || 0).getTime()
|
||||
return tb - ta
|
||||
return (a.name || 'Untitled Workflow').localeCompare(b.name || 'Untitled Workflow')
|
||||
})
|
||||
setWorkflows(
|
||||
sorted.map((w: any) => ({
|
||||
|
||||
@@ -691,21 +691,13 @@ export function Sidebar() {
|
||||
}
|
||||
})
|
||||
|
||||
// Sort by last modified date (newest first)
|
||||
const sortByLastModified = (a: WorkflowMetadata, b: WorkflowMetadata) => {
|
||||
const dateA =
|
||||
a.lastModified instanceof Date
|
||||
? a.lastModified.getTime()
|
||||
: new Date(a.lastModified).getTime()
|
||||
const dateB =
|
||||
b.lastModified instanceof Date
|
||||
? b.lastModified.getTime()
|
||||
: new Date(b.lastModified).getTime()
|
||||
return dateB - dateA
|
||||
// Sort by name alphabetically for stable ordering
|
||||
const sortByName = (a: WorkflowMetadata, b: WorkflowMetadata) => {
|
||||
return a.name.localeCompare(b.name)
|
||||
}
|
||||
|
||||
regular.sort(sortByLastModified)
|
||||
temp.sort(sortByLastModified)
|
||||
regular.sort(sortByName)
|
||||
temp.sort(sortByName)
|
||||
}
|
||||
|
||||
return { regularWorkflows: regular, tempWorkflows: temp }
|
||||
|
||||
Reference in New Issue
Block a user