tic
CLAUDE.md49 starsChanged 2 months agoMITView on GitHub
Tic is a macOS app of floating, Stickies-style task notes that live on the desktop. It's a SwiftPM executable (no .xcodeproj), SwiftUI for views, AppKit for windows, and SQLite via GRDB for storage. Deployment target is macOS 14; the dev toolchain is Swift 6.2 / Xcode 26. PLAN.md is the design doc and roadmap (what's built vs. deferred). - Landing page (tic.kasvith.me) is a self-contained Astro + pnpm project in site/ — all Node tooling stays there (see site/README.md); never…
In this repository2 other files it gives its agents.
- site/AGENTS.mdAGENTS.md
- site/CLAUDE.mdCLAUDE.md
The file
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What this is
Tic is a macOS app of floating, Stickies-style task notes that live on the desktop. It's a
SwiftPM executable (no .xcodeproj), SwiftUI for views, AppKit for windows, and SQLite via
GRDB for storage. Deployment target is macOS 14; the dev toolchain is Swift 6.2 / Xcode 26.
PLAN.md is the design doc and roadmap (what's built vs. deferred).
Commands
swift build # compile (resolves the GRDB SPM dependency); the source of truth
swift run # build + launch the GUI app (long-running; kill it when done)
open Package.swift # opens the package in Xcode for GUI editing / previews
./scripts/package.sh # build release + assemble dist/Tic.app (add --open to launch it)- Landing page (tic.kasvith.me) is a self-contained Astro + pnpm project in
site/— all Node tooling stays there (seesite/README.md); never add JS files to the repo root. - Verification is a clean
swift build,swift test(Swift Testing —AppDatabaseTests,TaskOutlineTests,NoteColorTests,TaskImageTests, …), plus running the app. The outline logic lives in pure, testable functions (TaskOutline) precisely so it can be covered without a DB or the main actor. swift runproduces a bare executable (no bundle): fine for dev, but it has no Dock identity and can't register as a login item (SMAppService needs a real bundle).- Packaging (
scripts/package.sh+Packaging/Info.plist) assembles a realdist/Tic.appwith bundle idcom.kasvith.ticand the icon fromAssets/AppIcon/Tic.icns(→Resources/AppIcon.icns, referenced byCFBundleIconFile). That's what gives the Dock icon/name and makes Launch-at-Login work. It's ad-hoc signed; a Developer ID + notarization is needed for distribution. For the login item to persist, run from a stable location (moveTic.appto /Applications). - Tests:
swift test(Swift Testing;@testable import Ticworks on the executable target — no separate library).Assets/holds source icon art (AppIcon / Flat / MenuBar); the menu-bar glyph is also copied toSources/Tic/Resources/MenuBarIcon.pngand bundled via SwiftPM. - CI/Release:
.github/workflows/—ci.yml(build + test + lint) andrelease.yml(push av*tag → buildsTic.app, git-cliff release notes, publishes a GitHub Release, commits the regeneratedCHANGELOG.mdto main, then POSTs theCF_DEPLOY_HOOKsecret so the site's What's new rebuilds — that commit is[skip ci], which Cloudflare honours). - To launch headlessly for a no-crash smoke check (the GUI can't be screenshotted from a
sandbox), run
.build/debug/Ticin the background and grep its stderr for the[Tic] restored N note panel(s)log line.
Inspecting / resetting state
The database is a plain SQLite file you can read and edit directly:
DB="$HOME/Library/Application Support/Tic/tic.sqlite"
sqlite3 -header -column "$DB" "SELECT title,color,material,floatOnTop,isCollapsed FROM note;"
rm "$DB" # wipe; the welcome note is re-seeded on next launchIn DEBUG builds the migrator sets eraseDatabaseOnSchemaChange = true, so changing the schema
auto-wipes the DB instead of crashing.
Architecture
The defining constraint: a desktop sticky note needs borderless/float/all-Spaces/custom-drag behavior that pure SwiftUI windows can't provide. So SwiftUI views are hosted inside AppKit panels, and a few responsibilities are deliberately split across the AppKit/SwiftUI boundary.
NotePanel(AppKitNSPanel) — one window per note. Titled but with a hidden transparent title bar +fullSizeContentView(gives rounded corners, shadow, edge-resize while the SwiftUI content fills everything).isMovableByWindowBackgroundis off on purpose.NoteWindowManager(@MainActor) — owns[UUID: NotePanel]+[UUID: NoteController], is each panel'sNSWindowDelegate, and is the single chokepoint for all window mutation:restoreAll(launch: only notes withisOpen— the header X clears it, quitting doesn't, so relaunch shows what was on screen),openNote, close, debounced frame persistence, roll-up resize, and applying float-on-top / show-on-all-Spaces. Frames are global coordinates spanning all displays, exactly as Stickies stores them. Only user drags/resizes persist a frame:placeputs a note at its saved frame when any connected display shows it, else parks it at the nearest edge of the main display, and re-runs ondidChangeScreenParametersNotificationwith saves suppressed (placing+ a 2s blackout) — so unplugging a monitor never overwrites the note's spot on it, and plugging it back returns the note exactly, with or without a relaunch in between.NoteController(@MainActor @Observable) — one per open note. Holds theNote, streams its tasks live via GRDBValueObservation, and turns user actions into DB writes. It stays AppKit-free: window side effects go through closures the manager sets on it (onApplyBehavior,onClose,onSetCollapsed).AppDatabase(Sendable) — GRDBDatabaseQueue+DatabaseMigrator, async CRUD, andValueObservationstreams.TaskOutline(pure, no AppKit / no DB) — all the subtask/outline maths over a note's flat[TaskItem]: subtree/parent/children queries, the bidirectional completion cascade (applyingToggle), indent/outdent, drag-move (movingSubtree), levelnormalizedLevels, and the id-matchedindentLevelChangesdiff. Kept separate so it's unit-testable in isolation.PlainTextEditor(NSViewRepresentableoverNSTextView) — the task / quick-add editor. AppKit, not SwiftUITextField, because that control can't reliably insert newlines or intercept Tab on macOS (see the editing convention below).QuickAddBaris the add-a-task bar along the bottom of a note (owns the typed text and pending indent).ShortcutHintis the small keycap-chip label.TaskImage(pure CoreGraphics/ImageIO, no AppKit / no DB) +TaskImageView— pasted images: normalise/thumbnail/crop/preview-file helpers and the crop maths (dragging,moving), and the view that draws a task's image with its hover buttons, context menu, and crop mode.ImageVieweris the image window a double-click opens (AppKitZoomScrollViewzoom + Open in Preview), dressed like its note (paper/glass background, note-style header, hints) — one reusableImageWindowowned byNoteWindowManager; far quicker than launching Preview.- MCP server (
MCP/) — lets AI agents drive Tic.MCPServiceruns anNWListeneron a Unix socket beside the DB (~/Library/Application Support/Tic/mcp.sock, 0600) — one official-SDKServersession per connection (per agent).MCPToolsis the tool surface (create_note,add_tasks,update_task,move_task, …): pureAppDatabasewrites plus three window pokes (WindowActions), reusingTaskOutlinefor every structural rule so tools and UI can't diverge. Clients speak stdio toTic --mcp(MCPProxy), which pipes to the socket — one config works for every client, and the server lives in the app next to the observers. Off by default (AppModel.mcpEnabled). Live updates are free: tools write the DB, the existingValueObservationstreams push into open panels; the one addition isobserveNote(id:)so the controller streams its own note row too (an agent's title/colour/flag write shows live). - App shell —
TicAppprovides aMenuBarExtra;main.swift(not@main) routes--mcpto the proxy, elseTicApp.main();AppDelegate(NSApplicationDelegateAdaptor) builds the sharedAppDatabase+NoteWindowManagerand callsrestoreAll()on launch. The app is a hybrid: Dock icon and menu bar item.
Conventions that matter (and why)
- Targeted column writes prevent clobbering. Window frame, title, appearance, and flags each
have their own
UPDATE-one-column method onAppDatabase(updateNoteFrame,updateNoteTitle, …). For tasks,applyStructuralUpdate(optional delete +sortIndexreorder +indentLevel, all in one transaction) andupdateTaskCompletion(isDone/completedAt) each touch only their own columns. This is load-bearing: dragging a window (frequent frame saves) must not overwrite a title edit, a reorder must not clobber a just-edited task's text, and a checkbox toggle must not clobber a concurrent text edit. A whole-recordupdate()is used only for a task text commit (where the controller owns the full current value). - Subtasks are a flat list + an
indentLevel, not a parent-id tree. A task's parent is implicit — the nearest preceding row with a smaller level (max 3 levels).TaskOutlinekeeps the outline invariant (first row level 0; no row more than one level deeper than the row above) vianormalizedLevelsafter every structural edit, so an orphaned/jumped level can never render. When persisting level changes, diff by id against the currenttasks(indentLevelChanges), not by position — a drag reorders and re-nests, so a positional diff would miss the level change (this was a real bug). New subtasks insert mid-list viainsertTask(_:reordering:); everything else appends withinsertTask(atomicMAX(sortIndex)+1, so deletes leaving gaps can't collide). - Completion changes only via
toggle; structural edits preserve ticks.toggleruns the bidirectional cascade (checking a parent checks its whole subtree; finishing the last child auto-completes the parent —TaskOutline.applyingToggle). Move / indent / outdent / delete / add never touchisDone— moving a checked item around leaves every tick exactly as it was. - The editor is AppKit (
PlainTextEditor/NSTextView), not SwiftUITextField. On macOS that control neither reliably inserts line breaks nor lets us intercept Tab (the key-view loop eats it before.onKeyPress).EditorTextView.keyDowngives deterministic chords: Return commits, Shift/Option-Return inserts a newline, Shift-Tab nests, Ctrl-Shift-Tab outdents. It forces TextKit 1 (_ = view.layoutManager) sousedRectcan size it (TextKit 2'slayoutManageris nil and multiline would clip), reports height viasizeThatFits, and aneditorFirstBaseline()guide aligns the adjacent checkbox to the editor's first line (an NSView has no SwiftUI text baseline). A blank/whitespace-only task is deleted on commit, so an abandoned new row just disappears. - Images: one per task, own table, crop is just a rect.
taskImage(PKtaskId, cascades with the task) holds the original PNG plus a crop normalised 0…1 with a top-left origin (CGImage pixel space — no flip). It's a separate table soobserveTasksnever loads blobs, and the crop has its own targetedupdateTaskImageCrop. The controller observes only crops (observeTaskImageCrops, neverdata) and decodes a downsampled thumbnail off the main actor; rows draw that throughCroppedImageCache, never the full image (a drag re-renders every row each frame). ⌘V routing: a focusedEditorTextView.paste(row → attach; quick-add →stageImage), otherwiseNotePanel.paste(alsostageImage, which focuses the quick-add viaquickAddFocusRequest). A staged image waits in the quick-add until Return adds it with the typed text; focus loss doesn't submit while one waits;NSPasteboard.pastableImageDatadecides image vs text (an image file wins; raw image data only when there's no plain text). An image keeps an empty-text task from the blank-task delete. Open in Preview renders a temp PNG of the cropped image (TaskImage.writePreviewFile). Crop mode's mouse and keys are AppKit (CropTrackingView), SwiftUI only draws it: a SwiftUIDragGesturethere kept following the pointer after mouse-up, and SwiftUI focus never arrived, so ⏎ / ⎋ / click-away did nothing. Images size through theAspectFitlayout:.aspectRatio(.fit)+.frame(maxHeight:)laid out row-wide, dragging the hover chrome to the note's edge. Pointing at or cropping an image pauses its row's reorder drag (GestureMask.subviews) — SwiftUI's rowDragGestureotherwise also fires over the image's buttons and even the AppKit crop view. - Rendered Markdown is memoised (
MarkdownRenderCache). Parsing inline Markdown per line on every body re-eval made dragging janky (the whole list re-renders each frame); the cache re-parses only when a task's text/colour actually changes. - Glass is
NSVisualEffectView(.behindWindow), not.glassEffect.NoteBackgroundrenders the.glassmaterial with a behind-window visual-effect view so it shows the desktop through it (and adopts the macOS 26 Liquid Glass look automatically). The SwiftUI.glassEffectAPI is for in-app controls and won't sample the desktop behind a window. - The window drags only by its header.
isMovableByWindowBackgroundis off;WindowMoveArea(anNSViewRepresentablecallingwindow.performDrag) is placed behind the header / collapsed bar. This is what lets task rows be dragged to reorder without moving the window. - Reorder uses a direct
DragGesture, not system.onDrag. System drag has a sluggish pickup; the gesture is immediate. Rows publish their midpoints via aPreferenceKey, the drop indicator shows the landing spot, and the move commits once on release. This is safe on macOS because scrolling is the wheel/trackpad, so click-drag doesn't fight theScrollView. - Roll-up keeps the top edge fixed.
NoteWindowManager.setCollapsedresizes the panel toNoteLayout.collapsedHeight, remembers the real height inexpandedHeights, andscheduleFrameSavepersists the expanded height/origin while collapsed so nothing is lost. - Theming via roles, not raw colors.
NoteColor.color(_:on:)resolves a role (title/task/secondary/completed/checkbox) for aSurface(.soliduses per-theme tuned inks;.glassuses adaptive.primary/.secondary). Views read a resolvedNoteTheme, never branch on material themselves. - Updates are check-only (
UpdateChecker), never auto-install. Tic is ad-hoc signed, so a self-replacing updater (Sparkle) can't be trusted. Daily GET of the GitHubreleases/latestAPI, compared numerically againstCFBundleShortVersionString(nil underswift run→ checker off). A newer tag shows a menu-bar item, a dot on the menu-bar icon until the menu is opened or the item clicked (isUnseen, remembered in theupdateSeenVersiondefault; "opened" is detected viaNSMenu.didEndTrackingNotificationon a menu containing our item; the dot is drawn into a second templateNSImagebecause the status item renders only the label's image, never a SwiftUI overlay), and one notification banner per version (updateNotifiedVersion; authorization is requested only then, so the system prompt appears in context).UNUserNotificationCenterneeds a bundle id, so both the delegate and the banner are guarded.package.shdefaultsVERSIONto the latest git tag so a local build isn't "outdated".- Seeing it locally:
VERSION=0.1.0 ./scripts/package.sh --openshows the menu item and the dot. The banner is stricter: macOS refuses notification authorization (UNErrorDomaincode 1, "Notifications are not allowed for this application") for an ad-hoc bundle outside /Applications, and the refusal seemed to stick to the bundle id afterwards. So to test the banner, copy the build to/Applications/Tic Dev.app, give it a uniqueCFBundleIdentifier(PlistBuddy), re-sign ad-hoc, thenopenit. Re-arm withdefaults delete <bundle id> updateNotifiedVersion updateSeenVersion, and delete the copy after.
- Seeing it locally:
- Models are sync-friendly.
Note/TaskItemuseUUIDPKs +updatedAt; relationships and defaults are chosen so CloudKit/iCloud sync stays feasible later (currently local-only).
Swift 6 strict concurrency
swift-tools-version: 6.0 enables Swift 6 language mode. AppDatabase is Sendable; controller
and manager are @MainActor. Recurring gotchas when editing: don't capture a mutable var in a
@Sendable/Task closure (snapshot to a let first); PreferenceKey.defaultValue must be a
let; qualify CGFloat.greatestFiniteMagnitude to avoid Double ambiguity in NSSize.
Note: SourceKit sometimes reports
Cannot find 'X' in scopefor newly added files in the same module — trustswift build, which resolves them.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

