v0.3.94 e344aa8

lifecycle.go RawHistoryFolder

1package extensions
2
3import (
4	"crypto/rand"
5
6	"github.com/patriceckhart/zot/packages/agent/extproto"
7)
8
9// StartSession opens an active-conversation lifecycle, closing its predecessor
10// first. Empty IDs get a process-local identity for non-persisted sessions.
11func (m *Manager) StartSession(id, cwd, reason string) {
12	m.lifecycleMu.Lock()
13	defer m.lifecycleMu.Unlock()
14	if m.stopping {
15		return
16	}
17	if cwd == "" {
18		cwd = m.cwd
19	}
20	if id == "" && m.sessionID != "" && !m.sessionClosed && cwd == m.sessionCWD {
21		return
22	}
23	if id != "" && id == m.sessionID && cwd == m.sessionCWD && !m.sessionClosed {
24		return
25	}
26	if m.sessionID != "" && !m.sessionClosed {
27		if reason == "" {
28			reason = "session_switch"
29		}
30		m.emitEventLocked(extproto.EventFromHost{Event: "session_end", Reason: reason})
31	}
32	if id == "" {
33		id = rand.Text()
34	}
35	m.sessionID, m.sessionCWD, m.sessionClosed = id, cwd, false
36	m.emitEventLocked(extproto.EventFromHost{Event: "session_start"})
37}
38
39// SessionContext returns the active conversation identity and working directory.
40func (m *Manager) SessionContext() (string, string) {
41	m.lifecycleMu.Lock()
42	defer m.lifecycleMu.Unlock()
43	return m.sessionID, m.sessionCWD
44}
45
46// EndSession emits at most one end notification per active lifecycle. It is
47// observational: it does not close the persisted session or stop subprocesses.
48func (m *Manager) EndSession(reason string) {
49	m.lifecycleMu.Lock()
50	defer m.lifecycleMu.Unlock()
51	m.endSessionLocked(reason)
52}
53
54func (m *Manager) stopLifecycle() {
55	m.lifecycleMu.Lock()
56	defer m.lifecycleMu.Unlock()
57	m.endSessionLocked("shutdown")
58	m.stopping = true
59}
60
61func (m *Manager) endSessionLocked(reason string) {
62	if m.sessionID == "" || m.sessionClosed {
63		return
64	}
65	m.emitEventLocked(extproto.EventFromHost{Event: "session_end", Reason: reason})
66	m.sessionClosed = true
67}

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 1

Tags 477

↑↓ moveenter openesc close