Sessions Integration Feature
Nucleic-Session: FC94353F-9F0D-4BCC-AD7C-0FB14E38C2E5 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -614,25 +614,38 @@ final class RemoteStore: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Unpair this device entirely — drop every paired Mac and its connection (the "Unpair this
|
||||||
|
/// device" button). Nothing left to show, so the app returns to the pairing intro.
|
||||||
func unpair() {
|
func unpair() {
|
||||||
// Forget + drop the active Mac's connection specifically (the switcher may have made it not
|
for (id, conn) in connections { conn.teardown(); connections[id] = nil }
|
||||||
// the last). Other Macs' connections keep running.
|
for host in IdentityStore.pairedHosts() { IdentityStore.removePairedHost(id: host.fingerprint) }
|
||||||
if let id = activeHostID {
|
IdentityStore.clearPairedHost()
|
||||||
connections[id]?.teardown()
|
finishUnpairIfEmpty()
|
||||||
connections[id] = nil
|
}
|
||||||
IdentityStore.removePairedHost(id: id)
|
|
||||||
|
/// Forget one paired Mac (the Settings ▸ Mesh per-row remove): drop just its connection +
|
||||||
|
/// registry record. Other Macs keep running and stay in the merged view.
|
||||||
|
func unpair(_ hostID: String) {
|
||||||
|
connections[hostID]?.teardown()
|
||||||
|
connections[hostID] = nil
|
||||||
|
IdentityStore.removePairedHost(id: hostID)
|
||||||
|
if IdentityStore.pairedHosts().isEmpty {
|
||||||
|
finishUnpairIfEmpty()
|
||||||
} else {
|
} else {
|
||||||
IdentityStore.clearPairedHost()
|
rebuildAggregate()
|
||||||
}
|
refreshAggregate()
|
||||||
activeHostID = nil
|
|
||||||
// Mesh P3: if other Macs remain paired, switch to one (already connected) rather than unpairing.
|
|
||||||
if let next = IdentityStore.pairedHosts().last {
|
|
||||||
activeHostID = next.fingerprint
|
|
||||||
reconnect()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wind the app back to the unpaired state once no Macs remain: clear the open transcript + flat
|
||||||
|
/// aggregate and spin the embedded Tailscale node down.
|
||||||
|
private func finishUnpairIfEmpty() {
|
||||||
|
openSessionID = nil
|
||||||
|
openSessionHostID = nil
|
||||||
|
openEvents = []; openApprovals = []; openDiff = nil; diffLoading = false
|
||||||
connectivity = .unpaired
|
connectivity = .unpaired
|
||||||
sessions = []
|
sessions = []
|
||||||
|
dashboard = .empty
|
||||||
// Nothing left to dial — spin the embedded Tailscale node down if it was running.
|
// Nothing left to dial — spin the embedded Tailscale node down if it was running.
|
||||||
Task { await TailnetNode.shared.stop() }
|
Task { await TailnetNode.shared.stop() }
|
||||||
tailnetStatus = nil
|
tailnetStatus = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user