Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
fix: show in-panel processing feedback in agent chat
Khuram Niaz4dc283f7b089
diff --git a/__tests__/AgentChatInput.spec.tsx b/__tests__/AgentChatInput.spec.tsxindex 6c305bc..2d03a0a 100644--- a/__tests__/AgentChatInput.spec.tsx+++ b/__tests__/AgentChatInput.spec.tsx@@ -58,6 +58,27 @@ describe("AgentChatInput", () => {expect(screen.queryByText(/pasted/i)).not.toBeInTheDocument();});+ // Browsers gate crypto.randomUUID behind a secure context, so it is absent+ // over plain http on a LAN host. Node's global crypto is not gated, which is+ // why every other test here passes while the browser drops the paste.+ it("chips an over-threshold paste where crypto.randomUUID is unavailable", async () => {+ const original = crypto.randomUUID;+ Object.defineProperty(crypto, "randomUUID", {+ configurable: true,+ value: undefined,+ });+ try {+ render(<AgentChatInput />);+ await paste(long);+ expect(screen.getByText(/pasted/i)).toBeInTheDocument();+ } finally {+ Object.defineProperty(crypto, "randomUUID", {+ configurable: true,+ value: original,+ });+ }+ });+it("truncates and labels a paste above the ceiling", async () => {render(<AgentChatInput />);await paste(huge);diff --git a/__tests__/AgentChatMessages.spec.tsx b/__tests__/AgentChatMessages.spec.tsxindex bf493af..210ffca 100644--- a/__tests__/AgentChatMessages.spec.tsx+++ b/__tests__/AgentChatMessages.spec.tsx@@ -135,6 +135,59 @@ describe("AgentChatMessages", () => {).not.toBeInTheDocument();});+ it("shows the thinking row while the first assistant part is still pending", () => {+ chat.status = "submitted";+ chat.messages = [user([{ type: "text", text: "add a job" }])];+ render(<AgentChatMessages />);+ expect(screen.getByText(/thinking/i)).toBeInTheDocument();+ });++ it("shows the thinking row after a tool result while the reply is composed", () => {+ chat.status = "streaming";+ chat.messages = [+ assistant([+ toolPart("output-available", {+ output: { created: true, jobId: "j1", resolutions: [] },+ }),+ ]),+ ];+ render(<AgentChatMessages />);+ expect(screen.getByText(/thinking/i)).toBeInTheDocument();+ });++ it("does not double up on the running card, which spins already", () => {+ chat.status = "streaming";+ chat.messages = [assistant([toolPart("input-available")])];+ render(<AgentChatMessages />);+ expect(screen.getByText(/preparing to add a job/i)).toBeInTheDocument();+ expect(screen.queryByText(/thinking/i)).not.toBeInTheDocument();+ });++ it("does not show the thinking row while an approval is on screen", () => {+ chat.status = "streaming";+ chat.messages = [+ assistant([toolPart("approval-requested", { approval: { id: "ap1" } })]),+ ];+ render(<AgentChatMessages />);+ expect(screen.queryByText(/thinking/i)).not.toBeInTheDocument();+ });++ it("does not show the thinking row once text is arriving", () => {+ chat.status = "streaming";+ chat.messages = [assistant([{ type: "text", text: "I found the" }])];+ render(<AgentChatMessages />);+ expect(screen.queryByText(/thinking/i)).not.toBeInTheDocument();+ });++ it("does not show the thinking row on a settled transcript", () => {+ chat.messages = [+ user([{ type: "text", text: "add a job" }]),+ assistant([{ type: "text", text: "Done." }]),+ ];+ render(<AgentChatMessages />);+ expect(screen.queryByText(/thinking/i)).not.toBeInTheDocument();+ });+it("renders assistant text as plain text, never as markdown media", () => {chat.messages = [assistant([{ type: "text", text: "" }]),diff --git a/__tests__/agentChatRoute.spec.ts b/__tests__/agentChatRoute.spec.tsindex c3977a5..fa16116 100644--- a/__tests__/agentChatRoute.spec.ts+++ b/__tests__/agentChatRoute.spec.ts@@ -96,6 +96,31 @@ describe("POST /api/ai/chat", () => {expect(saveOrder).toBeLessThan(streamOrder);});+ // Pasting and hitting Send without typing produces a message whose only+ // part is the chip. convertToModelMessages drops that custom data part, so+ // the message converts to empty content — and ollama-ai-provider-v2+ // serializes empty user content as [], which Ollama 400s on because its+ // content field is a string. The paste context message carries the posting,+ // so the empty shell has nothing left to say.+ it("never sends a contentless message when the user pastes without typing", async () => {+ const chipOnly = {+ id: "m1",+ role: "user",+ parts: [+ { type: AGENT_PASTE_PART_TYPE, id: "p1", data: { id: "p1", text: "MARKER posting", chars: 14, truncated: false } },+ ],+ };+ await POST(req({ messages: [chipOnly] }));+ expect(streamText).toHaveBeenCalled();+ const sent = streamArgs().messages;+ const contentless = sent.filter(+ (m: any) => Array.isArray(m.content) && m.content.length === 0,+ );+ expect(contentless).toEqual([]);+ // The posting still has to reach the model, or we fixed it by muting it.+ expect(JSON.stringify(sent)).toContain("MARKER posting");+ });+it("sends only the truncated head to the model, never the full paste", async () => {const posting = "HEAD_MARKER " + "x".repeat(APP_CONSTANTS.AGENT_CHAT_PASTE_HEAD_CHARS) + " TAIL_MARKER";await POST(req({ messages: [pasteMessage(posting)] }));diff --git a/src/app/api/ai/chat/route.ts b/src/app/api/ai/chat/route.tsindex a29e7a0..4e4f80a 100644--- a/src/app/api/ai/chat/route.ts+++ b/src/app/api/ai/chat/route.ts@@ -119,6 +119,16 @@ export const POST = async (req: NextRequest) => {return NextResponse.json({ error: "Invalid chat request." }, { status: 400 });}+ // A chip-only send — paste, then Send without typing — has no text part,+ // and the paste part is not a model part, so the message converts to empty+ // content. Ollama rejects the whole request on it (its content field is a+ // string; the provider serializes empty content as []), and it keeps doing+ // so on every later turn while the shell stays in the window. The paste+ // context message below is what actually carries the posting.+ modelMessages = modelMessages.filter(+ (message) => !(Array.isArray(message.content) && message.content.length === 0),+ );+// Injected only on the turn that introduced the paste. On the approval POST// the last message is the assistant's, so nothing is re-injected — and the// full text never reaches the model on any turn.diff --git a/src/components/agent/AgentChatInput.tsx b/src/components/agent/AgentChatInput.tsxindex 9a95da9..33fb058 100644--- a/src/components/agent/AgentChatInput.tsx+++ b/src/components/agent/AgentChatInput.tsx@@ -50,6 +50,16 @@ function chipAttachment(chip: AgentPastePartData): AttachmentData {};}+// crypto.randomUUID is secure-context-only, so it is absent over plain http on+// a LAN host and calling it drops the paste. The id only has to be unique+// within one composer, never unguessable.+function chipId(): string {+ return (+ crypto.randomUUID?.() ??+ `paste-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`+ );+}+function queuedText(parts: ComposerPart[]): string {const text = parts.find((part) => part.type === "text");const chip = parts.find(isAgentPastePart);@@ -85,7 +95,7 @@ export function AgentChatInput() {? pasted.slice(0, APP_CONSTANTS.AGENT_CHAT_PASTE_MAX_CHARS): pasted;setChip({- id: crypto.randomUUID(),+ id: chipId(),text: body,chars: body.length,truncated,diff --git a/src/components/agent/AgentChatMessages.tsx b/src/components/agent/AgentChatMessages.tsxindex 99a9558..52d43f3 100644--- a/src/components/agent/AgentChatMessages.tsx+++ b/src/components/agent/AgentChatMessages.tsx@@ -11,6 +11,7 @@ import {import { Button } from "@/components/ui/button";import { AgentApprovalCard } from "@/components/agent/AgentApprovalCard";import { AgentResultCard } from "@/components/agent/AgentResultCard";+import { AgentStatusRow } from "@/components/agent/AgentStatusRow";import { AgentToolRunningCard } from "@/components/agent/AgentToolRunningCard";import { useAgentChat } from "@/components/agent/AgentChatProvider";import { resolvePastedText } from "@/lib/agent/paste";@@ -36,6 +37,34 @@ function endsAwaitingReply(messages: UIMessage[], status: string): boolean {return messages[messages.length - 1]?.role === "user";}+// Two silent windows on a local model: the wait before the first assistant+// part lands, and the wait after a tool result while the closing prose is+// composed. Both look identical — nothing on screen moves and the only signal+// is the submit button. Suppressed wherever the transcript already narrates+// itself, so there is never a second spinner beside a card that has one.+function showThinking(messages: UIMessage[], status: string): boolean {+ if (status !== "submitted" && status !== "streaming") return false;+ const last = messages[messages.length - 1];+ if (!last || last.role !== "assistant") return true;++ const tail = last.parts[last.parts.length - 1];+ if (!tail) return true;+ if (tail.type === "text") return tail.text.trim().length === 0;+ if (!isStaticToolUIPart(tail)) return true;+ switch (tail.state) {+ // The running card spins for these two.+ case "input-streaming":+ case "input-available":+ // Waiting on the user, not the model.+ case "approval-requested":+ // The approval card already says "Waiting…".+ case "approval-responded":+ return false;+ default:+ return true;+ }+}+export function AgentChatMessages() {const {messages,@@ -50,6 +79,7 @@ export function AgentChatMessages() {const pastedText = resolvePastedText(messages);const showContinue =!dismissed && (interruptedTurn || endsAwaitingReply(messages, status));+ const thinking = showThinking(messages, status);const dismiss = () => {setDismissed(true);@@ -137,6 +167,8 @@ export function AgentChatMessages() {</Button></div>)}++ {thinking && <AgentStatusRow label="Thinking…" />}</ConversationContent><ConversationScrollButton /></Conversation>diff --git a/src/components/agent/AgentStatusRow.tsx b/src/components/agent/AgentStatusRow.tsxnew file mode 100644index 0000000..8758f9f--- /dev/null+++ b/src/components/agent/AgentStatusRow.tsx@@ -0,0 +1,21 @@+"use client";++import { Loader2 } from "lucide-react";+import { useSlowResponseWarning } from "@/hooks/useSlowResponseWarning";+import { SlowResponseWarning } from "@/components/common/SlowResponseWarning";++// One row for every "the model is busy" moment in the transcript. Mounts and+// unmounts per gap, so the slow-response timer restarts with each wait.+export function AgentStatusRow({ label }: { label: string }) {+ const showSlowWarning = useSlowResponseWarning(true, false);++ return (+ <div className="rounded-sm border bg-muted/20 px-3 py-2">+ <div className="flex items-center gap-2 text-sm text-muted-foreground">+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ <span>{label}</span>+ </div>+ {showSlowWarning && <SlowResponseWarning />}+ </div>+ );+}diff --git a/src/components/agent/AgentToolRunningCard.tsx b/src/components/agent/AgentToolRunningCard.tsxindex d4e663c..777c728 100644--- a/src/components/agent/AgentToolRunningCard.tsx+++ b/src/components/agent/AgentToolRunningCard.tsx@@ -1,24 +1,13 @@"use client";-import { Loader2 } from "lucide-react";import { getToolName, type ToolUIPart } from "ai";-import { useSlowResponseWarning } from "@/hooks/useSlowResponseWarning";-import { SlowResponseWarning } from "@/components/common/SlowResponseWarning";+import { AgentStatusRow } from "@/components/agent/AgentStatusRow";// Confirmation renders null for these states, so this is not redundant with// it. On a local 8B, deciding on a tool call is the longest phase of a turn.export function AgentToolRunningCard({ part }: { part: ToolUIPart }) {- const showSlowWarning = useSlowResponseWarning(true, false);const label =getToolName(part) === "add_job" ? "Preparing to add a job…" : "Working…";- return (- <div className="rounded-sm border bg-muted/20 px-3 py-2">- <div className="flex items-center gap-2 text-sm text-muted-foreground">- <Loader2 className="h-3.5 w-3.5 animate-spin" />- <span>{label}</span>- </div>- {showSlowWarning && <SlowResponseWarning />}- </div>- );+ return <AgentStatusRow label={label} />;}