Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions desktop/internal/core/remote_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,15 @@ func WithRemoteWorkspace(ctx context.Context, binding *RemoteWorkspace) context.
return context.WithValue(ctx, remoteWorkspaceKey{}, binding)
}

// payloadOnlyCommands are the commands an open document or the Project tool window sends that
// compute only from their payload: Core's handler reads no file, starts no process and names no
// payloadOnlyCommands are the commands an open document, the Project tool window or the search
// sends that compute only from their payload: Core's handler reads no file, starts no process and names no
// workspace path, so the answer is the same on any computer. They go without the remote
// workspace, which Core would refuse for want of an adapter, and keep working while the host is
// disconnected, so the user can still type, decode the bytes the host returned and plan the save
// that will then fail. workspace.filterChanges drops the host watch's changes in folders Core
// hides, by name alone.
// hides, by name alone; workspace.searchPresentation groups search results by the paths it is
// sent, and workspace.replaceText replaces in the text it is sent, which Replace All read from
// the host.
//
// Add a command here only after reading its Core handler; a command that touches the workspace
// sent without the binding would read the empty placeholder instead of the host.
Expand All @@ -411,6 +413,8 @@ var payloadOnlyCommands = map[string]bool{
"text.decode": true,
"text.encode": true,
"workspace.filterChanges": true,
"workspace.replaceText": true,
"workspace.searchPresentation": true,
}

// RemoteWorkspaceOf is the binding WithRemoteWorkspace put in ctx, nil for a local context.
Expand Down
8 changes: 4 additions & 4 deletions desktop/internal/i18n/shared.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions desktop/internal/workbench/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ type Kernel interface {
ReduceDocument(ctx context.Context, state core.DocumentState, event core.DocumentEvent) (core.DocumentDecision, error)
SearchWorkspace(ctx context.Context, request core.WorkspaceSearchRequest) ([]core.WorkspaceSearchMatch, error)
SearchWorkspacePage(ctx context.Context, request core.WorkspaceSearchRequest) (core.WorkspaceSearchPage, error)
CountWorkspaceSearch(ctx context.Context, request core.WorkspaceSearchRequest) (core.WorkspaceSearchCounts, error)
InvalidateWorkspaceSearch(ctx context.Context, root string) error
FilterWorkspaceChanges(ctx context.Context, paths []string) ([]string, error)
UpdateWorkspaceSearch(ctx context.Context, root string, paths []string) error
Expand Down
4 changes: 3 additions & 1 deletion desktop/internal/workbench/navigation_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ func (a *App) stepNavigation(p *project, forward bool) {
return
}
// A destination that no longer exists keeps the history as it was, so the entry is not lost.
if _, err := os.Stat(destination.Document); err != nil {
// A remote workspace's file is on the host, not at its placeholder path: opening it reads the
// host and tells the user when the file is gone.
if _, err := os.Stat(destination.Document); err != nil && p.remote == nil {
a.operationRejected("editor_navigation_history", "destination_unavailable")
a.notifyError(i18n.Shared(a.language(), "desktop.navigation.historyUnavailable"))
return
Expand Down
64 changes: 64 additions & 0 deletions desktop/internal/workbench/remote_search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package workbench

// This file keeps the search index of a remote workspace current. Find in Files, Search
// Everywhere and Replace All run with the workspace's remote binding, so Core builds the index
// from the host's folder and answers with paths relative to it, which open in the remote editor.
// The local watch cannot observe the host, so the host watch (remote_watch.go) feeds the index in
// its place: the changed paths it reports update the index before the next query, and its start,
// and a batch it lost, build the index again. While it does not watch all of the folder, from a
// lost session until it starts again with the next one, or after the host ran out of watches,
// every query builds the index from the host again.
//
// The host watch leaves out the folders the plugins hide. A search that includes generated files
// reads some of them, so it builds the index again for every query; Search Everywhere's generated
// file names are read again each time the popup opens. Language servers do not run for a remote
// workspace yet, so Search Everywhere's symbols are only those Core finds in the host's files.

// remoteWatching reports whether p is a remote workspace whose host watch watches all of its
// folder, so the host's changes reach the search index (remoteSearchChanged).
func (p *project) remoteWatching() bool {
r := p.remote
return r != nil && r.watch != nil && r.watch.watching && !r.watch.partial
}

// remoteWatchMisses reports whether a search of p that includes generated files (generated)
// reads folders its host watch leaves out, whose changes never reach the index.
func (p *project) remoteWatchMisses(generated bool) bool {
return p.remote != nil && generated
}

// remoteSearchChanged hands what p's host watch saw to Find in Files and Search Everywhere:
// names, changed paths relative to the folder, update the index before the next query, and
// resync, for a watch that started or lost changes, builds it again. The queries shown run again.
func (a *App) remoteSearchChanged(p *project, names []string, resync bool) {
available := p.remoteWatching()
if s := &p.search; s.watch != nil && s.watchReady {
s.watchAvailable = available
if resync {
s.pending, s.fullResync = nil, true
} else {
a.queueSearchChanges(&s.pending, &s.fullResync, names)
}
a.projectSearchOutdated(p)
a.runProjectSearch(p)
}
if s := &p.everywhere; s.watchAttached && s.watchReady && a.everywhereView.open {
s.watchAvailable = available
if resync {
s.pending, s.fullResync = nil, true
} else {
a.queueSearchChanges(&s.pending, &s.fullResync, names)
}
a.everywhereOutdated(p)
a.runEverywhere(p, false)
}
}

// remoteSearchUnwatched tells p's searches that the host watch stopped, or ran out of watches:
// changes no longer reach the index, so every query builds it again until a watch starts and
// resyncs. The results shown stay; a session lost would fail the query run now, and the next
// session's watch runs it again.
func (a *App) remoteSearchUnwatched(p *project) {
p.search.watchAvailable, p.search.pending, p.search.fullResync = false, nil, true
p.everywhere.watchAvailable, p.everywhere.pending, p.everywhere.fullResync = false, nil, true
}
Loading
Loading