Archived
- On startup, after the local state is shown, fetch the superproject and every initialized submodule (all remotes, prune, at most 8 at once). Fetches never prompt; failures show git's message. --no-fetch skips it, f fetches again. - The header shows "fetching n/m", then the fetch age and failures; the detail pane shows each submodule's last fetch and fetch errors. - The git provider polls each repository's metadata (refs, HEAD, index, .gitmodules) every 2 s and reports changes. The app reloads only what changed, keeping old values, expansion and cursor; loads are single-flight with coalesced reruns. Refresh is driven by the repositories, so a fetch in another shell updates the view like ours. - r reloads everything (worktree edits are not watched). - Docs: F50-F53, N1/N8 rewritten, D18-D20 (D12 superseded). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package tui
|
|
|
|
// treeKey is the reloader key for loading the tree; submodules use their
|
|
// path.
|
|
const treeKey = "\x00tree"
|
|
|
|
// reloader allows at most one load per key at a time. A request while a
|
|
// load is running marks the key dirty, and the load runs once more after
|
|
// the current one finishes, so the last result always reflects the latest
|
|
// change and results never arrive out of order.
|
|
type reloader struct {
|
|
running map[string]bool
|
|
dirty map[string]bool
|
|
}
|
|
|
|
func newReloader() reloader {
|
|
return reloader{running: map[string]bool{}, dirty: map[string]bool{}}
|
|
}
|
|
|
|
// start reports whether a load for key should start now. If one is already
|
|
// running, the key is marked dirty instead.
|
|
func (r reloader) start(key string) bool {
|
|
if r.running[key] {
|
|
r.dirty[key] = true
|
|
return false
|
|
}
|
|
r.running[key] = true
|
|
return true
|
|
}
|
|
|
|
// done marks the load for key as finished. It reports whether the load must
|
|
// run again because it was requested meanwhile; the key then stays running.
|
|
func (r reloader) done(key string) (again bool) {
|
|
if r.dirty[key] {
|
|
delete(r.dirty, key)
|
|
return true
|
|
}
|
|
delete(r.running, key)
|
|
return false
|
|
}
|
|
|
|
// busy reports whether any load is running.
|
|
func (r reloader) busy() bool { return len(r.running) > 0 }
|