clients: prefill a shared account so our devices auto-pair ("just us")
Default the account to a shared identity (overridable, persisted in UserDefaults/prefs; agent via --account) instead of empty. With it prefilled, every one of our devices on the same network auto-pairs over the LAN regardless of room — no setup. Swapped in for the real Sign-in-with-Apple `sub` later. Verified with the live Mac app: it and an agent in a totally different room LAN-paired purely via the shared account. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -58,7 +58,7 @@ fn main() {
|
|||||||
let host = std::env::var("HOSTNAME").unwrap_or_else(|_| "tether-agent".into());
|
let host = std::env::var("HOSTNAME").unwrap_or_else(|_| "tether-agent".into());
|
||||||
let name = arg("--name", &host);
|
let name = arg("--name", &host);
|
||||||
// Shared identity: same-account devices pair on the LAN regardless of room.
|
// Shared identity: same-account devices pair on the LAN regardless of room.
|
||||||
let account = arg("--account", "");
|
let account = arg("--account", "pecord@gmail.com");
|
||||||
|
|
||||||
eprintln!("tether-agent → {server} room={room} source={source}");
|
eprintln!("tether-agent → {server} room={room} source={source}");
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ data class FeedItem(val text: String, val source: String, val ts: Long, val id:
|
|||||||
/// changes, so we auto-send via OnPrimaryClipChangedListener.
|
/// changes, so we auto-send via OnPrimaryClipChangedListener.
|
||||||
class TetherStore(private val context: Context) {
|
class TetherStore(private val context: Context) {
|
||||||
val serverURL = mutableStateOf(prefs().getString("serverURL", "https://tether.pecord.io")!!)
|
val serverURL = mutableStateOf(prefs().getString("serverURL", "https://tether.pecord.io")!!)
|
||||||
|
val account = mutableStateOf(prefs().getString("account", "pecord@gmail.com")!!)
|
||||||
val room = mutableStateOf(RoomIdentity.derive(context))
|
val room = mutableStateOf(RoomIdentity.derive(context))
|
||||||
val feed = mutableStateListOf<FeedItem>()
|
val feed = mutableStateListOf<FeedItem>()
|
||||||
val connected = mutableStateOf(false)
|
val connected = mutableStateOf(false)
|
||||||
@@ -30,9 +31,9 @@ class TetherStore(private val context: Context) {
|
|||||||
private var counter = 0L
|
private var counter = 0L
|
||||||
|
|
||||||
fun connect() {
|
fun connect() {
|
||||||
prefs().edit().putString("serverURL", serverURL.value).apply()
|
prefs().edit().putString("serverURL", serverURL.value).putString("account", account.value).apply()
|
||||||
disconnect()
|
disconnect()
|
||||||
val e = Engine(serverURL.value.trim(), room.value, deviceId, "android", android.os.Build.MODEL, "")
|
val e = Engine(serverURL.value.trim(), room.value, deviceId, "android", android.os.Build.MODEL, account.value)
|
||||||
e.start(Bridge())
|
e.start(Bridge())
|
||||||
engine = e
|
engine = e
|
||||||
connected.value = true
|
connected.value = true
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ struct FeedItem: Identifiable, Equatable {
|
|||||||
@MainActor @Observable
|
@MainActor @Observable
|
||||||
final class MacTetherStore {
|
final class MacTetherStore {
|
||||||
var serverURL: String = UserDefaults.standard.string(forKey: "serverURL") ?? "https://tether.pecord.io"
|
var serverURL: String = UserDefaults.standard.string(forKey: "serverURL") ?? "https://tether.pecord.io"
|
||||||
|
// Prefilled shared identity — for now it's just us, so all devices pair.
|
||||||
|
var account: String = UserDefaults.standard.string(forKey: "account") ?? "pecord@gmail.com"
|
||||||
var room: String = RoomIdentity.derive()
|
var room: String = RoomIdentity.derive()
|
||||||
var feed: [FeedItem] = []
|
var feed: [FeedItem] = []
|
||||||
var nearby: [Peer] = [] // tether devices on the LAN, for the picker
|
var nearby: [Peer] = [] // tether devices on the LAN, for the picker
|
||||||
@@ -45,10 +47,11 @@ final class MacTetherStore {
|
|||||||
}
|
}
|
||||||
hasAttemptedConnect = true
|
hasAttemptedConnect = true
|
||||||
UserDefaults.standard.set(serverURL, forKey: "serverURL")
|
UserDefaults.standard.set(serverURL, forKey: "serverURL")
|
||||||
|
UserDefaults.standard.set(account, forKey: "account")
|
||||||
disconnect()
|
disconnect()
|
||||||
|
|
||||||
let b = EngineBridge(store: self)
|
let b = EngineBridge(store: self)
|
||||||
let e = Engine(server: url, room: room, from: deviceID, source: "macos", name: deviceID, account: "")
|
let e = Engine(server: url, room: room, from: deviceID, source: "macos", name: deviceID, account: account)
|
||||||
e.start(handler: b)
|
e.start(handler: b)
|
||||||
engine = e
|
engine = e
|
||||||
bridge = b
|
bridge = b
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ struct FeedItem: Identifiable, Equatable {
|
|||||||
@MainActor @Observable
|
@MainActor @Observable
|
||||||
final class TetherStore {
|
final class TetherStore {
|
||||||
var serverURL: String = UserDefaults.standard.string(forKey: "serverURL") ?? "https://tether.pecord.io"
|
var serverURL: String = UserDefaults.standard.string(forKey: "serverURL") ?? "https://tether.pecord.io"
|
||||||
|
// Prefilled shared identity — for now it's just us, so all devices pair.
|
||||||
|
// Becomes the Sign-in-with-Apple `sub` once the dev program clears.
|
||||||
|
var account: String = UserDefaults.standard.string(forKey: "account") ?? "pecord@gmail.com"
|
||||||
var room: String = RoomIdentity.derive()
|
var room: String = RoomIdentity.derive()
|
||||||
var feed: [FeedItem] = []
|
var feed: [FeedItem] = []
|
||||||
var connected = false
|
var connected = false
|
||||||
@@ -41,10 +44,11 @@ final class TetherStore {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
UserDefaults.standard.set(serverURL, forKey: "serverURL")
|
UserDefaults.standard.set(serverURL, forKey: "serverURL")
|
||||||
|
UserDefaults.standard.set(account, forKey: "account")
|
||||||
disconnect()
|
disconnect()
|
||||||
|
|
||||||
let b = EngineBridge(store: self)
|
let b = EngineBridge(store: self)
|
||||||
let e = Engine(server: url, room: room, from: deviceID, source: "ios", name: UIDevice.current.name, account: "")
|
let e = Engine(server: url, room: room, from: deviceID, source: "ios", name: UIDevice.current.name, account: account)
|
||||||
e.start(handler: b)
|
e.start(handler: b)
|
||||||
engine = e
|
engine = e
|
||||||
bridge = b
|
bridge = b
|
||||||
|
|||||||
Reference in New Issue
Block a user