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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ It's for the everyday work. You can follow a standup or refinement someone's run

## Keys

Everywhere: `1` My work (with Mentions) · `2` Projects · `3`–`5` your most used projects · `/` search everything · `t` go to a ticket by its key (`TL-308` or `tl-308`) · `D` unsent drafts · `esc` or `q` back (on My work and Projects, `q` quits) · `Q` quit from anywhere · `?` your version, updates and these keys; `h` there opens the help answers.
Everywhere: `1` My work (with Mentions) · `2` Projects · `3`–`5` your most used projects · `/` search everything · `t` go to a ticket by its key (`TL-308` or `tl-308`) · `N` notifications · `D` unsent drafts · `esc` or `q` back (on My work and Projects, `q` quits) · `Q` quit from anywhere · `?` your version, updates and these keys; `h` there opens the help answers.

| Screen | Keys |
|---|---|
Expand All @@ -59,6 +59,7 @@ Everywhere: `1` My work (with Mentions) · `2` Projects · `3`–`5` your most u
| Ticket | `j`/`k` scroll · `e` edit · `m` move to a column · `c` comment · `a` assign to you (again: unassign) · `tab` pick a sub-ticket or file, `enter` open it · `o` open a picked file in your system's viewer (`xdg-open`; `open` on macOS) · `u` attach a file · `d` remove the picked file (asks first; yours, or any if you're an org admin) · `p` open the parent · `b` browse blocking tickets (project, title and open/done status; `enter` opens the selected blocker, `esc` returns) · `h` its history (everything that happened to it — columns, assignment, edits, labels, comments, files, pull requests — who did it and when; newest first. Edits to text say only that they happened) · `r` reload |
| New / edit ticket | Typing is insert mode; `esc` leaves it. Then `tab` or `j`/`k` field · `i`/`enter` edit · `h`/`l` change type, priority, estimate, and spike timebox · on the due date: `h`/`l` a day, `H`/`L` a week, `x` clears · `q` cancel · `ctrl+s` save (any time) · `ctrl+o` create and attach a file (new tickets) |
| Attach a file (`u`) | type or paste a path, or drop a file on the terminal · `tab` completes it (lists the choices when there are several) · `enter` uploads it with its progress · `esc` cancels the upload, or goes back. Up to 10 MB a file and 10 files a ticket; not on a done ticket. The file goes through the TrackLin.es API, so the TUI never needs the file store's key. |
| Notifications (`N`) | `j`/`k` · `enter` read it and open its ticket or board · `x` clear · `a` mark all read · `r` reload |
| Drafts (`D`) | `j`/`k` · `r` send again · `x` discard · `enter` open its ticket (`c` or `e` there picks the draft up to change it first) |
| Board / project | `f` follows its standup / refinement, when one's running (the banner says so) |
| Following | it moves with the host: who's here, whose turn, the ticket they have open · `esc`/`q` leave |
Expand All @@ -72,6 +73,7 @@ Everywhere: `1` My work (with Mentions) · `2` Projects · `3`–`5` your most u
- Boards that use estimates ask for one when you create a ticket there.
- **Due dates** count down by day, in your local day: "due in 3 days", "due tomorrow", "due today", then "2 days overdue" (red). They show in lists and on the ticket, and go once it's done.
- Choose `spike` to set an optional timebox in days (0–60) and hours (0–23); `not set` is available for either. Changing to another type clears the timebox.
- **Notifications.** The header shows how many are unread, and `N` lists them, as the website's bell. The TUI looks for new ones every 30 seconds, even while its terminal isn't focused, and on Linux each new one also goes to the desktop through the D-Bus notification service (`notify-send`'s; nothing is sent without a session bus). An urgent one (the backend asks policy2 which are) opens the list once, on whichever client sees it first, never over something you're typing.
- **Drafts.** A comment or an edit that can't be sent (the API down, the connection gone) isn't lost: it's kept in `~/.local/state/tracklines/drafts.json` (under `$XDG_STATE_HOME` if set) until it's sent or you discard it, through restarts too, and the TUI says how many are waiting when it starts. Nothing is resent on its own: `D` lists them and `r` sends one again. A comment that got through before the connection dropped isn't posted twice, and an edit to a ticket someone has changed since isn't sent over their changes: open it and `e` shows your edit with a warning, to compare and save if you still want it.
- **Help answers** are the ones in the web app's help panel, written by the TrackLin.es team. They're built in, so help works offline, and the TUI checks for newer ones when it starts and every minute after, swapping them in without a restart. The latest copy is kept in `~/.local/state/tracklines/help.<language>.json` for the next start.
- `m` on a backlog ticket picks a board, then a column, then an estimate if that board sizes tickets. When a move isn't allowed (a read-only key, a sprint on its last day), the TUI says why.
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
github.com/godbus/dbus/v5 v5.2.4 // indirect
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=
github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=
github.com/godbus/dbus/v5 v5.2.4 h1:F2gUCy++NMIxGmo9J+z5le/+ZC8W1OgeR51P4i9ZB/U=
github.com/godbus/dbus/v5 v5.2.4/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
Expand Down
49 changes: 49 additions & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ type Mention struct {
MentionedAt string `json:"mentioned_at"`
}

// Notification is one in the bell (TL-886): read_at nil is unread; urgent ones open the notifications
// once, then shown_at is set.
type Notification struct {
ID string `json:"id"`
Kind string `json:"kind"`
Text string `json:"text"`
Actor string `json:"actor"`
TicketID *string `json:"ticket_id"`
TicketKey *string `json:"ticket_key"`
BoardID *string `json:"board_id"`
Link *string `json:"link"`
CreatedAt string `json:"created_at"`
ReadAt *string `json:"read_at"`
Urgent bool `json:"urgent"`
ShownAt *string `json:"shown_at"`
}

type Column struct {
ID string `json:"id"`
Name string `json:"name"`
Expand Down Expand Up @@ -513,6 +530,38 @@ func (c *Client) Mentions(ctx context.Context) ([]Mention, error) {
return out.Mentions, err
}

// Notifications are yours, unread first, then newest (TL-886).
func (c *Client) Notifications(ctx context.Context) ([]Notification, error) {
var out []Notification
err := c.do(ctx, http.MethodGet, "/notifications?page=1&per_page=50", nil, &out)
return out, err
}

func (c *Client) UnreadCount(ctx context.Context) (int, error) {
var out struct {
Count int `json:"count"`
}
err := c.do(ctx, http.MethodGet, "/notifications/unread-count", nil, &out)
return out.Count, err
}

func (c *Client) ReadNotification(ctx context.Context, id string) error {
return c.do(ctx, http.MethodPost, "/notifications/"+url.PathEscape(id)+"/read", nil, nil)
}

func (c *Client) ReadAllNotifications(ctx context.Context) error {
return c.do(ctx, http.MethodPost, "/notifications/read-all", nil, nil)
}

func (c *Client) DismissNotification(ctx context.Context, id string) error {
return c.do(ctx, http.MethodDelete, "/notifications/"+url.PathEscape(id), nil, nil)
}

// NotificationShown: an urgent one opened the notifications here, so no client does again (TL-886).
func (c *Client) NotificationShown(ctx context.Context, id string) error {
return c.do(ctx, http.MethodPost, "/notifications/"+url.PathEscape(id)+"/shown", nil, nil)
}

// Create makes a ticket at the bottom of a column (joining the board's sprint), or, with no column,
// in the project's backlog.
func (c *Client) Create(ctx context.Context, project, column string, in TicketInput) (Ticket, error) {
Expand Down
13 changes: 13 additions & 0 deletions internal/desktop/desktop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Package desktop shows desktop notifications: on Linux through org.freedesktop.Notifications on the
// session bus (TL-886); elsewhere nothing, for now.
package desktop

// Notifier shows one notification. Never fails the caller: no bus or no daemon is no notification.
type Notifier interface {
Notify(summary, body string, urgent bool)
}

// None shows nothing (other systems, tests).
type None struct{}

func (None) Notify(string, string, bool) {}
42 changes: 42 additions & 0 deletions internal/desktop/desktop_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package desktop

import (
"os"
"sync"

"github.com/godbus/dbus/v5"
)

// Session is the desktop's notification daemon, over the D-Bus session bus.
type Session struct {
once sync.Once
conn *dbus.Conn // nil: no session bus (a server, a container, SSH without one)
}

// New is the system's notifier.
func New() Notifier { return &Session{} }

// urgency is the freedesktop hint: 1 normal, 2 critical (stays until dismissed on most desktops).
func urgency(urgent bool) byte {
if urgent {
return 2
}
return 1
}

// hints are the urgency and who sent it, as notify-send gives them.
func hints(urgent bool, pid int) map[string]dbus.Variant {
return map[string]dbus.Variant{"urgency": dbus.MakeVariant(urgency(urgent)), "sender-pid": dbus.MakeVariant(int64(pid))}
}

func (s *Session) Notify(summary, body string, urgent bool) {
s.once.Do(func() { s.conn, _ = dbus.ConnectSessionBus() })
if s.conn == nil {
return
}
// Notify(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout), sent as
// notify-send sends it: some daemons (quickshell here) didn't show one named "TrackLin.es" without sender-pid
s.conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications").Call(
"org.freedesktop.Notifications.Notify", 0, "tracklines", uint32(0), "", summary, body, []string{},
hints(urgent, os.Getpid()), int32(-1))
}
27 changes: 27 additions & 0 deletions internal/desktop/desktop_linux_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package desktop

import (
"testing"

"github.com/godbus/dbus/v5"
)

func TestUrgency(t *testing.T) {
if urgency(true) != 2 || urgency(false) != 1 {
t.Fatal("urgent is critical (2), the rest normal (1)")
}
}

// As notify-send sends them: some daemons drop ones without sender-pid.
func TestHints(t *testing.T) {
h := hints(true, 42)
if h["urgency"] != dbus.MakeVariant(byte(2)) || h["sender-pid"] != dbus.MakeVariant(int64(42)) {
t.Fatalf("hints: %v", h)
}
}

// No session bus (CI, SSH): nothing shown, nothing fails.
func TestNoBus(t *testing.T) {
t.Setenv("DBUS_SESSION_BUS_ADDRESS", "unix:path=/nonexistent")
(&Session{}).Notify("TrackLin.es", "Sam assigned you TL-1", false)
}
7 changes: 7 additions & 0 deletions internal/desktop/desktop_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !linux

package desktop

// New is the system's notifier: nothing yet off Linux.
// ponytail: macOS (osascript) and Windows (toast) when someone asks
func New() Notifier { return None{} }
14 changes: 14 additions & 0 deletions internal/i18n/de.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// de is German: English text → its translation. A missing entry shows the English (i18n_test finds it).
var de = map[string]string{
// notifications (TL-886)
"Notifications": "Benachrichtigungen",
"N %d unread": "N %d ungelesen",
"You’re all caught up.": "Du bist auf dem neuesten Stand.",
"Reminder: %s": "Erinnerung: %s",
"Someone": "Jemand",
"Cleared.": "Entfernt.",
"Couldn’t clear it": "Konnte nicht entfernt werden",
"All read.": "Alle gelesen.",
"Couldn’t mark them read": "Konnten nicht als gelesen markiert werden",
"Open it on the website: %s": "Auf der Website öffnen: %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k bewegen · enter öffnen · x entfernen · a alle gelesen · r neu laden · esc/q zurück",
"notifications (on Linux, new ones also go to the desktop)": "Benachrichtigungen (unter Linux kommen neue auch auf den Desktop)",

"open": "offen",

"Blocked by": "Blockiert durch",
Expand Down
14 changes: 14 additions & 0 deletions internal/i18n/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// es is Spanish: English text → its translation. A missing entry shows the English (i18n_test finds it).
var es = map[string]string{
// notifications (TL-886)
"Notifications": "Notificaciones",
"N %d unread": "N %d sin leer",
"You’re all caught up.": "Estás al día.",
"Reminder: %s": "Recordatorio: %s",
"Someone": "Alguien",
"Cleared.": "Quitada.",
"Couldn’t clear it": "No se pudo quitar",
"All read.": "Todas leídas.",
"Couldn’t mark them read": "No se pudieron marcar como leídas",
"Open it on the website: %s": "Ábrela en la web: %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k mover · enter abrir · x quitar · a marcar todo leído · r recargar · esc/q atrás",
"notifications (on Linux, new ones also go to the desktop)": "notificaciones (en Linux, las nuevas también van al escritorio)",

"open": "abierto",

"Blocked by": "Bloqueado por",
Expand Down
14 changes: 14 additions & 0 deletions internal/i18n/fr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// fr is French: English text → its translation. A missing entry shows the English (i18n_test finds it).
var fr = map[string]string{
// notifications (TL-886)
"Notifications": "Notifications",
"N %d unread": "N %d non lues",
"You’re all caught up.": "Vous êtes à jour.",
"Reminder: %s": "Rappel : %s",
"Someone": "Quelqu’un",
"Cleared.": "Effacée.",
"Couldn’t clear it": "Impossible de l’effacer",
"All read.": "Tout est lu.",
"Couldn’t mark them read": "Impossible de les marquer comme lues",
"Open it on the website: %s": "Ouvrez-la sur le site : %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k déplacer · entrée ouvrir · x effacer · a tout marquer lu · r recharger · échap/q retour",
"notifications (on Linux, new ones also go to the desktop)": "notifications (sous Linux, les nouvelles vont aussi sur le bureau)",

"open": "ouvert",

"Blocked by": "Bloqué par",
Expand Down
14 changes: 14 additions & 0 deletions internal/i18n/nl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// nl is Dutch: English text → Nederlands. A missing entry shows the English (i18n_test finds it).
var nl = map[string]string{
// notifications (TL-886)
"Notifications": "Meldingen",
"N %d unread": "N %d ongelezen",
"You’re all caught up.": "Je bent helemaal bij.",
"Reminder: %s": "Herinnering: %s",
"Someone": "Iemand",
"Cleared.": "Gewist.",
"Couldn’t clear it": "Kon niet wissen",
"All read.": "Alles gelezen.",
"Couldn’t mark them read": "Kon ze niet als gelezen markeren",
"Open it on the website: %s": "Open het op de website: %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k bewegen · enter openen · x wissen · a alles gelezen · r herladen · esc/q terug",
"notifications (on Linux, new ones also go to the desktop)": "meldingen (op Linux gaan nieuwe ook naar het bureaublad)",

"open": "open",

"Blocked by": "Geblokkeerd door",
Expand Down
14 changes: 14 additions & 0 deletions internal/i18n/pt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// pt is Brazilian Portuguese: English text → its translation. A missing entry shows the English (i18n_test finds it).
var pt = map[string]string{
// notifications (TL-886)
"Notifications": "Notificações",
"N %d unread": "N %d não lidas",
"You’re all caught up.": "Você está em dia.",
"Reminder: %s": "Lembrete: %s",
"Someone": "Alguém",
"Cleared.": "Removida.",
"Couldn’t clear it": "Não foi possível remover",
"All read.": "Todas lidas.",
"Couldn’t mark them read": "Não foi possível marcá-las como lidas",
"Open it on the website: %s": "Abra no site: %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k mover · enter abrir · x remover · a marcar tudo lido · r recarregar · esc/q voltar",
"notifications (on Linux, new ones also go to the desktop)": "notificações (no Linux, as novas também vão para a área de trabalho)",

"open": "aberto",

"Blocked by": "Bloqueado por",
Expand Down
14 changes: 14 additions & 0 deletions internal/i18n/tlh.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ package i18n

// tlh is Klingon, for fun: English text → its translation. A missing entry shows the English (i18n_test finds it).
var tlh = map[string]string{
// notifications (TL-886)
"Notifications": "De’ chu’mey",
"N %d unread": "N %d De’ chu’ laDbe’lu’",
"You’re all caught up.": "Hoch DaSovta’.",
"Reminder: %s": "yIqaw: %s",
"Someone": "vay’",
"Cleared.": "teq.",
"Couldn’t clear it": "teqlaHbe’",
"All read.": "Hoch laDlu’ta’.",
"Couldn’t mark them read": "laDlu’ta’ net ghItlhlaHbe’",
"Open it on the website: %s": "Daq yIpoSmoH: %s",
"j/k move · enter open · x clear · a mark all read · r reload · esc/q back": "j/k vIH · enter poSmoH · x teq · a Hoch laD · r chu’qa’ · esc/q chegh",
"notifications (on Linux, new ones also go to the desktop)": "De’ chu’mey (Linux Daq, chu’ De’ ’oH raSDaq ghoS)",

"open": "ta’be’",

"Blocked by": "botwI’",
Expand Down
1 change: 1 addition & 0 deletions internal/ui/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (v *aboutView) render(a *app) string {
{"V", T("saved views: open, save, rename or delete")},
{"ctrl+x", T("clear all filters on the current ticket list")},
{"t", T("go to a ticket by its key (TL-308)")},
{"N", T("notifications (on Linux, new ones also go to the desktop)")},
{"D", T("unsent drafts: comments and edits that didn't reach the server")},
{"esc / q", T("back (q quits on My work and Projects)")},
{"Q", T("quit from anywhere")},
Expand Down
13 changes: 12 additions & 1 deletion internal/ui/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ var (
// closed or the TUI gives up; removeForbidden: the file isn't yours to remove
uploadFails, removeForbidden bool
uploadHold chan struct{}
callsMu sync.Mutex // guards fakeAPI's calls while requests are in flight
fakeNotices []map[string]any // the bell's list (TL-886); unread ones have no read_at
callsMu sync.Mutex // guards fakeAPI's calls while requests are in flight
)

// fakeAPI is TrackLin.es for Sam: project TL with a Web board (To do → In progress → Done, Fibonacci
Expand Down Expand Up @@ -211,6 +212,16 @@ func fakeAPI(t *testing.T) (*Client, *[]string) {
w.Header().Set("ETag", `"h2"`)
out = []map[string]any{{"slug": "fresh", "question": "How do I add another board?", "answer": "From the API: Edit project → Boards.",
"href": "/projects/[project]/edit", "fallback_href": "", "pages": []string{"project"}, "words": "board"}}
case p == "/api/notifications/unread-count":
n := 0
for _, x := range fakeNotices {
if x["read_at"] == nil {
n++
}
}
out = map[string]any{"count": n}
case p == "/api/notifications" && r.Method == http.MethodGet:
out = fakeNotices
case p == "/api/assignees":
out = []map[string]any{{"id": "user_1", "label": "You", "name": "Sam Doe"}, {"id": "user_2", "label": "Alex", "name": "Alex Roe"}, {"id": "Claude", "label": "Claude", "kind": "ai"}}
case p == "/api/projects":
Expand Down
Loading
Loading