Skip to content
Open
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 Tusk/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ final class AppState {
var editingConnection: Connection? = nil
var connectingIDs: Set<UUID> = []
var createTableTarget: CreateTableTarget? = nil
var isShowingChristmasEasterEgg = false

init() {
connections = ConnectionStore.shared.load()
Expand Down
120 changes: 120 additions & 0 deletions Tusk/Views/About/ChristmasEasterEggView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import SwiftUI

struct ChristmasEasterEggView: View {
@Environment(\.dismiss) private var dismiss
@State private var snowflakes: [Snowflake] = ChristmasEasterEggView.makeSnowflakes()

var body: some View {
ZStack {
Color(red: 0.07, green: 0.13, blue: 0.25)
.ignoresSafeArea()

// Animated snowflakes
TimelineView(.animation) { timeline in
Canvas { ctx, size in
let elapsed = timeline.date.timeIntervalSinceReferenceDate
for flake in snowflakes {
let progress = (elapsed * flake.speed + flake.offset).truncatingRemainder(dividingBy: 1.0)
let x = flake.xFraction * size.width + sin(elapsed * flake.sway + flake.offset * .pi * 2) * 18
let y = progress * (size.height + 20) - 10
let resolved = ctx.resolve(Text(flake.symbol)
.font(.system(size: flake.size))
.foregroundStyle(.white.opacity(flake.opacity)))
ctx.draw(resolved, at: CGPoint(x: x, y: y))
}
}
}

VStack(spacing: 0) {
Spacer()

// Tree
VStack(spacing: 2) {
Text("*")
.font(.system(size: 28))
.foregroundStyle(.yellow)
Text("^ ^ ^")
.font(.system(size: 22, design: .monospaced))
.foregroundStyle(.green)
Text("^ ^ ^ ^ ^")
.font(.system(size: 22, design: .monospaced))
.foregroundStyle(.green)
Text("^ ^ ^ ^ ^ ^ ^")
.font(.system(size: 22, design: .monospaced))
.foregroundStyle(.green)
Text("^ ^ ^ ^ ^ ^ ^ ^ ^")
.font(.system(size: 22, design: .monospaced))
.foregroundStyle(.green)
Text("|||")
.font(.system(size: 20, design: .monospaced))
.foregroundStyle(Color(red: 0.55, green: 0.35, blue: 0.15))
}
.padding(.bottom, 28)

// Message
VStack(spacing: 10) {
Text("Merry Christmas!")
.font(.system(size: 28, weight: .bold))
.foregroundStyle(.white)

Text("May your queries be fast,\nyour indexes never bloat,\nand your vacuums run on time.")
.font(.system(size: 15))
.foregroundStyle(.white.opacity(0.85))
.multilineTextAlignment(.center)
.lineSpacing(4)

Text("Ho ho ho from the Tusk team.")
.font(.system(size: 13))
.foregroundStyle(.white.opacity(0.5))
.padding(.top, 4)
}
.padding(.bottom, 36)

Button("Dismiss") {
dismiss()
}
.keyboardShortcut(.escape, modifiers: [])
.buttonStyle(.borderedProminent)
.tint(.white.opacity(0.2))
.foregroundStyle(.white)
.controlSize(.large)

Spacer()
}
.padding(.horizontal, 40)
}
.frame(width: 420, height: 480)
}

// MARK: - Snowflakes

private struct Snowflake {
let xFraction: Double
let speed: Double
let offset: Double
let sway: Double
let size: Double
let opacity: Double
let symbol: String
}

private static func makeSnowflakes() -> [Snowflake] {
let symbols = ["*", "+", "·", "❄"]
return (0..<40).map { i in
let rng = Double(i)
func pseudo(_ seed: Double) -> Double {
let x = sin(seed * 127.1 + 311.7) * 43758.5453
return x - floor(x)
}
return Snowflake(
xFraction: pseudo(rng),
speed: 0.04 + pseudo(rng + 1) * 0.06,
offset: pseudo(rng + 2),
sway: 0.5 + pseudo(rng + 3) * 1.5,
size: 8 + pseudo(rng + 4) * 10,
opacity: 0.3 + pseudo(rng + 5) * 0.5,
symbol: symbols[Int(pseudo(rng + 6) * Double(symbols.count))]
)
}
}
}
3 changes: 3 additions & 0 deletions Tusk/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct ContentView: View {
AddConnectionSheet(connection: connection)
.environment(\.font, .system(size: contentFontSize, design: contentFontDesign.design))
}
.sheet(isPresented: $appState.isShowingChristmasEasterEgg) {
ChristmasEasterEggView()
}
Comment on lines +27 to +29

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Conflicting sheet presentations 🐞 Bug ☼ Reliability

ContentView now has an additional independent `.sheet(isPresented:
$appState.isShowingChristmasEasterEgg)` alongside existing sheets, and ⌘⇧J sets that boolean
unconditionally. Triggering ⌘⇧J while another sheet is already presented can cause competing sheet
states (queued/ignored presentation), making the Easter egg appear at unexpected times or not appear
when invoked.
Agent Prompt
### Issue description
The app can end up with multiple sheet states active at once (`isAddingConnection`, `editingConnection`, and now `isShowingChristmasEasterEgg`). SwiftUI sheet presentation is not designed for multiple simultaneous sheet presenters on the same window, so presentation can become queued/ignored/unexpected.

### Issue Context
⌘⇧J is available “anywhere in the app,” including while other sheets are open.

### Fix Focus Areas
- Tusk/Views/ContentView.swift[19-29]
- Tusk/Views/Main/TuskCommands.swift[47-50]

### Suggested fix
Implement one of the following:
- **Single source of truth for modals**: replace the multiple `.sheet` modifiers with a single `.sheet(item:)` driven by an `enum ActiveModal: Identifiable` in `AppState` (cases for add/edit/christmas), and set that enum from commands.
- **Guard the shortcut**: in the ⌘⇧J action, only set `isShowingChristmasEasterEgg = true` if no other modal state is active (e.g., `!isAddingConnection && editingConnection == nil && createTableTarget == nil && !isImportingPgpass`). Optionally, clear/close other sheets before opening the Easter egg if that’s acceptable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
}

Expand Down
8 changes: 8 additions & 0 deletions Tusk/Views/Main/TuskCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ struct TuskCommands: Commands {
openWindow(id: "help")
}
.keyboardShortcut("?", modifiers: .command)

Button("") {
appState.isShowingChristmasEasterEgg = true
}
.keyboardShortcut("j", modifiers: [.command, .shift])
.opacity(0)
.allowsHitTesting(false)
.accessibilityHidden(true)
Comment on lines +47 to +53

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. ⌘⇧j doesn’t toggle flag 📎 Requirement gap ≡ Correctness

The hidden ⌘⇧J command sets appState.isShowingChristmasEasterEgg to true instead of toggling it
true/false. This violates the requirement that the shortcut toggles visibility year-round and
prevents using the shortcut to dismiss once shown.
Agent Prompt
## Issue description
The hidden ⌘⇧J command currently sets `appState.isShowingChristmasEasterEgg = true` instead of toggling it, violating the requirement that the shortcut flips the boolean.

## Issue Context
Compliance requires the hidden menu item under `CommandGroup(replacing: .help)` to toggle `appState.isShowingChristmasEasterEgg` (true/false).

## Fix Focus Areas
- Tusk/Views/Main/TuskCommands.swift[47-53]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}

CommandGroup(after: .windowArrangement) {
Expand Down