loop: auto-commit changes when saving in diff view

What I've done is create a git commit whenever the user edits things,
and amend if possible. The existing detection logic pushes the commits
to the host, BUT, I had to do some plumbing to make that happen. The
agent state machine would be out of sorts if I did this (since we're
doing things outside of the loop), but, I didn't tell it, so... it's ok!

If the user has the agent running when editing, everyone can get
confused. There's no atomicity for the git operations, etc.
I suspect in practice this will all be as fine as everything else is.

I'm not running the autoformatters. That's a weird editing experience.

The alternative was to do what the diff comments does, and let the agent
deal with the changes by sending it a message. I chose not to do that:
first of all, I want the push to happen fast, since I don't like losing
user data. Second, the latency on an operation is distracting sometimes,
and sometimes what I do next is just cherrypick my changes over, and I'm
not interested in the pedantry of the agent and the code formatters and
so forth. If they were faster, maybe.

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: sec50af415124810bk
diff --git a/loop/server/loophttp.go b/loop/server/loophttp.go
index aaaf7c2..94cbb78 100644
--- a/loop/server/loophttp.go
+++ b/loop/server/loophttp.go
@@ -1373,6 +1373,16 @@
 		return
 	}
 
+	// Auto-commit the changes
+	err = git_tools.AutoCommitDiffViewChanges(r.Context(), repoDir, requestBody.Path)
+	if err != nil {
+		http.Error(w, fmt.Sprintf("Error auto-committing changes: %v", err), http.StatusInternalServerError)
+		return
+	}
+
+	// Detect git changes to push and notify user
+	s.agent.DetectGitChanges(r.Context())
+
 	// Return simple success response
 	w.WriteHeader(http.StatusOK)
 	w.Write([]byte("ok"))