main 5041353

auth_window_observer.go RawHistoryFolder

1package content
2
3import (
4	"context"
5	"sync"
6	"time"
7
8	"github.com/bnema/dumber/internal/application/port"
9	"github.com/bnema/dumber/internal/logging"
10	"github.com/bnema/puregotk/v4/glib"
11)
12
13const nativePopupOAuthCloseDelay = 500 * time.Millisecond
14
15var scheduleNativePopupOAuthClose = func(delay time.Duration, fn func()) {
16	time.AfterFunc(delay, func() {
17		cb := glib.SourceFunc(func(_ uintptr) bool {
18			fn()
19			return false
20		})
21		glib.IdleAdd(&cb, 0)
22	})
23}
24
25func (c *Coordinator) ObserveNativePopupAuth(ctx context.Context, input NativePopupInput) {
26	if c == nil || input.PopupWebView == nil || !IsOAuthURL(input.TargetURI) {
27		return
28	}
29
30	popupID := input.PopupWebView.ID()
31
32	oauthWV, ok := input.PopupWebView.(port.OAuthCallbackCapable)
33	if !ok {
34		logging.FromContext(ctx).Debug().
35			Uint64("popup_id", uint64(popupID)).
36			Msg("native popup auth observation skipped: webview lacks OAuth callbacks")
37		return
38	}
39	c.trackOAuthPopup(popupID, input.ParentPaneID, input.ParentURIAtOpen)
40
41	var requestCloseOnce sync.Once
42	requestClose := func(reason string) {
43		requestCloseOnce.Do(func() {
44			logging.FromContext(ctx).Info().
45				Uint64("popup_id", uint64(popupID)).
46				Str("reason", reason).
47				Msg("native popup oauth callback detected, closing popup")
48			scheduleNativePopupOAuthClose(nativePopupOAuthCloseDelay, func() {
49				if input.PopupWebView != nil && !input.PopupWebView.IsDestroyed() {
50					oauthWV.Close()
51				}
52			})
53		})
54	}
55
56	oauthWV.AddNavigationCallback(func(uri string) {
57		if !ShouldAutoClose(uri) {
58			return
59		}
60		c.capturePopupOAuthState(popupID, uri)
61		requestClose("navigation")
62	})
63	oauthWV.AddCloseCallback(func() {
64		c.handlePopupOAuthClose(context.Background(), popupID)
65	})
66
67	logging.FromContext(ctx).Debug().
68		Uint64("popup_id", uint64(popupID)).
69		Str("target_uri", logging.TruncateURL(input.TargetURI, logURLMaxLen)).
70		Msg("native popup auth observer configured")
71}

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 8

Tags 42

↑↓ moveenter openesc close