A snapshot is a single entry representing your widget
at this exact moment in time.

The system asks for it when it needs a quick preview
of your widget with real data.

Core Rule

Return a single entry as fast as possible.
Can be async but should still be quick.
Avoid long network calls if possible.

From the Project

func snapshot(for configuration: FocusWidgetIntent, in context: Context) async -> SimpleEntry {
    let index = selectedIndex(for: configuration.session)
    return makeEntry(from: FocusState.all[index], index: index, date: Date())
}
Reads the user's intent config → which session did they pick?
Maps it to an index via selectedIndex()
Builds and returns one entry instantly

When is it shown?

1. Widget gallery → when user is browsing widgets to add
2. Widget editor  → when user is configuring the widget
3. System needs a quick preview without running full timeline

Snapshot vs Placeholder vs Timeline

Placeholder → no data, system redacts it    → layout only
Snapshot    → real data, one entry, fast    → gallery/editor
Timeline    → real data, full schedule      → live on home screen

The context.isPreview Pattern

In production you'd check if the system just wants a preview
to avoid unnecessary network calls:
func snapshot(for configuration: FocusWidgetIntent, in context: Context) async -> SimpleEntry {
    if context.isPreview {
        // return hardcoded data fast — don't fetch anything
        return makeEntry(from: FocusState.all[0], index: 0, date: Date())
    }

    // otherwise fetch real data
    let index = selectedIndex(for: configuration.session)
    return makeEntry(from: FocusState.all[index], index: index, date: Date())
}
context.isPreview == true  → widget gallery, return fast
context.isPreview == false → real usage, fetch real data

Mental Model

Snapshot → "Here's my widget right now, with real data"
Placeholder → shape only
Snapshot    → real but instant
Timeline    → real and scheduled

Important Rule

Snapshot is async but the system expects it quickly.
If it takes too long the system may time out
and fall back to the placeholder instead.