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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ For other commands and options see, `daylog --help`.
`daylog tui` opens an interactive terminal UI for browsing and editing your logs. It lands on a ledger of every day, newest first, with a preview of each. From there you can:

- `↑`/`↓` move, `enter` to open a day
- `a` append a one-line entry, `e` open the day in `$EDITOR`, `y` copy the log
- `a` append a one-line entry, `e` open the day in `$EDITOR`, `c` copy the log (works from the day list too)
- `/` filter by date or text (searches log contents), `n` start a new day from a date
- `t` toggle todos, `p` switch projects, `?` for full help, `q` to quit

Expand Down
4 changes: 2 additions & 2 deletions internal/tui/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func defaultKeyMap() keyMap {
key.WithHelp("e", "edit in $EDITOR"),
),
Copy: key.NewBinding(
key.WithKeys("y"),
key.WithHelp("y", "copy log"),
key.WithKeys("c"),
key.WithHelp("c", "copy log"),
),
Projects: key.NewBinding(
key.WithKeys("p"),
Expand Down
21 changes: 20 additions & 1 deletion internal/tui/tui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1260,13 +1260,32 @@ func TestCopyKey(t *testing.T) {

m := newTestModel(t, projectPath, today)

_, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'y'}})
_, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}})
if cmd == nil {
t.Fatal("expected a copy cmd")
}
// don't execute it — that would touch the real clipboard
}

// c copies from the ledger too, hitting the highlighted day (not today, when a
// different day is highlighted). mirrors the log-view TestCopyKey
func TestCopyKeyFromLedger(t *testing.T) {
today := time.Date(2026, 7, 10, 12, 0, 0, 0, time.Local)
projectPath := t.TempDir()
seedLog(t, projectPath, "2026/07/08", "- older entry\n")

m := newLedgerModel(t, projectPath, today)
m.moveLedgerCursor(1) // highlight 2026/07/08
if day, _ := m.selectedDay(); day != "2026/07/08" {
t.Fatalf("expected 2026/07/08 selected, got %s", day)
}

_, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}})
if cmd == nil {
t.Fatal("expected a copy cmd from the ledger")
}
}

func TestCopyMissingLogReportsError(t *testing.T) {
projectPath := t.TempDir()

Expand Down
8 changes: 8 additions & 0 deletions internal/tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ func (m Model) onLedgerKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
}
return m, openEditor(m.projectPath, day)

case key.Matches(msg, m.keys.Copy):
// copy the selected day from the list, same as in the log view
day, ok := m.selectedDay()
if !ok {
return m, nil
}
return m, copyDay(m.projectPath, day)

case key.Matches(msg, m.keys.Older):
m.moveLedgerCursor(1) // older = further down the newest-first list
return m, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func (m Model) footerView() string {
if m.dayFilter.Focused() {
return footer.Render("filter by date or text • ↑/↓ move • enter open • esc clear")
}
return footer.Render("↑/↓ move • enter open • a append • n new day • / filter • p project • ? help")
return footer.Render("↑/↓ move • enter open • a append • c copy • n new day • / filter • p project • ? help")
}

if m.status != "" {
Expand Down