Repository navigation
Conversation
The knowledge base, agent and space lists always open with "Recently
updated", so users who prefer another order have to pick it again on
every visit.
Store the chosen sort as a per-user UI preference through
preferenceStorage (WeKnora_${userId}_resource_sort_${list}) and restore
it when the list opens. Each list keeps its own choice, the choice
follows the user across spaces in the same browser, and accounts that
share a browser do not inherit each other's choice. Unknown stored
values fall back to the default sort.
Remembering one sort per user carried a choice made in one workspace
into every other workspace. Scope the stored preference by workspace as
well, the same way useResourcePins scopes recents
(WeKnora_${userId}_t${tenantId}_resource_sort_${list}), and read or
write nothing until the workspace id is known so no choice is shared
across workspaces.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The knowledge base, agent and space lists always open sorted by "Recently updated". Users who prefer another order (for example by name) have to pick it again every time they open the list. This PR remembers the chosen sort per workspace and restores it on the next visit.
frontend/src/utils/resourceSortPreference.tsloads and saves the choice through the existingpreferenceStoragehelpers, with the same user and workspace scoping thatuseResourcePinsuses for recents:WeKnora_${userId}_t${tenantId}_resource_sort_${list}.KnowledgeBaseList.vue,AgentList.vueandOrganizationList.vueinitialiseselectedResourceSortfrom the stored value forauthStore.effectiveTenantIdand save it when it changes (two lines each). Switching workspace reloads the page, so the list picks up that workspace's choice.Behaviour:
knowledge_bases,agents,organizations), so sorting knowledge bases by name does not change the agent list.DEFAULT_RESOURCE_SORT, so the default for first-time users is unchanged.preferenceStoragealready swallows those errors.Type of Change
Related Issue
None.
Testing
The first version remembered one sort per user for all workspaces. Testing on our deployment showed that a sort chosen in one workspace then applied in every other workspace, which is not what users expected, so the second commit scopes it per workspace.
Added
resourceSortPreference.test.ts(8 tests): default when nothing is stored, round trip, unknown stored values fall back to the default, workspaces are independent, nothing is read or written without a workspace id, lists are independent, accounts on the same browser are isolated, and unavailable storage neither throws nor leaks a value. It fails againstmain(module missing) and passes with this change;resourceSorting.test.tsstill passes.I also compiled the three changed SFCs with
@vue/compiler-sfc3.5 and type-checked the new module withtsc --strict. I could not runtype-check,buildor the full test suite locally, becausenpm ciis blocked here by a policy on remote tarballs (xlsxfrom cdn.sheetjs.com), so those are left to CI.git diff --checkis clean.Checklist
git diff --check origin/main...HEADpasseswebsite-docs/, Swagger annotations, etc.) (not needed)Screenshots / Recordings
No visual change: the sort control looks the same, it just opens with the previously chosen option. I will add a short recording once it has been checked on our deployment.