A per-DataDir background process owns ticket JSON, history, and sync so multiple TUI instances stay consistent; MCP token APIs are ready for phase 2. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
928 B
Go
38 lines
928 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) handleHistoryStatus(w http.ResponseWriter, r *http.Request) {
|
|
_ = r
|
|
writeJSON(w, http.StatusOK, map[string]any{
|
|
"canUndo": s.history.CanUndo(),
|
|
"canRedo": s.history.CanRedo(),
|
|
"lastUndoName": s.history.LastUndoName(),
|
|
"lastRedoName": s.history.LastRedoName(),
|
|
})
|
|
}
|
|
|
|
func (s *Server) handleUndo(w http.ResponseWriter, r *http.Request) {
|
|
_ = r
|
|
name := s.history.LastUndoName()
|
|
if err := s.history.Undo(); err != nil {
|
|
writeErr(w, http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
s.notify("")
|
|
writeJSON(w, http.StatusOK, map[string]string{"name": name})
|
|
}
|
|
|
|
func (s *Server) handleRedo(w http.ResponseWriter, r *http.Request) {
|
|
_ = r
|
|
name := s.history.LastRedoName()
|
|
if err := s.history.Redo(); err != nil {
|
|
writeErr(w, http.StatusBadRequest, err.Error())
|
|
return
|
|
}
|
|
s.notify("")
|
|
writeJSON(w, http.StatusOK, map[string]string{"name": name})
|
|
}
|