feat: add search with preview

This commit is contained in:
2026-02-02 20:32:19 -06:00
parent 2aa49faad5
commit 155d8c4c1d
7 changed files with 584 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ import (
"playback/internal/ui"
"playback/internal/ui/header"
"playback/internal/ui/legend"
"playback/internal/ui/search"
"playback/internal/ui/transcript"
"playback/internal/ui/waveform"
)
@@ -37,6 +38,7 @@ type Model struct {
legend legend.Model
waveform waveform.Model
transcript transcript.Model
search search.Model
// State
showHelp bool
@@ -61,6 +63,7 @@ func New(audioPath, transcriptPath string) Model {
legend: legend.New(),
waveform: waveform.New(),
transcript: transcript.New(),
search: search.New(),
}
return m
@@ -138,6 +141,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.updateLayout()
case tea.KeyMsg:
// Search overlay takes priority
if m.search.IsOpen() {
cmd := m.search.Update(msg)
cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)
}
// All shortcuts are now global
switch {
case key.Matches(msg, m.keys.Quit):
@@ -168,6 +178,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case key.Matches(msg, m.keys.SeekBackwardBig):
m.player.SeekRelative(-m.config.BigSeekStep)
case key.Matches(msg, m.keys.Search):
cmd := m.search.Open(m.transcript.AllCues())
cmds = append(cmds, cmd)
// Transcript navigation and other keys forward to transcript
default:
cmd := m.transcript.Update(msg)
@@ -211,6 +225,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case transcript.SeekToCueMsg:
m.player.Seek(msg.Position)
case search.SeekToSearchResultMsg:
m.player.Seek(msg.Position)
}
return m, tea.Batch(cmds...)
@@ -247,6 +264,7 @@ func (m *Model) updateLayout() {
m.legend.SetWidth(m.width)
m.waveform.SetSize(m.width, waveformHeight)
m.transcript.SetSize(m.width, transcriptHeight)
m.search.SetSize(m.width, m.height)
}
func (m Model) launchEditor() tea.Cmd {
@@ -285,6 +303,10 @@ func (m Model) View() string {
return m.renderHelp()
}
if m.search.IsOpen() {
return m.search.View()
}
// Header
headerView := m.header.View(m.player.Position(), m.player.Duration(), m.player.IsPlaying())