coordinator

package
v0.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBehavior

func GetBehavior(popupType PopupType, cfg *config.PopupBehaviorConfig) config.PopupBehavior

GetBehavior returns the appropriate behavior based on popup type and config.

func IsOAuthCallback

func IsOAuthCallback(url string) bool

IsOAuthCallback checks if the URL is an OAuth callback with response parameters. This indicates the OAuth flow has completed (successfully or with error).

func IsOAuthError

func IsOAuthError(url string) bool

IsOAuthError checks if the callback indicates an authentication error.

func IsOAuthSuccess

func IsOAuthSuccess(url string) bool

IsOAuthSuccess checks if the callback indicates successful authentication.

func IsOAuthURL

func IsOAuthURL(url string) bool

IsOAuthURL checks if the URL is related to an OAuth flow. This includes authorization endpoints, login pages, and callback URLs.

func ShouldAutoClose

func ShouldAutoClose(url string) bool

ShouldAutoClose determines if a popup at this URL should auto-close. Returns true for OAuth callbacks that indicate flow completion.

This is comprehensive detection that handles: - Success: code=, access_token=, id_token= - Errors: error=, error_description= - Various OAuth providers (Google, GitHub, Auth0, etc.)

Types

type ContentCoordinator

type ContentCoordinator struct {
	// contains filtered or unexported fields
}

ContentCoordinator manages WebView lifecycle, title tracking, and content attachment.

func NewContentCoordinator

func NewContentCoordinator(
	ctx context.Context,
	pool *webkit.WebViewPool,
	widgetFactory layout.WidgetFactory,
	faviconAdapter *adapter.FaviconAdapter,
	getActiveWS func() (*entity.Workspace, *component.WorkspaceView),
	zoomUC *usecase.ManageZoomUseCase,
) *ContentCoordinator

NewContentCoordinator creates a new ContentCoordinator.

func (*ContentCoordinator) ActiveWebView

func (c *ContentCoordinator) ActiveWebView(ctx context.Context) *webkit.WebView

ActiveWebView returns the WebView for the active pane.

func (*ContentCoordinator) ApplyFiltersToAll

func (c *ContentCoordinator) ApplyFiltersToAll(ctx context.Context, applier webkit.FilterApplier)

ApplyFiltersToAll applies content filters to all active webviews. Called when filters become available after webviews were already created.

func (*ContentCoordinator) ApplySettingsToAll

func (c *ContentCoordinator) ApplySettingsToAll(ctx context.Context, sm *webkit.SettingsManager)

ApplySettingsToAll reapplies WebKit settings to all active WebViews.

func (*ContentCoordinator) ApplyWebUIThemeToAll

func (c *ContentCoordinator) ApplyWebUIThemeToAll(ctx context.Context, prefersDark bool, cssText string)

ApplyWebUIThemeToAll updates theme CSS for already-loaded dumb:// pages. This is necessary because user scripts only run on navigation.

func (*ContentCoordinator) AttachToWorkspace

func (c *ContentCoordinator) AttachToWorkspace(ctx context.Context, ws *entity.Workspace, wsView *component.WorkspaceView)

AttachToWorkspace ensures each pane in the workspace has a WebView widget attached.

func (*ContentCoordinator) EnsureWebView

func (c *ContentCoordinator) EnsureWebView(ctx context.Context, paneID entity.PaneID) (*webkit.WebView, error)

EnsureWebView acquires or reuses a WebView for the given pane.

func (*ContentCoordinator) FaviconAdapter

func (c *ContentCoordinator) FaviconAdapter() *adapter.FaviconAdapter

FaviconAdapter returns the favicon adapter for external use (e.g., omnibox).

func (*ContentCoordinator) GetTitle

func (c *ContentCoordinator) GetTitle(paneID entity.PaneID) string

GetTitle returns the current title for a pane.

func (*ContentCoordinator) GetWebView

func (c *ContentCoordinator) GetWebView(paneID entity.PaneID) *webkit.WebView

GetWebView returns the WebView for a specific pane.

func (*ContentCoordinator) PreloadCachedFavicon

func (c *ContentCoordinator) PreloadCachedFavicon(ctx context.Context, paneID entity.PaneID, url string)

PreloadCachedFavicon checks the favicon cache and updates the stacked pane title bar immediately if a cached favicon exists for the URL. This provides instant favicon display without waiting for WebKit.

func (*ContentCoordinator) RefreshInjectedScriptsToAll

func (c *ContentCoordinator) RefreshInjectedScriptsToAll(ctx context.Context, injector *webkit.ContentInjector)

RefreshInjectedScriptsToAll clears and re-injects user scripts into all active WebViews.

WebKit user scripts are snapshotted when added to a WebKitUserContentManager, so when appearance settings change at runtime (dark mode, palettes, UI scale), we must refresh the scripts so future navigations pick up the latest values.

func (*ContentCoordinator) RegisterPopupWebView

func (c *ContentCoordinator) RegisterPopupWebView(paneID entity.PaneID, wv *webkit.WebView)

RegisterPopupWebView registers a popup WebView that was created externally. This is used when popup tabs are created and the WebView needs to be tracked.

func (*ContentCoordinator) ReleaseWebView

func (c *ContentCoordinator) ReleaseWebView(ctx context.Context, paneID entity.PaneID)

ReleaseWebView returns the WebView for a pane to the pool.

func (*ContentCoordinator) SetGestureActionHandler

func (c *ContentCoordinator) SetGestureActionHandler(handler input.ActionHandler)

SetGestureActionHandler sets the callback for mouse button navigation gestures.

func (*ContentCoordinator) SetIdleInhibitor added in v0.20.1

func (c *ContentCoordinator) SetIdleInhibitor(inhibitor port.IdleInhibitor)

SetIdleInhibitor sets the idle inhibitor for fullscreen video playback.

func (*ContentCoordinator) SetNavigationOrigin

func (c *ContentCoordinator) SetNavigationOrigin(paneID entity.PaneID, url string)

SetNavigationOrigin records the original URL before navigation starts. This allows caching favicons under both original and final domains when cross-domain redirects occur (e.g., google.fr → google.com).

func (*ContentCoordinator) SetOnClosePane

func (c *ContentCoordinator) SetOnClosePane(fn func(ctx context.Context, paneID entity.PaneID) error)

SetOnClosePane sets the callback to close a pane when its popup closes.

func (*ContentCoordinator) SetOnHistoryRecord

func (c *ContentCoordinator) SetOnHistoryRecord(fn func(ctx context.Context, paneID entity.PaneID, url string))

SetOnHistoryRecord sets the callback for recording history on page commit.

func (*ContentCoordinator) SetOnInsertPopup

func (c *ContentCoordinator) SetOnInsertPopup(fn func(ctx context.Context, input InsertPopupInput) error)

SetOnInsertPopup sets the callback to insert popups into the workspace.

func (*ContentCoordinator) SetOnPaneURIUpdated added in v0.21.0

func (c *ContentCoordinator) SetOnPaneURIUpdated(fn func(paneID entity.PaneID, url string))

SetOnPaneURIUpdated sets the callback for pane URI changes (for session snapshots).

func (*ContentCoordinator) SetOnTitleUpdated

func (c *ContentCoordinator) SetOnTitleUpdated(fn func(ctx context.Context, paneID entity.PaneID, url, title string))

SetOnTitleUpdated sets the callback for title changes (for history persistence).

func (*ContentCoordinator) SetOnWindowTitleChanged added in v0.21.0

func (c *ContentCoordinator) SetOnWindowTitleChanged(fn func(title string))

SetOnWindowTitleChanged sets the callback for active pane title changes (for window title updates).

func (*ContentCoordinator) SetPopupConfig

func (c *ContentCoordinator) SetPopupConfig(
	factory *webkit.WebViewFactory,
	popupConfig *config.PopupBehaviorConfig,
	generateID func() string,
)

SetPopupConfig configures popup handling.

func (*ContentCoordinator) SetupPopupHandling

func (c *ContentCoordinator) SetupPopupHandling(ctx context.Context, paneID entity.PaneID, wv *webkit.WebView)

SetupPopupHandling wires the popup create signal for a WebView. This should be called after acquiring a WebView for a pane.

func (*ContentCoordinator) WrapWidget

func (c *ContentCoordinator) WrapWidget(ctx context.Context, wv *webkit.WebView) layout.Widget

WrapWidget converts a WebView to a layout.Widget for embedding. It also attaches gesture handlers for mouse button navigation.

type InsertPopupInput

type InsertPopupInput struct {
	// ParentPaneID is the pane that spawned this popup.
	ParentPaneID entity.PaneID

	// PopupPane is the pre-created pane entity for the popup.
	// It should have IsRelated=true and ParentPaneID set.
	PopupPane *entity.Pane

	// WebView is the related WebView for the popup.
	WebView *webkit.WebView

	// Behavior determines how the popup is inserted (split/stacked/tabbed).
	Behavior config.PopupBehavior

	// Placement specifies direction for split behavior (right/left/top/bottom).
	Placement string

	// PopupType indicates if this is a tab-like or JS popup.
	PopupType PopupType

	// TargetURI is the URL to load in the popup.
	TargetURI string
}

InsertPopupInput contains the data needed to insert a popup into the workspace.

type NavigationCoordinator struct {
	// contains filtered or unexported fields
}

NavigationCoordinator handles URL navigation, history, and browser controls.

func NewNavigationCoordinator

func NewNavigationCoordinator(
	ctx context.Context,
	navigateUC *usecase.NavigateUseCase,
	contentCoord *ContentCoordinator,
) *NavigationCoordinator

NewNavigationCoordinator creates a new NavigationCoordinator.

func (c *NavigationCoordinator) ActiveWebView(ctx context.Context) *webkit.WebView

ActiveWebView returns the WebView for the active pane (for zoom operations).

func (c *NavigationCoordinator) GoBack(ctx context.Context) error

GoBack navigates back in history.

func (c *NavigationCoordinator) GoForward(ctx context.Context) error

GoForward navigates forward in history.

func (c *NavigationCoordinator) HardReload(ctx context.Context) error

HardReload reloads the current page bypassing cache.

func (c *NavigationCoordinator) Navigate(ctx context.Context, url string) error

Navigate loads a URL in the active pane using NavigateUseCase. This properly handles history recording and zoom application.

func (c *NavigationCoordinator) NotifyZoomChanged(ctx context.Context, factor float64)

NotifyZoomChanged updates the omnibox zoom indicator.

func (c *NavigationCoordinator) OpenDevTools(ctx context.Context) error

OpenDevTools opens the WebKit inspector for the active WebView.

func (c *NavigationCoordinator) OpenOmnibox(ctx context.Context) error

OpenOmnibox toggles the omnibox visibility.

func (c *NavigationCoordinator) RecordHistory(ctx context.Context, paneID entity.PaneID, url string)

RecordHistory records a URL in history on page commit.

func (c *NavigationCoordinator) Reload(ctx context.Context) error

Reload reloads the current page.

func (c *NavigationCoordinator) SetOmniboxProvider(provider OmniboxProvider)

SetOmniboxProvider sets the omnibox provider for toggle/zoom operations.

func (c *NavigationCoordinator) UpdateHistoryTitle(ctx context.Context, paneID entity.PaneID, url, title string)

UpdateHistoryTitle updates the title of a history entry after page load.

type OmniboxProvider

type OmniboxProvider interface {
	ToggleOmnibox(ctx context.Context)
	UpdateOmniboxZoom(factor float64)
	SetOmniboxOnNavigate(fn func(url string))
}

OmniboxProvider provides access to omnibox operations.

type PendingPopup

type PendingPopup struct {
	// WebView is the related WebView created in the "create" phase.
	// It shares cookies/session with the parent for OAuth support.
	WebView *webkit.WebView

	// ParentPaneID is the pane that spawned this popup.
	ParentPaneID entity.PaneID

	// ParentWebViewID is the WebView ID of the parent (for lookup).
	ParentWebViewID port.WebViewID

	// TargetURI is the initial URL the popup will load.
	TargetURI string

	// FrameName is the target frame name from the navigation action.
	// "_blank" indicates a tab-like popup, other values indicate JS popups.
	FrameName string

	// IsUserGesture indicates if the popup was triggered by user action
	// (click) vs script-initiated (e.g., popup after timeout).
	IsUserGesture bool

	// PopupType categorizes this as a tab-like or JS popup.
	PopupType PopupType

	// CreatedAt is when the popup was created (for timeout handling).
	CreatedAt time.Time
}

PendingPopup tracks a popup WebView that has been created but not yet inserted into the workspace. This is used during the three-phase popup lifecycle: create → ready-to-show → (insert into workspace).

type PopupType

type PopupType int

PopupType indicates whether the popup was triggered by a link or JavaScript.

const (
	// PopupTypeTab represents a popup from target="_blank" links.
	// These are typically user-initiated and open like new tabs.
	PopupTypeTab PopupType = iota
	// PopupTypePopup represents a popup from window.open() JavaScript calls.
	// These may have different placement behavior than tab-like popups.
	PopupTypePopup
)

func DetectPopupType

func DetectPopupType(frameName string) PopupType

DetectPopupType determines if this is a tab-like or JS popup based on frame name.

func (PopupType) String

func (t PopupType) String() string

String returns a human-readable name for the popup type.

type TabCoordinator

type TabCoordinator struct {
	// contains filtered or unexported fields
}

TabCoordinator manages tab lifecycle operations.

func NewTabCoordinator

func NewTabCoordinator(ctx context.Context, cfg TabCoordinatorConfig) *TabCoordinator

NewTabCoordinator creates a new TabCoordinator.

func (*TabCoordinator) Close

func (c *TabCoordinator) Close(ctx context.Context) error

Close closes the active tab.

func (*TabCoordinator) Create

func (c *TabCoordinator) Create(ctx context.Context, initialURL string) (*entity.Tab, error)

Create creates a new tab with the given initial URL.

func (*TabCoordinator) CreateWithPane

func (c *TabCoordinator) CreateWithPane(
	ctx context.Context,
	pane *entity.Pane,
	wv *webkit.WebView,
	initialURL string,
) (*entity.Tab, error)

CreateWithPane creates a new tab with a pre-created pane and WebView. This is used for tabbed popup behavior where the popup pane already exists.

func (*TabCoordinator) GetTabBar

func (c *TabCoordinator) GetTabBar() *component.TabBar

GetTabBar returns the tab bar component.

func (*TabCoordinator) SetOnAttachPopupToTab

func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv *webkit.WebView))

SetOnAttachPopupToTab sets the callback for attaching popup WebViews to tabs.

func (*TabCoordinator) SetOnQuit

func (c *TabCoordinator) SetOnQuit(fn func())

SetOnQuit sets the callback for when the last tab is closed.

func (*TabCoordinator) SetOnStateChanged added in v0.21.0

func (c *TabCoordinator) SetOnStateChanged(fn func())

SetOnStateChanged sets the callback for when tab state changes (for session snapshots).

func (*TabCoordinator) SetOnTabCreated

func (c *TabCoordinator) SetOnTabCreated(fn func(ctx context.Context, tab *entity.Tab))

SetOnTabCreated sets the callback for when a tab is created.

func (*TabCoordinator) SetOnTabSwitched

func (c *TabCoordinator) SetOnTabSwitched(fn func(ctx context.Context, tab *entity.Tab))

SetOnTabSwitched sets the callback for when a tab switch occurs. This is used to swap workspace views in the content area.

func (*TabCoordinator) Switch

func (c *TabCoordinator) Switch(ctx context.Context, tabID entity.TabID) error

Switch switches to a specific tab by ID.

func (*TabCoordinator) SwitchByIndex

func (c *TabCoordinator) SwitchByIndex(ctx context.Context, index int) error

SwitchByIndex switches to a tab by 0-based index.

func (*TabCoordinator) SwitchNext

func (c *TabCoordinator) SwitchNext(ctx context.Context) error

SwitchNext switches to the next tab.

func (*TabCoordinator) SwitchPrev

func (c *TabCoordinator) SwitchPrev(ctx context.Context) error

SwitchPrev switches to the previous tab.

func (*TabCoordinator) SwitchToLastActive

func (c *TabCoordinator) SwitchToLastActive(ctx context.Context) error

SwitchToLastActive switches to the previously active tab (Alt+Tab style).

func (*TabCoordinator) UpdateBarVisibility

func (c *TabCoordinator) UpdateBarVisibility(ctx context.Context)

UpdateBarVisibility shows or hides the tab bar based on tab count.

type TabCoordinatorConfig

type TabCoordinatorConfig struct {
	TabsUC     *usecase.ManageTabsUseCase
	Tabs       *entity.TabList
	MainWindow *window.MainWindow
	Config     *config.Config
}

TabCoordinatorConfig holds configuration for TabCoordinator.

type UpdateCoordinator added in v0.21.0

type UpdateCoordinator struct {
	// contains filtered or unexported fields
}

UpdateCoordinator handles update checking and notification.

func NewUpdateCoordinator added in v0.21.0

func NewUpdateCoordinator(
	checkUC *usecase.CheckUpdateUseCase,
	applyUC *usecase.ApplyUpdateUseCase,
	toaster *component.Toaster,
	cfg *config.Config,
) *UpdateCoordinator

NewUpdateCoordinator creates a new update coordinator.

func (*UpdateCoordinator) CheckOnStartup added in v0.21.0

func (c *UpdateCoordinator) CheckOnStartup(ctx context.Context)

CheckOnStartup performs an async update check if enabled in config. This should be called during app initialization.

func (*UpdateCoordinator) FinalizeOnExit added in v0.21.0

func (c *UpdateCoordinator) FinalizeOnExit(ctx context.Context) error

FinalizeOnExit applies any staged update during shutdown. This should be called from the app's shutdown handler.

func (*UpdateCoordinator) HasPendingUpdate added in v0.21.0

func (c *UpdateCoordinator) HasPendingUpdate(ctx context.Context) bool

HasPendingUpdate returns true if an update is staged for exit.

func (*UpdateCoordinator) LastCheckResult added in v0.21.0

func (c *UpdateCoordinator) LastCheckResult() *usecase.CheckUpdateOutput

LastCheckResult returns the result of the last update check.

func (*UpdateCoordinator) Status added in v0.21.0

Status returns the current update status.

type WorkspaceCoordinator

type WorkspaceCoordinator struct {
	// contains filtered or unexported fields
}

WorkspaceCoordinator manages pane operations within a workspace.

func NewWorkspaceCoordinator

func NewWorkspaceCoordinator(ctx context.Context, cfg WorkspaceCoordinatorConfig) *WorkspaceCoordinator

NewWorkspaceCoordinator creates a new WorkspaceCoordinator.

func (*WorkspaceCoordinator) ClosePane

func (c *WorkspaceCoordinator) ClosePane(ctx context.Context) error

ClosePane closes the active pane.

func (*WorkspaceCoordinator) ClosePaneByID

func (c *WorkspaceCoordinator) ClosePaneByID(ctx context.Context, paneID entity.PaneID) error

ClosePaneByID closes a specific pane by ID. This is used for closing popup panes when window.close() is called.

func (*WorkspaceCoordinator) ConsumeOrExpelPane added in v0.21.0

func (c *WorkspaceCoordinator) ConsumeOrExpelPane(ctx context.Context, direction usecase.ConsumeOrExpelDirection) error

func (*WorkspaceCoordinator) FocusPane

func (c *WorkspaceCoordinator) FocusPane(ctx context.Context, direction usecase.NavigateDirection) error

FocusPane navigates focus to an adjacent pane.

func (*WorkspaceCoordinator) InsertPopup

func (c *WorkspaceCoordinator) InsertPopup(ctx context.Context, input InsertPopupInput) error

InsertPopup inserts a popup pane into the workspace based on the specified behavior. Supports split, stacked, and tabbed behaviors.

func (*WorkspaceCoordinator) NavigateStack

func (c *WorkspaceCoordinator) NavigateStack(ctx context.Context, direction string) error

NavigateStack navigates up or down within a stacked pane container.

func (*WorkspaceCoordinator) Resize added in v0.21.0

Resize updates the active split ratio and applies it to GTK widgets.

func (*WorkspaceCoordinator) SetOnCloseLastPane

func (c *WorkspaceCoordinator) SetOnCloseLastPane(fn func(ctx context.Context) error)

SetOnCloseLastPane sets the callback for when the last pane is closed.

func (*WorkspaceCoordinator) SetOnCreatePopupTab

func (c *WorkspaceCoordinator) SetOnCreatePopupTab(fn func(ctx context.Context, input InsertPopupInput) error)

SetOnCreatePopupTab sets the callback for creating popup tabs. This is used when popup behavior is "tabbed".

func (*WorkspaceCoordinator) SetOnStateChanged added in v0.21.0

func (c *WorkspaceCoordinator) SetOnStateChanged(fn func())

SetOnStateChanged sets the callback for when workspace state changes (for session snapshots).

func (*WorkspaceCoordinator) SetSplitRatio added in v0.21.0

func (c *WorkspaceCoordinator) SetSplitRatio(ctx context.Context, splitNodeID string, ratio float64) error

func (*WorkspaceCoordinator) ShowToastOnActivePane

func (c *WorkspaceCoordinator) ShowToastOnActivePane(ctx context.Context, message string, level component.ToastLevel)

ShowToastOnActivePane displays a toast notification on the active pane.

func (*WorkspaceCoordinator) ShowZoomToast

func (c *WorkspaceCoordinator) ShowZoomToast(ctx context.Context, zoomPercent int)

ShowZoomToast displays a zoom level toast on the active pane.

func (*WorkspaceCoordinator) Split

Split splits the active pane in the given direction.

func (*WorkspaceCoordinator) StackPane

func (c *WorkspaceCoordinator) StackPane(ctx context.Context) error

StackPane adds a new pane stacked on top of the active pane.

type WorkspaceCoordinatorConfig

type WorkspaceCoordinatorConfig struct {
	PanesUC        *usecase.ManagePanesUseCase
	FocusMgr       *focus.Manager
	StackedPaneMgr *component.StackedPaneManager
	WidgetFactory  layout.WidgetFactory
	ContentCoord   *ContentCoordinator
	GetActiveWS    func() (*entity.Workspace, *component.WorkspaceView)
	GenerateID     func() string
}

WorkspaceCoordinatorConfig holds configuration for WorkspaceCoordinator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL