Repository navigation
feat(computers): rack overview filter/sort/group logic (web parity, step 1 of #60) - #4540
Open
stamp-build[bot] wants to merge 1 commit into
Open
stamp-build[bot] wants to merge 1 commit into
stamp-build[bot] wants to merge 1 commit into
Conversation
…tep 1 of #60) Port the web Computers rack toolbar logic into shared as pure code: search, Status and Runtime filters, Group (none / name prefix / provider) with its group order, Sort (name, runtime remaining, disk, memory) with its tie-breakers, Clear all, and the Offline section split. Group, Sort and View persist through a shared repository over SharedPreferenceStore; search, Status and Runtime are session-only and reset on another server. Decode the machine row's nullable hostProvider. No UI changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Step 1 of #proj-mobile:#60 (Computers rack overview, web parity, 1.24): the web's toolbar logic is ported into
compose/sharedas pure, tested code. The UI does not change. The toolbar, list body and strings are steps 2 and 3. There is no changeset because nothing user-visible ships in this PR; the UI PR will add it.Web source of truth:
botiverse/slockorigin/staging@fabcd51b4. This is newer than the spec's194e5d3; see the spec gaps below. Paths are relative topackages/web/src/.What's added
RaftComputersRackFilters.kt(next toRaftSettingsComputersModel.kt): the pure functions, the toolbar state andRaftComputersRackToolbarStore.data/ComputersRackPreferences.kt: theComputersRackGroupByandComputersRackSort*types, plusKeyValueComputersRackPreferenceRepositoryoverSharedPreferenceStore. It stores Group (computers:rackGroup) and Sort (computers:rackSort, the web's JSON shape). View is delegated to the existingKeyValueComputersRackViewPreferenceRepository(computers:rackView).hostProvider(nullable) is carried throughComputerDto→ComputerSummary→SettingsComputerSnapshotand the durable cache. The field name was checked againstpackages/server/src/services/machineReadModel.ts:163(hostProvider: isHostProvider(machine.hostProvider) ? machine.hostProvider : null),packages/server/src/db/schema.ts:6481(host_provider) andpackages/shared/src/index.ts:2038-2056(HOST_PROVIDER_LABELS,isHostProvider).Rules → web reference
ownerUserIdis set), andowner.namefeatures/computer/computersRackFilter.ts:55-73raftFilterRackComputerscomputersRackFilter.ts:43-47,74-76,utils/computerUpgradeIndicator.tsgetComputerAttentionStatusraftRackNeedsAttentioncomputersRackFilter.ts:22-40,49-53,77-80,features/computer/ComputersRackToolbar.tsx:118-156raftRackRuntimeFilterOptions,raftRackEffectiveRuntimeFilter,toggleRuntimestore/computersRackFilterPreference.ts:22ComputersRackGroupBy-_.), case-insensitive, lone groups fold up or go to Other, title = most common spellingcomputersRackFilter.ts:85-169raftRackNamePrefixGroupsHOST_PROVIDER_LABELS; unknown or none goes to Personal computerscomputersRackFilter.ts:187-197RAFT_HOST_PROVIDER_LABELScomputersRackFilter.ts:206-239,features/computer/ComputersRackList.tsx:124-137raftGroupRackComputers,raftRackGroupRankremaining:<provider>for each provider present, Disk, Memory; default Name A to Z; a new key starts at its first direction (name asc, numbers desc); no value goes last both ways; ties keep the list order; a stored runtime sort whose runtime is gone falls back to the defaultfeatures/computer/computersRackSort.ts:19-121,features/computer/computersRackToolbarModel.ts:68-85,ComputersRackToolbar.tsx:58-61,196-248raftSortRackComputers,raftRackEffectiveSort,raftRackSortMenuSections,raftRackSortDirectionCopyrate_limited= 0; reauth / unsupported / error = no value;limit_reachedwith no ratio = fully usedcomputersRackSort.ts:49-75raftRackRemainingComputersRackList.tsx:102-123raftComputersRackLayoutstore/computersRackFilterPreference.ts:55-57,66-68,81-83clearedFilters,RaftComputersRackFilters.activestore/computersRackFilterPreference.ts:35-51,71-78,store/computersRackSortPreference.ts:30-47,store/computersRackViewPreference.tsRaftComputersRackToolbarStore.onServer,KeyValueComputersRackPreferenceRepositoryTests (35 new, all commonTest)
RaftComputersRackFiltersTest(30) mirrorsfeatures/computer/tests/computersRackFilter.behavior.test.ts(all 14 tests: same fleets, same name-prefix table, same 20-seed order-independence shuffle, same remaining cases), plus the row-order expectations ofcomputersRackSort.behavior.test.tsxandcomputersRackToolbar.behavior.test.tsx: search, Status, Runtime, Group, every sort key in both directions, provider groups under a remaining sort, a stale runtime choice, Clear all, server change, persistence, and the sort sheet's key/direction steps. The cases are tables, not copied tests.ComputersRackPreferencesTest(4): the Group and Sort round trips (every key × direction), unreadable stored values, and View sharing the existing key.ComputersApiTest.hostProviderMapsFromTheMachineReadModelAndIsNullWhenAbsent(1).ComputersApiTest,LocalPreferencesTest,RaftComputersRackModelTest,SharedComputersCacheFirstTest.Spec vs web differences (followed the web)
-N/_N, a group needs 2+ members". Staging (#14042,77ba471b5) groups by the longest shared word prefix instead: it splits on-_., compares case-insensitively, and folds lone groups up (for example,artin-hostinger-rootpullsartin-fluence-*intoartin). The spec's line rangecomputersRackFilter.ts:85-166is now:85-239.owner.namewhen the Computer has no owner. WebfilterRackMachinesaddsmachine.owner?.nameeven whenownerUserIdis null. Only the display name requires an owner.isComputer). An offline bare daemon is not counted. A machine whose status is unknown counts as offline.Intl.Collator(locale, {numeric, sensitivity: "base"}). Common Kotlin has no collator, soraftRackCompareTextapproximates it: numeric runs, case and common Latin accents ignored, punctuation < digits < letters. There is no locale tailoring, so zh pinyin order for Han names falls back to code point order.SharedComputersRackToolbarStore; the code usesRaftComputersRackToolbarStore. The spec points to the toolbar and sort behaviour tests, but most of the logic tests are incomputersRackFilter.behavior.test.ts, which this PR mirrors in full.🤖 Generated with Claude Code