main.go

  1// inbox_view is a small helper that renders a mock inbox with realistic emails
  2// for screenshot generation. It wraps the real Inbox component in a model
  3// that forwards window size events properly.
  4package main
  5
  6import (
  7	"fmt"
  8	"os"
  9	"time"
 10
 11	tea "charm.land/bubbletea/v2"
 12	"github.com/floatpane/matcha/config"
 13	"github.com/floatpane/matcha/fetcher"
 14	"github.com/floatpane/matcha/tui"
 15)
 16
 17const (
 18	demoUserID    = "demo-user"
 19	demoUserEmail = "matcha@floatpane.com"
 20)
 21
 22// wrapper forwards all messages to the FolderInbox and ensures it renders correctly.
 23type wrapper struct {
 24	folderInbox *tui.FolderInbox
 25}
 26
 27func (w wrapper) Init() tea.Cmd {
 28	return w.folderInbox.Init()
 29}
 30
 31func (w wrapper) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 32	m, cmd := w.folderInbox.Update(msg)
 33	if fi, ok := m.(*tui.FolderInbox); ok {
 34		w.folderInbox = fi
 35	}
 36	return w, cmd
 37}
 38
 39func (w wrapper) View() tea.View {
 40	v := w.folderInbox.View()
 41	v.AltScreen = true
 42	return v
 43}
 44
 45func main() {
 46	now := time.Now()
 47
 48	accounts := []config.Account{
 49		{
 50			ID:         demoUserID,
 51			Name:       "Matcha Client",
 52			Email:      demoUserEmail,
 53			FetchEmail: demoUserEmail,
 54		},
 55	}
 56
 57	emails := []fetcher.Email{
 58		{
 59			UID:       1012,
 60			From:      "Alice Park <alice.park@example.com>",
 61			To:        []string{demoUserEmail},
 62			Subject:   "Quick sync on the API migration?",
 63			Date:      now.Add(-12 * time.Minute),
 64			MessageID: "<api-migration-012@example.com>",
 65			AccountID: demoUserID,
 66		},
 67		{
 68			UID:       1011,
 69			From:      "GitHub <notifications@github.com>",
 70			To:        []string{demoUserEmail},
 71			Subject:   "[floatpane/matcha] Fix: resolve inbox pagination issue (#281)",
 72			Date:      now.Add(-47 * time.Minute),
 73			MessageID: "<gh-notif-281@github.com>",
 74			AccountID: demoUserID,
 75		},
 76		{
 77			UID:       1010,
 78			From:      "Sarah Chen <sarah.chen@example.com>",
 79			To:        []string{"team@example.com"},
 80			Subject:   "New Dashboard Redesign - Preview & Feedback",
 81			Date:      now.Add(-2 * time.Hour),
 82			MessageID: "<dashboard-redesign-001@example.com>",
 83			AccountID: demoUserID,
 84			Attachments: []fetcher.Attachment{
 85				{Filename: "dashboard-mockup.png", MIMEType: "image/png"},
 86			},
 87		},
 88		{
 89			UID:       1009,
 90			From:      "David Kim <david.kim@example.com>",
 91			To:        []string{demoUserEmail},
 92			Subject:   "Re: Quarterly budget review notes",
 93			Date:      now.Add(-5 * time.Hour),
 94			MessageID: "<budget-review-009@example.com>",
 95			AccountID: demoUserID,
 96		},
 97		{
 98			UID:       1008,
 99			From:      "Stripe <receipts@stripe.com>",
100			To:        []string{demoUserEmail},
101			Subject:   "Your receipt from Acme Corp - Invoice #4821",
102			Date:      now.Add(-23 * time.Hour),
103			MessageID: "<stripe-receipt-4821@stripe.com>",
104			AccountID: demoUserID,
105		},
106		{
107			UID:       1007,
108			From:      "Maria Gonzalez <maria.g@example.com>",
109			To:        []string{demoUserEmail},
110			Subject:   "Design system tokens - final version attached",
111			Date:      now.Add(-1*24*time.Hour - 6*time.Hour),
112			MessageID: "<design-tokens-007@example.com>",
113			AccountID: demoUserID,
114			Attachments: []fetcher.Attachment{
115				{Filename: "design-tokens-v3.json", MIMEType: "application/json"},
116			},
117		},
118		{
119			UID:       1006,
120			From:      "Linear <notifications@linear.app>",
121			To:        []string{demoUserEmail},
122			Subject:   "MAT-342: Implement keyboard shortcuts for compose view",
123			Date:      now.Add(-2*24*time.Hour - 3*time.Hour),
124			MessageID: "<linear-342@linear.app>",
125			AccountID: demoUserID,
126		},
127		{
128			UID:       1005,
129			From:      "James Wright <j.wright@example.com>",
130			To:        []string{demoUserEmail},
131			Subject:   "Onboarding docs are ready for review",
132			Date:      now.Add(-3*24*time.Hour - 1*time.Hour),
133			MessageID: "<onboarding-005@example.com>",
134			AccountID: demoUserID,
135		},
136		{
137			UID:       1004,
138			From:      "Vercel <notifications@vercel.com>",
139			To:        []string{demoUserEmail},
140			Subject:   "Deployment successful: matcha-docs-8f3a2b1",
141			Date:      now.Add(-4*24*time.Hour - 8*time.Hour),
142			MessageID: "<vercel-deploy-004@vercel.com>",
143			AccountID: demoUserID,
144		},
145		{
146			UID:       1003,
147			From:      "Lena Muller <lena.m@example.com>",
148			To:        []string{demoUserEmail},
149			Subject:   "Conference talk proposal - Rethinking TUI Design",
150			Date:      now.Add(-5*24*time.Hour - 2*time.Hour),
151			MessageID: "<conference-003@example.com>",
152			AccountID: demoUserID,
153		},
154		{
155			UID:       1002,
156			From:      "GitHub <notifications@github.com>",
157			To:        []string{demoUserEmail},
158			Subject:   "[floatpane/matcha] Release v1.4.0 published",
159			Date:      now.Add(-5*24*time.Hour - 14*time.Hour),
160			MessageID: "<gh-release-140@github.com>",
161			AccountID: demoUserID,
162		},
163		{
164			UID:       1001,
165			From:      "Omar Hassan <omar.h@example.com>",
166			To:        []string{demoUserEmail},
167			Subject:   "Re: Open source contribution guidelines",
168			Date:      now.Add(-6*24*time.Hour - 5*time.Hour),
169			MessageID: "<oss-contrib-001@example.com>",
170			AccountID: demoUserID,
171		},
172	}
173
174	folders := []string{
175		"INBOX",
176		"Drafts",
177		"Sent",
178		"Archive",
179		"Receipts",
180		"GitHub",
181		"Trash",
182	}
183
184	folderInbox := tui.NewFolderInbox(folders, accounts)
185	folderInbox.SetEmails(emails, accounts)
186
187	p := tea.NewProgram(wrapper{folderInbox: folderInbox})
188	if _, err := p.Run(); err != nil {
189		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
190		os.Exit(1)
191	}
192}