From 853f7d6d8953e7564ab07220b900e5cbc710f572 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 12 May 2026 15:27:48 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Console=20calls=20agent=20directly=20?= =?UTF-8?q?=E2=80=94=20no=20stream,=20no=20polling,=20no=20overlay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The console was broken: posting to /stream with @micro prefix, then polling for agent events — race conditions, wrong responses, overlay state getting lost. All gone. Now the console is just an input that calls POST /agent/run directly and displays the response inline. Same endpoint the MCP agent tool uses. Same endpoint the chat page uses. One code path. - Removed the full-screen overlay entirely - Removed stream posting / polling from the console - Input stays at the top of the home page after the date - Response appears in a rounded box below the input - Each new question replaces the previous answer - Markdown rendered in the response - No state management, no overlay, no polling races --- home/home.go | 205 ++++++++------------------------------------------- 1 file changed, 29 insertions(+), 176 deletions(-) diff --git a/home/home.go b/home/home.go index b0db68d9..e588a7ab 100644 --- a/home/home.go +++ b/home/home.go @@ -369,125 +369,13 @@ function fetchW(la,lo){ // rounded textarea with send button inside. if viewerID != "" { b.WriteString(fmt.Sprintf(` -
-
- - +
+ + + +
`, stream.MaxContentLength)) - } - - // Inline card preferences panel — toggled by the ⚙ icon. - if viewerAcc != nil { - allCardDefs := []struct{ id, label string }{ - {"reminder", "Reminder"}, {"blog", "Blog"}, {"news", "News"}, - {"markets", "Markets"}, {"social", "Social"}, {"video", "Video"}, - } - activeSet := map[string]bool{} - if len(viewerAcc.HomeCards) > 0 { - for _, id := range viewerAcc.HomeCards { - activeSet[id] = true - } - } else { - for _, c := range allCardDefs { - activeSet[c.id] = true - } - } - var checkboxes string - for _, c := range allCardDefs { - checked := "" - if activeSet[c.id] { - checked = " checked" - } - checkboxes += fmt.Sprintf(``, c.id, checked, c.label) - } - b.WriteString(fmt.Sprintf(``, checkboxes)) - } - - // User card preferences — if set, only show cards in the user's - // chosen order. Empty = show all in default order. - var userCards map[string]int // card ID → display order - if viewerAcc != nil && len(viewerAcc.HomeCards) > 0 { - userCards = make(map[string]int, len(viewerAcc.HomeCards)) - for i, id := range viewerAcc.HomeCards { - userCards[id] = i - } - } - - var leftHTML []string - var rightHTML []string - - tooltips := map[string]string{ - "blog": "Microblog posts with daily AI-generated digests", - "news": "Headlines from RSS feeds, sorted by time", - "markets": "Live crypto, futures, and commodity prices", - "reminder": "Daily Islamic reminder with verse and hadith", - "social": "Public discussion threads", - "video": "Latest videos from curated channels", - } - - for _, card := range Cards { - // If user has card preferences, skip cards not in their list. - if userCards != nil { - if _, ok := userCards[card.ID]; !ok { - continue - } - } - content := card.CachedHTML - if strings.TrimSpace(content) == "" { - continue - } - if card.Link != "" { - content += app.Link("More", card.Link) - } - title := card.Title - if tip, ok := tooltips[card.ID]; ok { - title += fmt.Sprintf(` ?`, htmlEsc(tip)) - } - html := fmt.Sprintf(app.CardTemplate, card.ID, card.ID, title, content) - if card.Column == "left" { - leftHTML = append(leftHTML, html) - } else { - rightHTML = append(rightHTML, html) - } - } - - if len(leftHTML) > 0 || len(rightHTML) > 0 { - b.WriteString(fmt.Sprintf(Template, - strings.Join(leftHTML, "\n"), - strings.Join(rightHTML, "\n"))) - } - - b.WriteString(`
`) // close #home-cards - - // Console overlay + script (prompt is now inline above the cards). - if viewerID != "" { - b.WriteString(fmt.Sprintf(` - - -`, stream.MaxContentLength)) b.WriteString(consoleScript) } @@ -565,84 +453,49 @@ func htmlEsc(s string) string { // consoleScript — stateless command prompt. Fixed bottom bar opens a // full-screen overlay. Ask a question, get an answer. Escape closes. // consoleScript — Claude-style inline prompt with overlay for responses. +// consoleScript calls the agent API directly. No stream, no polling, +// no overlay. Question → POST /agent/run → response inline. const consoleScript = `