Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Anything that changes what the dashboard, the admin or a widget can do gets a li

### Added
- **Local Docker and AI models.** Registry widgets can show up to 200 local containers and observed Ollama or MLX models. Fremkit refuses remote Docker contexts, distinguishes a missing CLI from a stopped daemon, and keeps the container list when stats fail.
- **Borrow the Edge display.** Hide or show the dashboard from the helper menu without quitting it. Hidden state survives display rearrangements, and the mouse fence pauses while the Edge is borrowed. Touch and data collection continue; the dashboard reappears after a helper restart.
- **Claude sessions: go to the session.** Touch a card and its window comes forward — the
exact Orca pane, the Terminal.app or iTerm2 tab, the VS Code window on that folder, or at
least the application — for every session, hooked or merely found running. The card also says which application the session lives in, which is what tells two panes of the
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ the widget library and the widgets themselves, live, without a reload.
helper adds what a browser cannot — its own HID driver for the Edge's touch panel, a fence that
keeps the mouse cursor on your other displays, a kiosk window with no chrome and no cursor, the
Dock's notification badges, and supervision of the server. Its menu bar **F** shows what is
running: *Open the admin*, *Admin in the browser*, *Reload the dashboard*, the *Touch* / *Mouse
fence* / *Notifications* / *Manage the server* / *Launch at login* toggles, *Log…* and *Quit*,
running: *Open the admin*, *Admin in the browser*, *Hide the dashboard* / *Show the dashboard*,
*Reload the dashboard*, the *Touch* / *Mouse fence* / *Notifications* / *Manage the server* /
*Launch at login* toggles, *Log…* and *Quit*,
above state lines such as "Server: running" and "Touch: active".

## Widgets
Expand Down
12 changes: 12 additions & 0 deletions native/Sources/FremkitCore/DashboardVisibility.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// User visibility survives display loss and geometry changes; data collection is independent.
public struct DashboardVisibility {
public private(set) var hiddenByUser = false
public private(set) var applicationHidden = false
public var displayAvailable = true
public var shouldShow: Bool { displayAvailable && !hiddenByUser && !applicationHidden }
public init() {}
public mutating func hide() { hiddenByUser = true }
public mutating func show() { hiddenByUser = false }
public mutating func applicationDidHide() { applicationHidden = true }
public mutating func applicationDidUnhide() { applicationHidden = false }
}
6 changes: 6 additions & 0 deletions native/Sources/FremkitCore/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum L10nKey: String, CaseIterable {
case openAdmin
case openAdminInBrowser
case reloadDashboard
case hideDashboard
case showDashboard
case toggleTouch
case toggleFence
case toggleDock
Expand Down Expand Up @@ -100,6 +102,8 @@ public enum L10n {
.openAdmin: "Ouvrir l'admin",
.openAdminInBrowser: "Admin dans le navigateur",
.reloadDashboard: "Recharger le dashboard",
.hideDashboard: "Masquer le dashboard",
.showDashboard: "Afficher le dashboard",
.toggleTouch: "Tactile",
.toggleFence: "Barrière souris",
.toggleDock: "Notifications",
Expand Down Expand Up @@ -151,6 +155,8 @@ public enum L10n {
.openAdmin: "Open the admin",
.openAdminInBrowser: "Admin in the browser",
.reloadDashboard: "Reload the dashboard",
.hideDashboard: "Hide the dashboard",
.showDashboard: "Show the dashboard",
.toggleTouch: "Touch",
.toggleFence: "Mouse fence",
.toggleDock: "Notifications",
Expand Down
37 changes: 35 additions & 2 deletions native/Sources/FremkitHelper/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
private let poster = EventPoster()
private var driver: TouchDriver?
private var fence: MouseFence?
/// A future window fence can register here and share the dashboard visibility rule.
private var fenceUpdates: [(Bool) -> Void] = []
private var dockBadges: DockBadges?
private var watcher: EdgeDisplay.Watcher?
private var kiosk: KioskWindow?
Expand Down Expand Up @@ -55,6 +57,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
self?.menu?.update { $0.fence = state }
}
self.fence = fence
fenceUpdates.append { [weak fence] active in
if active { _ = fence?.start() }
else { fence?.stop() }
}

let dockBadges = DockBadges(port: config.port)
dockBadges.onState = { [weak self] state in
Expand All @@ -80,7 +86,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}

if config.touch { driver.start() }
if config.fence { fence.start() }
syncFences()
if config.dock { dockBadges.start() }

// An orphan from a crashed helper still holds the port and would be mistaken for an
Expand Down Expand Up @@ -182,6 +188,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

// MARK: - Display

// Cmd-H temporarily hides the app without changing the user's dashboard preference.
func applicationDidHide(_ notification: Notification) { kiosk?.applicationDidHide() }
func applicationDidUnhide(_ notification: Notification) { kiosk?.applicationDidUnhide() }

private func syncFences() {
let active = config.fence && kiosk?.isShowingDashboard == true
for update in fenceUpdates { update(active) }
}

private func refreshDashboardMenu() {
menu?.update { state in
state.dashboardAvailable = edge != nil && kiosk != nil
state.dashboardHidden = kiosk?.isHiddenByUser == true
}
}

private func edgeDidChange(_ edge: CGRect?) {
self.edge = edge
driver?.displayBounds = edge
Expand All @@ -197,11 +219,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
} else {
let url = Self.parseURL(config.url, what: "url")
kiosk = KioskWindow(frame: frame, url: url)
kiosk?.onVisibilityChange = { [weak self] in
self?.syncFences()
self?.refreshDashboardMenu()
}
}
} else {
admin?.kioskFrame = nil
kiosk?.setEdgeFrame(nil)
}
syncFences()
refreshDashboardMenu()
}

// MARK: - Server
Expand All @@ -227,6 +255,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}

private func wireMenu(_ menu: StatusMenu) {
menu.onToggleDashboard = { [weak self] in
guard let self, self.edge != nil, let kiosk = self.kiosk else { return }
if kiosk.isHiddenByUser { kiosk.showDashboard() }
else { kiosk.hideDashboard() }
}
menu.onOpenAdmin = { [weak self] in self?.admin?.show() }

menu.onOpenAdminInBrowser = { [weak self] in
Expand All @@ -248,7 +281,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
guard let self else { return }
self.config.fence = on
self.saveConfig()
if on { self.fence?.start() } else { self.fence?.stop() }
self.syncFences()
self.refreshMenu()
}

Expand Down
41 changes: 39 additions & 2 deletions native/Sources/FremkitHelper/KioskWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,50 @@ final class KioskWindow: NSObject, WKNavigationDelegate {

/// Moves the window onto `rect` (CoreGraphics display bounds), or hides it when the Edge is gone.
func setEdgeFrame(_ rect: CGRect?) {
visibility.displayAvailable = rect != nil
guard let rect else {
window.orderOut(nil)
return
}
let frame = NSRect.fromCGDisplayBounds(rect, primaryHeight: NSRect.primaryScreenHeight)
window.setFrame(frame, display: true)
window.orderFrontRegardless()
window.setFrame(frame, display: visibility.shouldShow)
if visibility.shouldShow { window.orderFrontRegardless() }
}

// MARK: - Visibility

private var visibility = DashboardVisibility()
var isHiddenByUser: Bool { visibility.hiddenByUser }
var isShowingDashboard: Bool { visibility.shouldShow }
var onVisibilityChange: (() -> Void)?

/// Lends the Edge to the windows behind the dashboard until the user shows it again.
func hideDashboard() {
visibility.hide()
window.orderOut(nil)
onVisibilityChange?()
}

/// Returns the dashboard without taking keyboard focus from the current application.
func showDashboard() {
visibility.show()
if NSApp.isHidden { NSApp.unhideWithoutActivation() }
if visibility.shouldShow {
window.orderFrontRegardless()
}
onVisibilityChange?()
}

func applicationDidHide() {
visibility.applicationDidHide()
window.orderOut(nil)
onVisibilityChange?()
}

func applicationDidUnhide() {
visibility.applicationDidUnhide()
if visibility.shouldShow { window.orderFrontRegardless() }
onVisibilityChange?()
}

func close() {
Expand Down
10 changes: 10 additions & 0 deletions native/Sources/FremkitHelper/StatusMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import FremkitCore

/// Everything the menu displays, handed over by the delegate on each rebuild.
struct MenuState {
var dashboardAvailable = false
var dashboardHidden = false
var server: ServerState = .stopped
var touch: TouchState = .disabled
/// What the fence is really doing, as opposed to what the config asks for.
Expand Down Expand Up @@ -49,6 +51,7 @@ final class StatusMenu: NSObject {
private var state = MenuState()

// Status lines, all disabled; the last three are hidden unless they have something to say.
private let dashboardToggle = NSMenuItem()
private let serverLine = NSMenuItem()
private let touchLine = NSMenuItem()
private let fenceLine = NSMenuItem()
Expand All @@ -66,6 +69,7 @@ final class StatusMenu: NSObject {
var onOpenAdmin: (() -> Void)?
var onOpenAdminInBrowser: (() -> Void)?
var onReload: (() -> Void)?
var onToggleDashboard: (() -> Void)?
var onToggleTouch: ((Bool) -> Void)?
var onToggleFence: ((Bool) -> Void)?
var onToggleDock: ((Bool) -> Void)?
Expand Down Expand Up @@ -142,6 +146,9 @@ final class StatusMenu: NSObject {

menu.addItem(actionItem(L10n.string(.openAdmin), #selector(openAdmin)))
menu.addItem(actionItem(L10n.string(.openAdminInBrowser), #selector(openAdminInBrowser)))
dashboardToggle.target = self
dashboardToggle.action = #selector(toggleDashboard)
menu.addItem(dashboardToggle)
menu.addItem(actionItem(L10n.string(.reloadDashboard), #selector(reload)))
menu.addItem(.separator())

Expand Down Expand Up @@ -170,6 +177,8 @@ final class StatusMenu: NSObject {
// MARK: - State

private func apply() {
dashboardToggle.title = L10n.string(state.dashboardHidden ? .showDashboard : .hideDashboard)
dashboardToggle.isEnabled = state.dashboardAvailable
serverLine.title = state.server.label
touchLine.title = state.touchLabel
fenceLine.isHidden = state.fence != .missingPermission
Expand All @@ -189,6 +198,7 @@ final class StatusMenu: NSObject {
@objc private func openAdmin() { onOpenAdmin?() }
@objc private func openAdminInBrowser() { onOpenAdminInBrowser?() }
@objc private func reload() { onReload?() }
@objc private func toggleDashboard() { onToggleDashboard?() }
@objc private func openLog() { onOpenLog?() }
@objc private func quit() { onQuit?() }

Expand Down
39 changes: 39 additions & 0 deletions native/Tests/FremkitCoreTests/DashboardVisibilityTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import XCTest
@testable import FremkitCore

final class DashboardVisibilityTests: XCTestCase {
func testUserHideSurvivesDisplayReconfiguration() {
var state = DashboardVisibility()
XCTAssertTrue(state.shouldShow)
state.hide()
XCTAssertFalse(state.shouldShow)
state.displayAvailable = false
state.displayAvailable = true
XCTAssertFalse(state.shouldShow)
state.show()
XCTAssertTrue(state.shouldShow)
}
func testShowingWithoutDisplayKeepsWindowAbsent() {
var state = DashboardVisibility()
state.displayAvailable = false
state.hide()
state.show()
XCTAssertFalse(state.shouldShow)
state.displayAvailable = true
XCTAssertTrue(state.shouldShow)
}
func testApplicationHideDoesNotClearUserPreference() {
var state = DashboardVisibility()
state.hide()
state.applicationDidHide()
state.applicationDidUnhide()
XCTAssertTrue(state.hiddenByUser)
XCTAssertFalse(state.shouldShow)
state.show()
XCTAssertTrue(state.shouldShow)
state.applicationDidHide()
XCTAssertFalse(state.shouldShow)
state.applicationDidUnhide()
XCTAssertTrue(state.shouldShow)
}
}
5 changes: 5 additions & 0 deletions native/Tests/Shim/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ let suites: [(String, () -> XCTestCase, [TestMethod])] = [
("testAnotherSchemeIsIgnored", { ($0 as! HelperURLTests).testAnotherSchemeIsIgnored() }),
("testUnknownTargetIsIgnored", { ($0 as! HelperURLTests).testUnknownTargetIsIgnored() }),
]),
("DashboardVisibilityTests", { DashboardVisibilityTests() }, [
("testUserHideSurvivesDisplayReconfiguration", { ($0 as! DashboardVisibilityTests).testUserHideSurvivesDisplayReconfiguration() }),
("testShowingWithoutDisplayKeepsWindowAbsent", { ($0 as! DashboardVisibilityTests).testShowingWithoutDisplayKeepsWindowAbsent() }),
("testApplicationHideDoesNotClearUserPreference", { ($0 as! DashboardVisibilityTests).testApplicationHideDoesNotClearUserPreference() }),
]),
("L10nTests", { L10nTests() }, [
("testPicksFrenchForAFrenchSystem", { ($0 as! L10nTests).testPicksFrenchForAFrenchSystem() }),
("testPicksEnglishForEverythingElse", { ($0 as! L10nTests).testPicksEnglishForEverythingElse() }),
Expand Down
Loading