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
48 changes: 46 additions & 2 deletions Tests/StackNudgePanelCoreTests/CompanionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,50 @@ final class CompanionPlacementTests: XCTestCase {
}
}

final class CompanionOutfitTests: XCTestCase {

private var calendar: Calendar {
var c = Calendar(identifier: .gregorian)
c.timeZone = TimeZone(identifier: "UTC")!
return c
}

private func date(_ month: Int, _ day: Int, hour: Int = 12) -> Date {
calendar.date(from: DateComponents(year: 2026, month: month, day: day, hour: hour))!
}

private func skin(_ outfit: CompanionOutfit, _ date: Date, chosen: String = "stacky") -> String {
CompanionOutfit.skinID(for: chosen, outfit: outfit, on: date, calendar: calendar)
}

func testByDateWearsTheCostumeAllOfDecember() {
XCTAssertEqual(skin(.auto, date(11, 30, hour: 23)), "stacky")
XCTAssertEqual(skin(.auto, date(12, 1, hour: 0)), "stacky-christmas")
XCTAssertEqual(skin(.auto, date(12, 26)), "stacky-christmas")
XCTAssertEqual(skin(.auto, date(12, 31, hour: 23)), "stacky-christmas")
XCTAssertEqual(skin(.auto, date(1, 1, hour: 0)), "stacky")
}

func testTheSettingOverridesTheDateBothWays() {
XCTAssertEqual(skin(.off, date(12, 15)), "stacky")
XCTAssertEqual(skin(.wear("stacky-christmas"), date(7, 4)), "stacky-christmas")
}

func testAnotherCharacterIsNeverDressed() {
for outfit in CompanionOutfit.all {
XCTAssertEqual(skin(outfit, date(12, 15), chosen: "other"), "other")
}
}

func testTheConfigValueRoundTripsAndUnknownMeansAuto() {
for outfit in CompanionOutfit.all {
XCTAssertEqual(CompanionOutfit(config: outfit.rawValue), outfit)
}
XCTAssertEqual(CompanionOutfit(config: nil), .auto)
XCTAssertEqual(CompanionOutfit(config: "stacky-easter"), .auto)
}
}

final class CompanionSkinsTests: XCTestCase {

// A config written by a newer build can name a skin this one lacks; the
Expand Down Expand Up @@ -148,7 +192,7 @@ final class CompanionSettingsTests: XCTestCase {
let nav = PanelNav()
nav.companionEnabled = true
XCTAssertEqual(nav.rows(in: .companion),
[.companionBadge, .companionSize, .companionPreviewPose, .companionResetPosition])
[.companionBadge, .companionSize, .companionOutfit, .companionPreviewPose, .companionResetPosition])
XCTAssertEqual(nav.rows(in: .appearance).first, .floatingWidget)
XCTAssertFalse(nav.rows(in: .appearance).contains(.companionTurnOn))
}
Expand All @@ -158,7 +202,7 @@ final class CompanionSettingsTests: XCTestCase {
let nav = PanelNav()
nav.companionEnabled = false
XCTAssertEqual(nav.rows(in: .companion).first, .companionTurnOn)
XCTAssertEqual(nav.rows(in: .companion).count, 5)
XCTAssertEqual(nav.rows(in: .companion).count, 6)
}

func testFloatingWidgetFollowsTheTwoFlags() {
Expand Down
2 changes: 1 addition & 1 deletion Tests/StackNudgePanelCoreTests/SettingsRowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ final class SettingsRowTests: XCTestCase {
XCTAssertFalse(nav.selectedRowIsPicker, "\(row) should ignore arrows")
}

for row in [SettingsRow.muteDuration, .floatingWidget, .theme, .companionSize, .companionPreviewPose, .historyPerSession, .agentDoneSound] {
for row in [SettingsRow.muteDuration, .floatingWidget, .theme, .companionSize, .companionOutfit, .companionPreviewPose, .historyPerSession, .agentDoneSound] {
select(row)
XCTAssertEqual(nav.selectedRow, row)
XCTAssertTrue(nav.selectedRowIsPicker, "\(row) should pick")
Expand Down
1 change: 1 addition & 0 deletions assets/skins/stacky-christmas/.bake-hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a7ea7aefbb1fd50b49bb3cf14b9967c90b71b97ffd771f4ab7d375642ace49aa
Binary file added assets/skins/stacky-christmas/alert/g-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/skins/stacky-christmas/alert/g-32.png
Binary file added assets/skins/stacky-christmas/alert/g-33.png
Binary file added assets/skins/stacky-christmas/alert/g-34.png
Binary file added assets/skins/stacky-christmas/alert/g-35.png
Binary file added assets/skins/stacky-christmas/alert/g-36.png
Binary file added assets/skins/stacky-christmas/alert/g-37.png
Binary file added assets/skins/stacky-christmas/alert/g-38.png
Binary file added assets/skins/stacky-christmas/alert/g-39.png
Binary file added assets/skins/stacky-christmas/alert/g-4.png
Binary file added assets/skins/stacky-christmas/alert/g-40.png
Binary file added assets/skins/stacky-christmas/alert/g-41.png
Binary file added assets/skins/stacky-christmas/alert/g-42.png
Binary file added assets/skins/stacky-christmas/alert/g-43.png
Binary file added assets/skins/stacky-christmas/alert/g-44.png
Binary file added assets/skins/stacky-christmas/alert/g-45.png
Binary file added assets/skins/stacky-christmas/alert/g-46.png
Binary file added assets/skins/stacky-christmas/alert/g-47.png
Binary file added assets/skins/stacky-christmas/alert/g-48.png
Binary file added assets/skins/stacky-christmas/alert/g-49.png
Binary file added assets/skins/stacky-christmas/alert/g-5.png
Binary file added assets/skins/stacky-christmas/alert/g-50.png
Binary file added assets/skins/stacky-christmas/alert/g-51.png
Binary file added assets/skins/stacky-christmas/alert/g-52.png
Binary file added assets/skins/stacky-christmas/alert/g-53.png
Binary file added assets/skins/stacky-christmas/alert/g-54.png
Binary file added assets/skins/stacky-christmas/alert/g-55.png
Binary file added assets/skins/stacky-christmas/alert/g-56.png
Binary file added assets/skins/stacky-christmas/alert/g-57.png
Binary file added assets/skins/stacky-christmas/alert/g-58.png
Binary file added assets/skins/stacky-christmas/alert/g-59.png
Binary file added assets/skins/stacky-christmas/alert/g-6.png
Binary file added assets/skins/stacky-christmas/alert/g-60.png
Binary file added assets/skins/stacky-christmas/alert/g-61.png
Binary file added assets/skins/stacky-christmas/alert/g-62.png
Binary file added assets/skins/stacky-christmas/alert/g-63.png
Binary file added assets/skins/stacky-christmas/alert/g-64.png
Binary file added assets/skins/stacky-christmas/alert/g-65.png
Binary file added assets/skins/stacky-christmas/alert/g-66.png
Binary file added assets/skins/stacky-christmas/alert/g-67.png
Binary file added assets/skins/stacky-christmas/alert/g-68.png
Binary file added assets/skins/stacky-christmas/alert/g-69.png
Binary file added assets/skins/stacky-christmas/alert/g-7.png
Binary file added assets/skins/stacky-christmas/alert/g-70.png
Binary file added assets/skins/stacky-christmas/alert/g-71.png
Binary file added assets/skins/stacky-christmas/alert/g-72.png
Binary file added assets/skins/stacky-christmas/alert/g-73.png
Binary file added assets/skins/stacky-christmas/alert/g-74.png
Binary file added assets/skins/stacky-christmas/alert/g-75.png
Binary file added assets/skins/stacky-christmas/alert/g-76.png
Binary file added assets/skins/stacky-christmas/alert/g-77.png
Binary file added assets/skins/stacky-christmas/alert/g-78.png
Binary file added assets/skins/stacky-christmas/alert/g-79.png
Binary file added assets/skins/stacky-christmas/alert/g-8.png
Binary file added assets/skins/stacky-christmas/alert/g-80.png
Binary file added assets/skins/stacky-christmas/alert/g-81.png
Binary file added assets/skins/stacky-christmas/alert/g-82.png
Binary file added assets/skins/stacky-christmas/alert/g-83.png
Binary file added assets/skins/stacky-christmas/alert/g-84.png
Binary file added assets/skins/stacky-christmas/alert/g-85.png
Binary file added assets/skins/stacky-christmas/alert/g-86.png
Binary file added assets/skins/stacky-christmas/alert/g-87.png
Binary file added assets/skins/stacky-christmas/alert/g-88.png
Binary file added assets/skins/stacky-christmas/alert/g-89.png
Binary file added assets/skins/stacky-christmas/alert/g-9.png
Binary file added assets/skins/stacky-christmas/alert/g-90.png
Binary file added assets/skins/stacky-christmas/alert/g-91.png
Binary file added assets/skins/stacky-christmas/alert/g-92.png
Binary file added assets/skins/stacky-christmas/alert/g-93.png
Binary file added assets/skins/stacky-christmas/alert/g-94.png
Binary file added assets/skins/stacky-christmas/alert/g-95.png
Binary file added assets/skins/stacky-christmas/alert/g-96.png
Binary file added assets/skins/stacky-christmas/alert/g-97.png
Binary file added assets/skins/stacky-christmas/alert/g-98.png
Binary file added assets/skins/stacky-christmas/alert/g-99.png
Binary file added assets/skins/stacky-christmas/alert/g.png
Binary file added assets/skins/stacky-christmas/alert/image-g-2.png
Binary file added assets/skins/stacky-christmas/alert/image-g.png
Binary file added assets/skins/stacky-christmas/error/g-2.png
Binary file added assets/skins/stacky-christmas/error/g-3.png
Binary file added assets/skins/stacky-christmas/error/g-4.png
Binary file added assets/skins/stacky-christmas/error/g-5.png
Binary file added assets/skins/stacky-christmas/error/g-6.png
Binary file added assets/skins/stacky-christmas/error/g-7.png
Binary file added assets/skins/stacky-christmas/error/g-8.png
Binary file added assets/skins/stacky-christmas/error/g-9.png
Binary file added assets/skins/stacky-christmas/error/g-path.png
Binary file added assets/skins/stacky-christmas/error/g.png
Binary file added assets/skins/stacky-christmas/error/image-2.png
Binary file added assets/skins/stacky-christmas/error/image-3.png
Binary file added assets/skins/stacky-christmas/error/image-g.png
Binary file added assets/skins/stacky-christmas/error/image.png
Binary file added assets/skins/stacky-christmas/idle/image-2.png
Binary file added assets/skins/stacky-christmas/idle/image-3.png
Binary file added assets/skins/stacky-christmas/idle/image-4.png
Binary file added assets/skins/stacky-christmas/idle/image.png
5,372 changes: 5,372 additions & 0 deletions assets/skins/stacky-christmas/manifest.json

Large diffs are not rendered by default.

Binary file added assets/skins/stacky-christmas/muted/g-2.png
Binary file added assets/skins/stacky-christmas/muted/g-3.png
Binary file added assets/skins/stacky-christmas/muted/g.png
Binary file added assets/skins/stacky-christmas/pending/image-2.png
Binary file added assets/skins/stacky-christmas/pending/image-g.png
Binary file added assets/skins/stacky-christmas/pending/image.png
Binary file added assets/skins/stacky-christmas/shared/g-10.png
Binary file added assets/skins/stacky-christmas/shared/g-11.png
Binary file added assets/skins/stacky-christmas/shared/g-2.png
Binary file added assets/skins/stacky-christmas/shared/g-3.png
Binary file added assets/skins/stacky-christmas/shared/g-4.png
Binary file added assets/skins/stacky-christmas/shared/g-5.png
Binary file added assets/skins/stacky-christmas/shared/g-6.png
Binary file added assets/skins/stacky-christmas/shared/g-7.png
Binary file added assets/skins/stacky-christmas/shared/g-9.png
Binary file added assets/skins/stacky-christmas/shared/g-path.png
Binary file added assets/skins/stacky-christmas/shared/g.png
Binary file added assets/skins/stacky-christmas/shared/halo.png
Binary file added assets/skins/stacky-christmas/shared/image-2.png
Binary file added assets/skins/stacky-christmas/shared/image-3.png
Binary file added assets/skins/stacky-christmas/shared/image-5.png
Binary file added assets/skins/stacky-christmas/shared/image-6.png
Binary file added assets/skins/stacky-christmas/shared/image-7.png
Binary file added assets/skins/stacky-christmas/shared/image-8.png
Binary file added assets/skins/stacky-christmas/shared/image-9.png
Binary file added assets/skins/stacky-christmas/shared/image-g.png
Binary file added assets/skins/stacky-christmas/shared/image.png
Binary file added assets/skins/stacky-christmas/shared/path.png
Binary file added assets/skins/stacky-christmas/sleeping/g-2.png
Binary file added assets/skins/stacky-christmas/sleeping/g-3.png
Binary file added assets/skins/stacky-christmas/sleeping/g-4.png
Binary file added assets/skins/stacky-christmas/sleeping/g-5.png
Binary file added assets/skins/stacky-christmas/sleeping/g-6.png
Binary file added assets/skins/stacky-christmas/sleeping/g-7.png
Binary file added assets/skins/stacky-christmas/sleeping/g-8.png
Binary file added assets/skins/stacky-christmas/sleeping/g-path.png
Binary file added assets/skins/stacky-christmas/sleeping/g.png
Binary file added assets/skins/stacky-christmas/thinking/g-2.png
Binary file added assets/skins/stacky-christmas/thinking/g-3.png
Binary file added assets/skins/stacky-christmas/thinking/g-4.png
Binary file added assets/skins/stacky-christmas/thinking/g.png
Binary file added assets/skins/stacky-christmas/thinking/halo-2.png
Binary file added assets/skins/stacky-christmas/thinking/halo-3.png
Binary file added assets/skins/stacky-christmas/thinking/halo.png
7 changes: 4 additions & 3 deletions docs/panel.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,18 @@ The companion is a small animated character that floats on your desktop and take

- **Click** the character to open the panel beside it. The hotkey opens it there too.
- **Drag** it anywhere; it stays where you drop it, and comes back on screen if a display it was on goes away.
- **Right-click** for the menu, including a **Companion** submenu with its size and **Reset position**, which puts it back where a fresh install starts it.
- **Right-click** for the menu, including a **Companion** submenu with its size, **Seasonal costumes** and **Reset position**, which puts it back where a fresh install starts it.

Its pose follows what stack-nudge knows: thinking while an agent is busy, watching while agent sessions are live, waiting when an event or a permission prompt is queued, alert when a quota is past your alert threshold, muted while notifications are muted, and asleep after five quiet minutes. The waiting pose is a wave: it means something wants you to act, and a finished agent turn is one of those, so it still waves. A new finished turn also gets a single small nod on arrival, when the character is otherwise calm (idle or asleep), not muted, and Reduce Motion is off. A count badge at its corner shows how many events are waiting, the Events tab count less snoozed events (a notification stops counting once read), grey while muted. It animates on the render server and pauses while it is covered, the display sleeps or the screen is locked, so it stays near 0% CPU. With Reduce Motion on, it holds still.

| Setting | Key | Values |
|---------|-----|--------|
| Floating widget (Appearance) | `STACKNUDGE_FLOATING_WIDGET` | `pill`, `companion`, `off` |
| Size | `STACKNUDGE_COMPANION_SIZE` | `small`, `medium` (default), `large` |
| Seasonal costumes | `STACKNUDGE_COMPANION_OUTFIT` | `auto` (default, **By date**: wears whatever is in season, today the Christmas costume from Dec 1 to Dec 31), `off`, `stacky-christmas` (**Christmas**, any time of year) |
| Count badge | `STACKNUDGE_COMPANION_BADGE` | `true` (default) / `false` |

The Companion category holds only the character's own settings. While Floating widget isn't `Companion` it shows a note and a **Turn on companion** row that switches it, and the settings are dimmed. `Space` or `⏎` flips Count badge, runs Reset position and Turn on companion, and on Floating widget, Size and Preview pose starts picking, as on every other row. Preview pose shows any pose on the character without changing anything else; it isn't saved. Holding `⌥` while the menu is open also reveals a **Debug** submenu under Companion with the same pose preview and an **Info (nod)** entry that plays the nod once. An extension can add its own entries to the same submenu, under its name, by declaring them in its manifest (see `debug` in [extensions.md](extensions.md)); Meetings uses them to post a reminder on demand. The submenu appears whenever it has something in it, with or without the companion. The character's last spot is kept in `STACKNUDGE_COMPANION_POS`.
The Companion category holds only the character's own settings. While Floating widget isn't `Companion` it shows a note and a **Turn on companion** row that switches it, and the settings are dimmed. `Space` or `⏎` flips Count badge, runs Reset position and Turn on companion, and on Floating widget, Size, Seasonal costumes and Preview pose starts picking, as on every other row. Preview pose shows any pose on the character without changing anything else; it isn't saved. Holding `⌥` while the menu is open also reveals a **Debug** submenu under Companion with the same pose preview and an **Info (nod)** entry that plays the nod once. An extension can add its own entries to the same submenu, under its name, by declaring them in its manifest (see `debug` in [extensions.md](extensions.md)); Meetings uses them to post a reminder on demand. The submenu appears whenever it has something in it, with or without the companion. The character's last spot is kept in `STACKNUDGE_COMPANION_POS`.

## Menu bar (macOS)

Expand All @@ -294,7 +295,7 @@ When the panel daemon is running, the StackNudge mark appears in your menu bar,
| `Voice notifications` | Toggles spoken notifications. Enabling speaks *"Voice notifications enabled"*. |
| `Mute when focused` | Toggles skipping the banner when the agent's window is already in front |
| `Mute notifications ▸` | Submenu (For 15m / 30m / 1h / 2h) to silence all nudges for a set time. While muted a `Muted · Xm left` line shows above it, the item becomes `Resume notifications`, and the menu-bar icon shows a `bell.slash` + countdown. |
| `Companion ▸` | While the companion is on: size, Reset position, and (with `⌥` held) Debug |
| `Companion ▸` | While the companion is on: size, seasonal costumes, Reset position, and (with `⌥` held) Debug |
| `Show panel` | Brings the floating panel up (handy when no events are queued) |
| `Settings…` (⌘,) | Opens the panel straight on Settings |
| `Check permissions…` | Opens the Permissions page in the panel (see [Permissions](setup.md#permissions-macos)) |
Expand Down
5 changes: 5 additions & 0 deletions notify.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ STACKNUDGE_FLOATING_WIDGET=companion
# Default: medium
#STACKNUDGE_COMPANION_SIZE=large

# Seasonal costumes for Stacky: auto (wears whatever is in season; today the
# Christmas costume, Dec 1 to Dec 31), off, or stacky-christmas (any time).
# Default: auto
#STACKNUDGE_COMPANION_OUTFIT=off

# A count badge at the character's corner for events waiting on you.
# Default: true
#STACKNUDGE_COMPANION_BADGE=false
Expand Down
2 changes: 2 additions & 0 deletions panel/Companion/CompanionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ final class CompanionController {
if model.badgeCount != badge { model.badgeCount = badge }
if model.badgeMuted != nav.isMuted { model.badgeMuted = nav.isMuted }
if model.size != nav.companionSize { model.size = nav.companionSize }
let skinID = CompanionOutfit.skinID(for: CompanionSkins.defaultID, outfit: nav.companionOutfit, on: now)
if model.skinID != skinID { model.skinID = skinID }
}

// MARK: - Nod
Expand Down
20 changes: 20 additions & 0 deletions panel/Companion/CompanionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class CompanionMenu: NSObject {
func addItems(to menu: NSMenu) {
let companion = NSMenu()
companion.addItem(sizeItem())
companion.addItem(outfitItem())
companion.addItem(.separator())
let reset = NSMenuItem(title: "Reset position", action: #selector(resetPosition), keyEquivalent: "")
reset.target = self
Expand Down Expand Up @@ -96,6 +97,20 @@ final class CompanionMenu: NSObject {
return item
}

private func outfitItem() -> NSMenuItem {
let outfits = NSMenu()
for outfit in CompanionOutfit.all {
let item = NSMenuItem(title: outfit.label, action: #selector(selectOutfit(_:)), keyEquivalent: "")
item.target = self
item.representedObject = outfit.rawValue
item.state = nav.companionOutfit == outfit ? .on : .off
outfits.addItem(item)
}
let item = NSMenuItem(title: "Seasonal costumes", action: nil, keyEquivalent: "")
item.submenu = outfits
return item
}

@objc private func resetPosition() {
nav.actions?.resetCompanionPosition()
}
Expand All @@ -108,6 +123,11 @@ final class CompanionMenu: NSObject {
nav.companionInputs.nodRequests &+= 1
}

@objc private func selectOutfit(_ sender: NSMenuItem) {
guard let raw = sender.representedObject as? String, CompanionOutfit.all.contains(where: { $0.rawValue == raw }) else { return }
nav.setCompanionOutfit(CompanionOutfit(config: raw))
}

@objc private func selectSize(_ sender: NSMenuItem) {
guard let raw = sender.representedObject as? String, let size = CompanionSize(rawValue: raw) else { return }
nav.setCompanionSize(size)
Expand Down
69 changes: 69 additions & 0 deletions panel/Companion/CompanionOutfit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import Foundation

// Seasonal costumes for Stacky. The saved character is never rewritten; the
// view asks here each refresh.
struct SeasonalCostume {
let skinID: String
let label: String
// Inclusive month and day bounds, within one calendar year.
let from: (month: Int, day: Int)
let to: (month: Int, day: Int)

func isInSeason(on date: Date, calendar: Calendar) -> Bool {
let parts = calendar.dateComponents([.month, .day], from: date)
let today = (parts.month ?? 0, parts.day ?? 0)
return today >= from && today <= to
}

// Adding a season is one entry here and its art under assets/skins;
// CompanionSkins.all registers the skin from this list.
static let all = [
SeasonalCostume(skinID: StackySkin.christmasID, label: "Christmas", from: (12, 1), to: (12, 31)),
]
}

// What Stacky wears: whatever is in season, nothing, or one costume any time.
enum CompanionOutfit: Equatable {
case auto, off, wear(String)

static let configKey = "STACKNUDGE_COMPANION_OUTFIT"

static var all: [CompanionOutfit] { [.auto, .off] + SeasonalCostume.all.map { .wear($0.skinID) } }

// An unknown value, as a newer build might write, reads as automatic.
init(config: String?) {
switch config {
case "off": self = .off
case let id? where SeasonalCostume.all.contains { $0.skinID == id }: self = .wear(id)
default: self = .auto
}
}

var rawValue: String {
switch self {
case .auto: return "auto"
case .off: return "off"
case .wear(let id): return id
}
}

var label: String {
switch self {
case .auto: return "By date"
case .off: return "Off"
case .wear(let id): return SeasonalCostume.all.first { $0.skinID == id }?.label ?? id
}
}

// Only plain Stacky is dressed up; any other character is returned as is.
static func skinID(for chosen: String, outfit: CompanionOutfit, on date: Date,
calendar: Calendar = .current) -> String {
guard chosen == StackySkin.plainID else { return chosen }
switch outfit {
case .off: return chosen
case .wear(let id): return id
case .auto:
return SeasonalCostume.all.first { $0.isInSeason(on: date, calendar: calendar) }?.skinID ?? chosen
}
}
}
3 changes: 2 additions & 1 deletion panel/Companion/CompanionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI
final class CompanionModel: ObservableObject {
@Published var mode: SkinMode = .idle
@Published var size: CompanionSize = .medium
@Published var skinID = CompanionSkins.defaultID
// Events waiting on you; 0 hides the badge, which is also how the setting
// that turns it off reaches the view.
@Published var badgeCount = 0
Expand Down Expand Up @@ -43,7 +44,7 @@ struct CompanionView: View {

var body: some View {
let size = model.size.points
CharacterLayerHost(skin: CompanionSkins.skin(id: CompanionSkins.defaultID), mode: model.mode,
CharacterLayerHost(skin: CompanionSkins.skin(id: model.skinID), mode: model.mode,
still: NSWorkspace.shared.accessibilityDisplayShouldReduceMotion,
size: size, active: gate.active)
.frame(width: size.width, height: size.height)
Expand Down
4 changes: 3 additions & 1 deletion panel/Companion/Skin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ protocol Skin: Sendable {
// back to the default, so a config written by a newer build still shows a
// character.
enum CompanionSkins {
static let defaultID = "stacky"
static let defaultID = StackySkin.plainID

// Costumes come from SeasonalCostume.all, so a new season registers its skin there.
static let all: [LayeredSkin] = [StackySkin()]
+ SeasonalCostume.all.map { StackySkin(id: $0.skinID, displayName: $0.label) }

static func skin(id: String?) -> LayeredSkin {
all.first { $0.id == id } ?? all.first { $0.id == defaultID } ?? all[0]
Expand Down
21 changes: 15 additions & 6 deletions panel/Companion/StackySkin.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import Foundation

// Stacky: layers cut from one reference sheet and animated with transforms.
// The art is baked into PNG parts and a manifest under assets/skins/stacky.
// The art is baked into PNG parts and a manifest under assets/skins/<id>; the
// Christmas costume is the same sheet baked with the costume on.
struct StackySkin: Skin {
let id = "stacky"
let displayName = "Stacky"
static let plainID = "stacky"
static let christmasID = "stacky-christmas"

let id: String
let displayName: String

init(id: String = plainID, displayName: String = "Stacky") {
self.id = id
self.displayName = displayName
}
}

extension StackySkin: LayeredSkin {
@MainActor func makeRig(size: CGSize, backing: CGFloat) -> SkinRig {
StackyRig(size: size, backing: backing, assets: BakedRig.bundled(id))
StackyRig(size: size, backing: backing, assets: BakedRig.bundled(id), name: id)
}
}

// The bake records each group's CSS keyframes as samples, so the rig adds no
// motion code of its own.
@MainActor
final class StackyRig: BakedRig {
init(size: CGSize, backing: CGFloat, assets: URL) {
super.init(size: size, backing: backing, assets: assets, name: "stacky", fallbackBox: [0, 0, 860, 922])
init(size: CGSize, backing: CGFloat, assets: URL, name: String) {
super.init(size: size, backing: backing, assets: assets, name: name, fallbackBox: [0, 0, 860, 922])
}
}
Loading
Loading