hintoptin_test.go RawHistoryFolder

1package app
2
3import (
4	"context"
5	"runtime"
6	"testing"
7	"time"
8
9	"github.com/stretchr/testify/require"
10
11	"github.com/bnema/neferwl/internal/adapters/clock"
12	"github.com/bnema/neferwl/internal/adapters/config"
13	"github.com/bnema/neferwl/internal/adapters/logging"
14	"github.com/bnema/neferwl/internal/adapters/xkb"
15	"github.com/bnema/neferwl/internal/ports"
16)
17
18func TestHintPipesOffByDefault(t *testing.T) {
19	require.False(t, config.Defaults().Hint.Enable)
20	off := newPipes(false, false)
21	require.Nil(t, off.hintScans)
22	require.Nil(t, off.hintResults)
23	require.Nil(t, off.hintCaptured)
24	// No demultiplexing: the outputs reply on the wayland channel itself.
25	require.Equal(t, off.captured, off.capturedAll)
26	ch := off.core()
27	require.Nil(t, ch.HintScans)
28	require.Nil(t, ch.Hints)
29	on := newPipes(false, true)
30	require.NotNil(t, on.hintScans)
31	require.NotNil(t, on.hintResults)
32	require.NotNil(t, on.hintCaptured)
33	require.NotEqual(t, on.captured, on.capturedAll)
34}
35
36func TestHintOffStartsNoHintGoroutine(t *testing.T) {
37	t.Setenv("XDG_RUNTIME_DIR", t.TempDir())
38	ctx, cancel := context.WithCancel(context.Background())
39	defer cancel()
40	done := make(chan error, 1)
41	go func() {
42		done <- Run(ctx, Options{Backend: "headless", NoXwayland: true, Config: config.Defaults(), NoTerminal: true, Timeout: 800 * time.Millisecond})
43	}()
44	time.Sleep(400 * time.Millisecond)
45	buf := make([]byte, 1<<20)
46	dump := string(buf[:runtime.Stack(buf, true)])
47	require.NotContains(t, dump, "adapters/hints.")
48	require.NotContains(t, dump, "routeCaptured")
49	select {
50	case <-done:
51	case <-time.After(3 * time.Second):
52		t.Fatal("session did not stop")
53	}
54}
55
56func TestRelayConfigKeepsStartupHintEnable(t *testing.T) {
57	ctx, cancel := context.WithCancel(context.Background())
58	defer cancel()
59	cur := config.Defaults()
60	in := make(chan ports.ConfigChanged, 1)
61	out := make(chan ports.ConfigChanged, 1)
62	go relayConfig(ctx, cur, in, out, make(chan *xkb.Keymap, 1), make(chan ports.InputDevicesConfig, 1), newCursors(clock.System{}, 0), make(chan ports.ClientCommand, 1), logging.For(ctx, "config"))
63	next := config.Defaults()
64	next.Hint.Enable = true
65	in <- ports.ConfigChanged{Config: next}
66	got := (<-out).Config.Hint
67	require.False(t, got.Enable)
68}
69
70func TestRelayConfigKeepsStartupHintDetector(t *testing.T) {
71	ctx, cancel := context.WithCancel(context.Background())
72	defer cancel()
73	cur := config.Defaults()
74	in := make(chan ports.ConfigChanged, 1)
75	out := make(chan ports.ConfigChanged, 1)
76	go relayConfig(ctx, cur, in, out, make(chan *xkb.Keymap, 1), make(chan ports.InputDevicesConfig, 1), newCursors(clock.System{}, 0), make(chan ports.ClientCommand, 1), logging.For(ctx, "config"))
77	next := config.Defaults()
78	next.Hint.Detector, next.Hint.Model, next.Hint.Threshold = "/other/nh", "/other/models", 0.5
79	in <- ports.ConfigChanged{Config: next}
80	got := (<-out).Config.Hint
81	require.Equal(t, cur.Hint.Detector, got.Detector)
82	require.Equal(t, cur.Hint.Model, got.Model)
83	require.Equal(t, cur.Hint.Threshold, got.Threshold)
84}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 23

Tags 10

↑↓ moveenter openesc close