- {summary.turnOnable > 0 ? (
-
- ) : null}
+ {/* Nothing left to switch on means nothing to offer: each row already speaks for itself. */}
+ {enableableServers.length === 0 ? null : (
+
+
)}
)
}))}
diff --git a/src/renderer/src/components/settings/session-search-computer-rollup.test.ts b/src/renderer/src/components/settings/session-search-computer-rollup.test.ts
index 66f94a1a33b..454be5e31bd 100644
--- a/src/renderer/src/components/settings/session-search-computer-rollup.test.ts
+++ b/src/renderer/src/components/settings/session-search-computer-rollup.test.ts
@@ -1,17 +1,10 @@
-import { expect, it, vi } from 'vitest'
+import { expect, it } from 'vitest'
import {
isTurnOnableSessionSearchState,
orderSessionSearchServers,
- sessionSearchSummarySentence,
- summarizeSessionSearchComputers,
type SessionSearchComputerEntry
} from './session-search-computer-rollup'
-vi.mock('@/i18n/i18n', () => ({
- translate: (_key: string, fallback: string, args?: Record) =>
- fallback.replace(/{{(\w+)}}/g, (_, key: string) => String(args?.[key]))
-}))
-
const fleet: SessionSearchComputerEntry[] = [
{ id: 'local', name: 'Local Mac', state: 'on' },
{ id: 'a', name: 'build-01', state: 'on' },
@@ -22,37 +15,12 @@ const fleet: SessionSearchComputerEntry[] = [
{ id: 'f', name: 'probing', state: 'checking' }
]
-it('counts what the user can see and what they could act on', () => {
- expect(summarizeSessionSearchComputers(fleet)).toEqual({
- on: 2,
- total: 7,
- offline: 2,
- needUpdate: 1,
- turnOnable: 1
- })
-})
-
it('will not offer to turn on a computer it cannot reach or that is too old', () => {
expect(isTurnOnableSessionSearchState('off')).toBe(true)
for (const state of ['on', 'offline', 'needs-update', 'checking'] as const) {
expect(isTurnOnableSessionSearchState(state)).toBe(false)
}
-})
-
-it('leaves a zero segment out of the sentence rather than printing it', () => {
- expect(sessionSearchSummarySentence(summarizeSessionSearchComputers(fleet), false)).toBe(
- 'On 2 of 7 computers · 2 offline · 1 need an update'
- )
- const onlyLocal = summarizeSessionSearchComputers([fleet[0]])
- expect(sessionSearchSummarySentence(onlyLocal, false)).toBe('On 1 of 1 computers')
-})
-
-it('promises to keep new computers turned on only when that is the standing consent', () => {
- const summary = summarizeSessionSearchComputers([fleet[0]])
- expect(sessionSearchSummarySentence(summary, true)).toBe(
- 'On 1 of 1 computers New computers turn on when they can.'
- )
- expect(sessionSearchSummarySentence(summary, false)).not.toContain('New computers')
+ expect(fleet.filter((entry) => isTurnOnableSessionSearchState(entry.state))).toHaveLength(1)
})
it('orders reachable and working first, then by name inside each group', () => {
diff --git a/src/renderer/src/components/settings/session-search-computer-rollup.ts b/src/renderer/src/components/settings/session-search-computer-rollup.ts
index 9a9c693e3f9..2d830f8584b 100644
--- a/src/renderer/src/components/settings/session-search-computer-rollup.ts
+++ b/src/renderer/src/components/settings/session-search-computer-rollup.ts
@@ -1,5 +1,3 @@
-import { translate } from '@/i18n/i18n'
-
/**
* What one computer in the pane is doing, as far as this client can tell.
*
@@ -14,64 +12,10 @@ export type SessionSearchComputerEntry = {
state: SessionSearchComputerState
}
-export type SessionSearchFleetSummary = {
- on: number
- total: number
- offline: number
- needUpdate: number
- /** Reachable, new enough, and still off: exactly what Turn on all would act on. */
- turnOnable: number
-}
-
export function isTurnOnableSessionSearchState(state: SessionSearchComputerState): boolean {
return state === 'off'
}
-export function summarizeSessionSearchComputers(
- entries: readonly SessionSearchComputerEntry[]
-): SessionSearchFleetSummary {
- const count = (state: SessionSearchComputerState): number =>
- entries.filter((entry) => entry.state === state).length
- return {
- on: count('on'),
- total: entries.length,
- offline: count('offline'),
- needUpdate: count('needs-update'),
- turnOnable: entries.filter((entry) => isTurnOnableSessionSearchState(entry.state)).length
- }
-}
-
-/** Sentence above the list. A segment worth zero is left out rather than printed as "0". */
-export function sessionSearchSummarySentence(
- summary: SessionSearchFleetSummary,
- autoEnableNewComputers: boolean
-): string {
- const segments = [
- translate('sessionHistory.settings.summaryOn', 'On {{on}} of {{total}} computers', {
- on: summary.on,
- total: summary.total
- })
- ]
- if (summary.offline > 0) {
- segments.push(
- translate('sessionHistory.settings.summaryOffline', '{{offline}} offline', {
- offline: summary.offline
- })
- )
- }
- if (summary.needUpdate > 0) {
- segments.push(
- translate('sessionHistory.settings.summaryNeedUpdate', '{{needUpdate}} need an update', {
- needUpdate: summary.needUpdate
- })
- )
- }
- const sentence = segments.join(' · ')
- return autoEnableNewComputers
- ? `${sentence} ${translate('sessionHistory.settings.summaryAutoEnable', 'New computers turn on when they can.')}`
- : sentence
-}
-
// Reachable and working first, then what the user could act on, then what they cannot.
const STATE_RANK: Record = {
on: 0,
diff --git a/src/renderer/src/components/settings/use-session-search-auto-enable.ts b/src/renderer/src/components/settings/use-session-search-auto-enable.ts
deleted file mode 100644
index 4efdde61db5097e8d973efbc509a2b929ee58c14..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 2312
zcmah~O^@3)5bfE&Vv<8FFC4kO6-FH-C=6r|y<``?1Ob+oMl!n+X^@m1!}Wjf8&Z#E`+%;oV5S9GSz*_Nh`RS~8Woh-v~$1q=i=b{VR
zn$OmU`*JkS^Tqh*x5{z3;KB6$7Pe!cnDP(XnZV_Bx{r&kwa`o%THM{y7ogBB6Pvwu
z*0gK_>2gkC%lMBs9gguug~07DP-AP-o}T&0C2fv5-7OGGmrL@&X;b4xioM5&8>Vn#
zRLi5`c`^Zl3Ej~{P^N@071nq`5b1yW*f~SikZPK@OH$<7?b!j10u0dLXv2kV*^@MC
zEAZ#yX@{)D@iy
zrX5Uo$}sJ<*CD4*$tXf{T%mJbJP;I^lAksbQGqzSn+swEt4OI2(#z=EsuFwy4u#aA
z(jt@6mvbwGAua>a*b(43^e3
zNBTjOB%H6`;A73&IqQ~`fqJj%v7_`inXYMOwE94MtI-J9K5z&PLk-#G`+2sE1`(9>
zT*feggYqH)em>-phdu~&zal9Ik&|1SrU;*33{5s0EqdLefzbx@mWenJ@wX({583Qu
zEwTcd(e(5>9C1u8dC@s1(#2@K?gN*_g6@aevQ^Z=!Mf*pYDkO%wac>f68n%Ib6w8zzpOUd^rz`;0$Le5-tqRR9Xf
z2?9dr4VxM?tX3=f`4udcb(AGQDK~*v_+MQ9omQ3QRobhae>6oe<3tOZk7b%B
zRPBKULR++;d2qJZ@o!zQcocDg+vnqn==ZS-0DVBJy5
z30U_Y53#12$^RqNDQ@d!
zKNPv#MwFzRN|4`c8ehI$EQhDzzi>EE{_Y*ULg&p`jGHYkEJ>e2o@f0BY>Fog@)Iss
z+-$g8a1B7&PyIYS&FQe!=qT6Y3udlQ