improv: ui / ux
This commit is contained in:
parent
8fb46fe392
commit
3c47523ea6
3 changed files with 50 additions and 19 deletions
|
|
@ -16,7 +16,11 @@ interface Agent {
|
|||
};
|
||||
}
|
||||
|
||||
export function AgentsList() {
|
||||
interface AgentsListProps {
|
||||
isCreatingAgent?: boolean;
|
||||
}
|
||||
|
||||
export function AgentsList({ isCreatingAgent = false }: AgentsListProps) {
|
||||
const { session } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
|
|
@ -93,7 +97,7 @@ export function AgentsList() {
|
|||
if (agents.length === 0) {
|
||||
return (
|
||||
<div className="text-description-muted px-2 py-4 text-center text-sm">
|
||||
No background agents yet. Submit a message above to create one.
|
||||
No background tasks yet. Submit a message above to create one.
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -101,7 +105,7 @@ export function AgentsList() {
|
|||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-description-muted px-2 text-xs font-semibold">
|
||||
Recent Agents
|
||||
Background Tasks
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 px-2">
|
||||
{agents.map((agent) => (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
ExclamationTriangleIcon,
|
||||
RocketLaunchIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
|
|
@ -11,9 +12,13 @@ import { AgentsList } from "./AgentsList";
|
|||
|
||||
interface BackgroundModeViewProps {
|
||||
onCreateAgent: (editorState: any) => void;
|
||||
isCreatingAgent?: boolean;
|
||||
}
|
||||
|
||||
export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
|
||||
export function BackgroundModeView({
|
||||
onCreateAgent,
|
||||
isCreatingAgent = false,
|
||||
}: BackgroundModeViewProps) {
|
||||
const { session, login } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
|
|
@ -129,10 +134,19 @@ export function BackgroundModeView({ onCreateAgent }: BackgroundModeViewProps) {
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-description px-2 text-sm">
|
||||
Agents you trigger will run in the background and appear below.
|
||||
<div className="px-2">
|
||||
<div className="text-description text-sm">
|
||||
Submit a task above to run a background agent. Your task will appear
|
||||
below in ~30 seconds once the container starts.
|
||||
</div>
|
||||
{isCreatingAgent && (
|
||||
<div className="text-description-muted mt-2 flex items-center gap-2 text-xs">
|
||||
<ArrowPathIcon className="h-3 w-3 animate-spin" />
|
||||
<span>Creating task...</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<AgentsList />
|
||||
<AgentsList isCreatingAgent={isCreatingAgent} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export function Chat() {
|
|||
);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const [stepsOpen] = useState<(boolean | undefined)[]>([]);
|
||||
const [isCreatingAgent, setIsCreatingAgent] = useState(false);
|
||||
const mainTextInputRef = useRef<HTMLInputElement>(null);
|
||||
const stepsDivRef = useRef<HTMLDivElement>(null);
|
||||
const tabsRef = useRef<HTMLDivElement>(null);
|
||||
|
|
@ -181,13 +182,28 @@ export function Chat() {
|
|||
const currentOrg = selectCurrentOrg(stateSnapshot);
|
||||
const organizationId =
|
||||
currentOrg?.id !== "personal" ? currentOrg?.id : undefined;
|
||||
ideMessenger.post("createBackgroundAgent", {
|
||||
editorState,
|
||||
organizationId,
|
||||
});
|
||||
|
||||
setIsCreatingAgent(true);
|
||||
|
||||
// Clear input immediately for better UX
|
||||
if (editorToClearOnSend) {
|
||||
editorToClearOnSend.commands.clearContent();
|
||||
}
|
||||
|
||||
// Create agent and track loading state
|
||||
(async () => {
|
||||
try {
|
||||
await ideMessenger.request("createBackgroundAgent", {
|
||||
editorState,
|
||||
organizationId,
|
||||
});
|
||||
setIsCreatingAgent(false);
|
||||
} catch (error) {
|
||||
console.error("Failed to create background agent:", error);
|
||||
setIsCreatingAgent(false);
|
||||
}
|
||||
})();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +273,7 @@ export function Chat() {
|
|||
}
|
||||
}
|
||||
},
|
||||
[dispatch, ideMessenger, reduxStore],
|
||||
[dispatch, ideMessenger, reduxStore, setIsCreatingAgent],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
|
|
@ -480,14 +496,11 @@ export function Chat() {
|
|||
{!hasDismissedExploreDialog && <ExploreDialogWatcher />}
|
||||
{mode === "background" ? (
|
||||
<BackgroundModeView
|
||||
onCreateAgent={(editorState) => {
|
||||
const organizationId =
|
||||
currentOrg?.id !== "personal" ? currentOrg?.id : undefined;
|
||||
ideMessenger.post("createBackgroundAgent", {
|
||||
editorState,
|
||||
organizationId,
|
||||
});
|
||||
onCreateAgent={() => {
|
||||
// This callback is kept for compatibility but not used
|
||||
// Agent creation is now handled in sendInput for better loading state management
|
||||
}}
|
||||
isCreatingAgent={isCreatingAgent}
|
||||
/>
|
||||
) : (
|
||||
history.length === 0 && (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue