Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: address user feedback (mobile nav, thinking section, logout, notifications, cursor) (#61)

Generefd9abeb9845
diff --git a/src/web/src/app/(app)/workspaces/client.tsx b/src/web/src/app/(app)/workspaces/client.tsx
index 257085d6b..72b308657 100644
--- a/src/web/src/app/(app)/workspaces/client.tsx
+++ b/src/web/src/app/(app)/workspaces/client.tsx
@@ -7,7 +7,8 @@ import { Card, CardContent } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { GradientBackground } from "@/components/gradient-background"
import { Logo } from "@/components/logo"
-import { Plus, ArrowRight, Loader2 } from "lucide-react"
+import { Plus, ArrowRight, Loader2, LogOut } from "lucide-react"
+import { signOut } from "@/lib/auth-client"
import {
type WorkspaceFormErrors,
hasWorkspaceFormErrors,
@@ -76,6 +77,19 @@ export function WorkspaceListClient({
<div className="relative flex min-h-dvh flex-col items-center justify-center p-6">
<GradientBackground />
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute top-4 right-4 text-muted-foreground"
+ onClick={async () => {
+ await signOut()
+ router.push("/sign-in")
+ }}
+ >
+ <LogOut className="size-4" />
+ Log out
+ </Button>
+
<div className="w-full max-w-md space-y-8">
<div className="flex flex-col items-center gap-3">
<Logo size="lg" />
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index 0439c9d9f..c149afce9 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -948,6 +948,13 @@
.caret-foreground {
caret-color: var(--foreground);
}
+.textarea-text-hidden {
+ -webkit-text-fill-color: transparent;
+ color: transparent;
+}
+.chat-input-line-height {
+ line-height: 24px;
+}
/* Mention highlight — underline + italic */
.mention-highlight {
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsx
index 5bc1a597a..6ac49ed50 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -1525,7 +1525,7 @@ export function AgentChatView() {
<div className="relative">
<div
aria-hidden
- className="mention-backdrop absolute inset-0 px-3.5 py-2.5 text-base leading-normal whitespace-pre-wrap wrap-break-word pointer-events-none overflow-y-auto thin-scrollbar"
+ className="mention-backdrop absolute inset-0 px-3.5 py-2.5 text-base chat-input-line-height whitespace-pre-wrap wrap-break-word pointer-events-none overflow-y-auto thin-scrollbar"
dangerouslySetInnerHTML={{
__html: input
? highlightMentions(
@@ -1563,10 +1563,10 @@ export function AgentChatView() {
rows={1}
disabled={sending}
className={cn(
- "relative field-sizing-content w-full resize-none bg-transparent px-3.5 py-2.5 text-base leading-normal outline-none",
+ "relative field-sizing-content w-full resize-none bg-transparent px-3.5 py-2.5 text-base chat-input-line-height outline-none",
"placeholder:text-muted-foreground disabled:cursor-not-allowed",
"min-h-9.5 max-h-50 thin-scrollbar",
- "caret-foreground text-transparent"
+ "caret-foreground textarea-text-hidden"
)}
/>
</div>
diff --git a/src/web/src/components/agent-chat/artifact-sheet.tsx b/src/web/src/components/agent-chat/artifact-sheet.tsx
index afc360fbe..a7a536bd9 100644
--- a/src/web/src/components/agent-chat/artifact-sheet.tsx
+++ b/src/web/src/components/agent-chat/artifact-sheet.tsx
@@ -9,7 +9,7 @@ import {
SheetBody,
} from "@/components/ui/sheet";
import type { Artifact } from "@alook/shared";
-import { FileText, Download, X } from "lucide-react";
+import { FileText, Download, X, ArrowLeft } from "lucide-react";
import { Button } from "@/components/ui/button";
import { ArtifactContentRenderer, getArtifactUrl } from "@/components/artifact-content-renderer";
@@ -84,22 +84,28 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init
<>
<SheetHeader>
<div className="flex items-center gap-2">
- <SheetTitle className="truncate flex-1">{selectedArtifact.filename}</SheetTitle>
<Button
variant="ghost"
size="icon-sm"
- className="shrink-0"
- onClick={() => window.open(getArtifactUrl(selectedArtifact.id, workspaceId, true), "_blank")}
+ className="shrink-0 sm:hidden"
+ onClick={() => {
+ if (artifacts.length > 1) {
+ setSelectedArtifact(null);
+ } else {
+ handleOpenChange(false);
+ }
+ }}
>
- <Download className="size-4" />
+ <ArrowLeft className="size-4" />
</Button>
+ <SheetTitle className="truncate flex-1">{selectedArtifact.filename}</SheetTitle>
<Button
variant="ghost"
size="icon-sm"
- className="shrink-0 sm:hidden"
- onClick={() => handleOpenChange(false)}
+ className="shrink-0"
+ onClick={() => window.open(getArtifactUrl(selectedArtifact.id, workspaceId, true), "_blank")}
>
- <X className="size-4" />
+ <Download className="size-4" />
</Button>
</div>
</SheetHeader>
@@ -111,15 +117,15 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init
<>
<SheetHeader>
<div className="flex items-center gap-2">
- <SheetTitle className="flex-1">Artifacts</SheetTitle>
<Button
variant="ghost"
size="icon-sm"
className="shrink-0 sm:hidden"
onClick={() => handleOpenChange(false)}
>
- <X className="size-4" />
+ <ArrowLeft className="size-4" />
</Button>
+ <SheetTitle className="flex-1">Artifacts</SheetTitle>
</div>
</SheetHeader>
<SheetBody className="thin-scrollbar">
diff --git a/src/web/src/components/agent-chat/historical-task-steps.tsx b/src/web/src/components/agent-chat/historical-task-steps.tsx
index 9acb0bb10..242716327 100644
--- a/src/web/src/components/agent-chat/historical-task-steps.tsx
+++ b/src/web/src/components/agent-chat/historical-task-steps.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useState, useCallback } from "react";
+import { useState, useCallback, useEffect } from "react";
import { TaskStream } from "@/components/task-stream";
import { getTaskMessages } from "@/lib/api";
import type { TaskMessage, TaskApi } from "@alook/shared";
@@ -36,7 +36,7 @@ export function HistoricalTaskSteps({
const [loading, setLoading] = useState(false);
const [fetched, setFetched] = useState(false);
- const handleExpand = useCallback(async () => {
+ const fetchMessages = useCallback(async () => {
if (fetched || loading) return;
setLoading(true);
try {
@@ -50,12 +50,15 @@ export function HistoricalTaskSteps({
}
}, [fetched, loading, taskId, workspaceId]);
+ // Auto-load messages so intermediate text ("Thinking") is available
+ useEffect(() => { fetchMessages(); }, []); // eslint-disable-line react-hooks/exhaustive-deps
+
return (
<TaskStream
task={COMPLETED_STUB}
messages={messages}
stepCountHint={stepCount}
- onExpandSteps={handleExpand}
+ onExpandSteps={fetchMessages}
stepsLoading={loading}
/>
);
diff --git a/src/web/src/components/task-stream.tsx b/src/web/src/components/task-stream.tsx
index f30d974e5..b66570000 100644
--- a/src/web/src/components/task-stream.tsx
+++ b/src/web/src/components/task-stream.tsx
@@ -299,6 +299,7 @@ export function TaskStream({
const finalTextItem = textItems.length > 0 ? textItems[textItems.length - 1] : null;
const toolScrollRef = useRef<HTMLDivElement>(null);
+ const textScrollRef = useRef<HTMLDivElement>(null);
const expandedRef = useRef(false);
// Auto-scroll tool area to bottom while running
@@ -308,10 +309,17 @@ export function TaskStream({
}
}, [toolItems.length, isRunning]);
- const hiddenTextCount = !isRunning ? Math.max(0, textItems.length - 1) : 0;
- const hasHiddenText = hiddenTextCount > 0;
- const displayStepCount = (toolItems.length > 0 ? toolItems.length : stepCountHint ?? 0) + hiddenTextCount;
- const showStepsSection = toolItems.length > 0 || (stepCountHint && stepCountHint > 0) || hasHiddenText;
+ // Auto-scroll text area to bottom while running
+ useEffect(() => {
+ if (isRunning && textScrollRef.current) {
+ textScrollRef.current.scrollTop = textScrollRef.current.scrollHeight;
+ }
+ }, [textItems.length, isRunning]);
+
+ const intermediateTextItems = isRunning ? textItems : textItems.slice(0, -1);
+ const hasFinalText = !isRunning && finalTextItem !== null;
+ const displayStepCount = toolItems.length > 0 ? toolItems.length : stepCountHint ?? 0;
+ const showStepsSection = toolItems.length > 0 || (stepCountHint && stepCountHint > 0);
const handleStepsToggle = (e: React.SyntheticEvent<HTMLDetailsElement>) => {
if ((e.currentTarget as HTMLDetailsElement).open && !expandedRef.current && onExpandSteps) {
@@ -374,15 +382,7 @@ export function TaskStream({
<span>Loading steps...</span>
</div>
)}
- {(isRunning ? toolItems : allItems).map((item) => {
- if (item.kind === "text") {
- if (item.id === finalTextItem?.id) return null;
- return (
- <div key={item.id} className="markdown max-w-full min-w-0 px-1 py-0.5 text-sm text-muted-foreground">
- <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }}>{item.content}</Streamdown>
- </div>
- );
- }
+ {toolItems.map((item) => {
switch (item.kind) {
case "tool-call":
return <ToolCallBlock key={item.id} item={item} isRunning={isRunning} />;
@@ -408,13 +408,31 @@ export function TaskStream({
</details>
)}
- {/* Text output zone — all text while running; only final text after completion */}
- {isRunning && textItems.length > 0 && (
- <div className="markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground">
- <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }}>{textItems.map((item) => item.content).join("\n\n")}</Streamdown>
- </div>
+ {/* Thinking section — intermediate text, open while running or when no final text */}
+ {intermediateTextItems.length > 0 && (
+ <details className="group/midtext pl-1" open={!hasFinalText || undefined}>
+ <summary
+ className={cn(
+ "flex items-center gap-1.5 py-1 cursor-pointer select-none",
+ "text-xs text-muted-foreground transition-colors duration-150",
+ "hover:text-foreground",
+ "[&::-webkit-details-marker]:hidden [&::marker]:hidden"
+ )}
+ >
+ <ChevronRight className="size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90" />
+ <span><AnimatedNumber value={intermediateTextItems.length} /> thinking</span>
+ </summary>
+ <div ref={textScrollRef} className="mt-1 space-y-2 pl-1">
+ {intermediateTextItems.map((item) => (
+ <div key={item.id} className="markdown max-w-full min-w-0 px-1 py-0.5 text-sm text-muted-foreground">
+ <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }}>{item.content}</Streamdown>
+ </div>
+ ))}
+ </div>
+ </details>
)}
- {!isRunning && finalTextItem && !onExpandSteps && (
+ {/* Final text — shown after completion (not for historical tasks which render it as a message) */}
+ {hasFinalText && !onExpandSteps && (
<div className="markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground">
<Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }} linkSafety={{ enabled: false }}>{finalTextItem.content}</Streamdown>
</div>
diff --git a/src/web/src/contexts/agent-context.tsx b/src/web/src/contexts/agent-context.tsx
index 59eb11412..8616eb5f9 100644
--- a/src/web/src/contexts/agent-context.tsx
+++ b/src/web/src/contexts/agent-context.tsx
@@ -35,7 +35,7 @@ import type {
WsMessage,
} from "@alook/shared";
import { useUserWs } from "@/lib/use-user-ws";
-import { sendTaskNotification } from "@/lib/browser-notification";
+
type WsSubscriber = (msg: WsMessage) => void;
@@ -203,14 +203,10 @@ export function AgentProvider({
break;
case "task.updated":
fetchTaskCounts();
- if (msg.status === "completed" || msg.status === "failed") {
- const agent = agents.find((a) => a.id === msg.agentId);
- sendTaskNotification(msg.status, agent?.name);
- }
break;
}
},
- [reload, debouncedReload, fetchTaskCounts, workspaceId, agents]
+ [reload, debouncedReload, fetchTaskCounts, workspaceId]
);
useUserWs(handleWsMessage);
diff --git a/src/web/src/contexts/inbox-count-context.tsx b/src/web/src/contexts/inbox-count-context.tsx
index de398476f..8fa741ffe 100644
--- a/src/web/src/contexts/inbox-count-context.tsx
+++ b/src/web/src/contexts/inbox-count-context.tsx
@@ -6,11 +6,13 @@ import {
useState,
useEffect,
useCallback,
+ useRef,
type ReactNode,
} from "react";
import { getInboxCount } from "@/lib/api";
import { useAgentContext } from "@/contexts/agent-context";
import { useWorkspace } from "@/contexts/workspace-context";
+import { sendTaskNotification } from "@/lib/browser-notification";
import type { WsMessage } from "@alook/shared";
interface InboxCountContextValue {
@@ -29,15 +31,33 @@ export function useInboxCount() {
export function InboxCountProvider({ children }: { children: ReactNode }) {
const { workspaceId } = useWorkspace();
- const { subscribeWs } = useAgentContext();
+ const { subscribeWs, agents } = useAgentContext();
const [count, setCount] = useState(0);
+ const prevCountRef = useRef<number | null>(null);
+ const pendingAgentIdRef = useRef<string | null>(null);
const refresh = useCallback(() => {
- getInboxCount(workspaceId).then((r) => setCount(r.count)).catch(() => {});
- }, [workspaceId]);
+ getInboxCount(workspaceId).then((r) => {
+ const prev = prevCountRef.current;
+ prevCountRef.current = r.count;
+ setCount(r.count);
+ // Only notify when count increases after initial load
+ if (prev !== null && r.count > prev) {
+ const agent = pendingAgentIdRef.current
+ ? agents.find((a) => a.id === pendingAgentIdRef.current)
+ : undefined;
+ sendTaskNotification("completed", agent?.name);
+ }
+ pendingAgentIdRef.current = null;
+ }).catch(() => {});
+ }, [workspaceId, agents]);
const decrement = useCallback(() => {
- setCount((c) => Math.max(0, c - 1));
+ setCount((c) => {
+ const next = Math.max(0, c - 1);
+ prevCountRef.current = next;
+ return next;
+ });
}, []);
useEffect(() => { refresh(); }, [refresh]);
@@ -45,6 +65,7 @@ export function InboxCountProvider({ children }: { children: ReactNode }) {
useEffect(() => {
return subscribeWs((msg: WsMessage) => {
if (msg.type === "task.updated" && (msg.status === "completed" || msg.status === "failed")) {
+ pendingAgentIdRef.current = msg.agentId;
refresh();
}
});