multiple agents

This commit is contained in:
Josh at WLTechBlog committed 2026-07-12 18:51:47 -07:00
1 parent ec391bd7ed
commit a399e1f365
6 files changed
+499 -658

No files matched your search

+9 -34
View File
@@ -84,13 +84,15 @@ func (c *Client) GetVersion() (string, error) {
// TabInfo contains information about a tab
type TabInfo struct {
ID string `json:"id"`
URL string `json:"url"`
IsCurrent bool `json:"is_current"`
HistoryIndex int `json:"history_index"` // Position in tab history (higher = more recent)
ID string `json:"id"`
URL string `json:"url"`
}
// ListTabs returns a list of all open tabs
// ListTabs returns a list of all open tabs.
//
// The daemon no longer tracks a "current tab" or tab history (those concepts
// are not safe to share across multiple concurrent clients), so the status
// endpoint only reports the set of open tabs and their URLs.
func (c *Client) ListTabs() ([]TabInfo, error) {
resp, err := http.Get(c.serverURL + "/status")
if err != nil {
@@ -124,24 +126,6 @@ func (c *Client) ListTabs() ([]TabInfo, error) {
return nil, fmt.Errorf("unexpected tabs format")
}
// Get the current tab
currentTab, _ := data["current_tab"].(string)
// Get the tab history
tabHistoryData, ok := data["tab_history"].([]interface{})
if !ok {
tabHistoryData = []interface{}{}
}
// Create a map of tab history indices
tabHistoryIndices := make(map[string]int)
for i, idInterface := range tabHistoryData {
id, ok := idInterface.(string)
if ok {
tabHistoryIndices[id] = i
}
}
// Convert to TabInfo
tabs := make([]TabInfo, 0, len(tabsData))
for id, urlInterface := range tabsData {
@@ -149,18 +133,9 @@ func (c *Client) ListTabs() ([]TabInfo, error) {
if !ok {
url = "<unknown>"
}
// Get the history index (default to -1 if not in history)
historyIndex, inHistory := tabHistoryIndices[id]
if !inHistory {
historyIndex = -1
}
tabs = append(tabs, TabInfo{
ID: id,
URL: url,
IsCurrent: id == currentTab,
HistoryIndex: historyIndex,
ID: id,
URL: url,
})
}