hint.go RawHistoryFolder

1package app
2
3import (
4	"context"
5	"os"
6	"path/filepath"
7
8	"github.com/bnema/neferwl/internal/adapters/hints"
9	"github.com/bnema/neferwl/internal/adapters/logging"
10	"github.com/bnema/neferwl/internal/ports"
11)
12
13// hintOptions builds the hint worker options from the configuration (read at
14// startup) and, when NEFERWL_HINT_DEBUG is "1", the dump directory of scanned
15// frames, $XDG_STATE_HOME/neferwl/hints. The detector process only starts at
16// the first scan.
17func hintOptions(ctx context.Context, cfg ports.Config) hints.Options {
18	opts := hintDump(ctx)
19	opts.Command, opts.ModelDir, opts.Threshold = cfg.Hint.Detector, cfg.Hint.Model, cfg.Hint.Threshold
20	return opts
21}
22
23// hintDump reads NEFERWL_HINT_DEBUG once.
24func hintDump(ctx context.Context) hints.Options {
25	if os.Getenv("NEFERWL_HINT_DEBUG") != "1" {
26		return hints.Options{}
27	}
28	log := logging.For(ctx, "hints")
29	state := os.Getenv("XDG_STATE_HOME")
30	if state == "" {
31		home, err := os.UserHomeDir()
32		if err != nil {
33			log.Warn().Err(err).Msg("hint debug dumps disabled")
34			return hints.Options{}
35		}
36		state = filepath.Join(home, ".local", "state")
37	}
38	dir := filepath.Join(state, "neferwl", "hints")
39	log.Warn().Str("dir", dir).Msg("hint debug dumps enabled")
40	return hints.Options{DumpDir: dir}
41}
42
43// hintDisabledNote returns the once-only notice for a hint bind pressed while
44// hint mode is off. The logger is made now; nothing else of hint mode exists.
45func hintDisabledNote(ctx context.Context) func() {
46	log := logging.For(ctx, "core")
47	return func() { log.Info().Msg("hint mode is disabled; set hint.enable = on and restart") }
48}

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 25

Tags 10

↑↓ moveenter openesc close