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
feat: dock agent chat panel beside page content
Khuram Niazd0d5860536d9
diff --git a/__tests__/AgentChatInput.spec.tsx b/__tests__/AgentChatInput.spec.tsxindex a8c0be4..6c305bc 100644--- a/__tests__/AgentChatInput.spec.tsx+++ b/__tests__/AgentChatInput.spec.tsx@@ -11,6 +11,7 @@ const chat = {error: undefined as Error | undefined,clearError: vi.fn(),preflight: { checked: true, ok: true } as any,+ composerNonce: 0,};vi.mock("@/components/agent/AgentChatProvider", () => ({useAgentChat: () => chat,@@ -35,6 +36,7 @@ describe("AgentChatInput", () => {chat.approvalPending = false;chat.error = undefined;chat.preflight = { checked: true, ok: true };+ chat.composerNonce = 0;});it("leaves a short paste inline in the textarea", async () => {@@ -142,6 +144,19 @@ describe("AgentChatInput", () => {expect(chat.sendMessage).not.toHaveBeenCalled();});+ it("empties the composer when the conversation is cleared", async () => {+ chat.approvalPending = true;+ const { rerender } = render(<AgentChatInput />);+ await paste(long);+ await userEvent.type(screen.getByRole("textbox"), "never mind");+ await userEvent.click(screen.getByRole("button", { name: /send/i }));+ chat.composerNonce = 1;+ rerender(<AgentChatInput />);+ expect(screen.getByRole("textbox")).toHaveValue("");+ expect(screen.queryByText(/pasted/i)).not.toBeInTheDocument();+ expect(screen.queryByText(/queued/i)).not.toBeInTheDocument();+ });+it("swaps send for stop while streaming", async () => {chat.status = "streaming";render(<AgentChatInput />);diff --git a/__tests__/AgentChatMessages.spec.tsx b/__tests__/AgentChatMessages.spec.tsxindex 3e54534..bf493af 100644--- a/__tests__/AgentChatMessages.spec.tsx+++ b/__tests__/AgentChatMessages.spec.tsx@@ -115,6 +115,15 @@ describe("AgentChatMessages", () => {expect(screen.getByRole("button", { name: /continue/i })).toBeInTheDocument();});+ it("does not offer Continue while the reply is still in flight", () => {+ chat.status = "submitted";+ chat.messages = [user([{ type: "text", text: "add a job" }])];+ render(<AgentChatMessages />);+ expect(+ screen.queryByRole("button", { name: /continue/i }),+ ).not.toBeInTheDocument();+ });+it("does not offer Continue after a completed assistant turn", () => {chat.messages = [user([{ type: "text", text: "add a job" }]),diff --git a/__tests__/AgentChatProvider.spec.tsx b/__tests__/AgentChatProvider.spec.tsxindex d0c871b..72cdf4b 100644--- a/__tests__/AgentChatProvider.spec.tsx+++ b/__tests__/AgentChatProvider.spec.tsx@@ -56,6 +56,7 @@ function Probe() {<button onClick={c.close}>close</button><button onClick={c.clear}>clear</button><span data-testid="state">{`${c.isOpen}|${c.approvalPending}|${c.interruptedTurn}|${holder}|${c.preflight.ok}`}</span>+ <span data-testid="composer-nonce">{c.composerNonce}</span></div>);}@@ -157,6 +158,13 @@ describe("AgentChatProvider", () => {expect(deleteOrder).toBeLessThan(resetOrder);});+ it("signals the composer to reset on clear", async () => {+ setup();+ expect(screen.getByTestId("composer-nonce").textContent).toBe("0");+ await userEvent.click(screen.getByText("clear"));+ expect(screen.getByTestId("composer-nonce").textContent).toBe("1");+ });+it("preflights Ollama on open and reports a failure", async () => {(checkOllamaConnection as any).mockResolvedValue({isConnected: false,diff --git a/src/components/SidebarInset.tsx b/src/components/SidebarInset.tsxindex fda0b1d..7fa62e3 100644--- a/src/components/SidebarInset.tsx+++ b/src/components/SidebarInset.tsx@@ -1,20 +1,38 @@"use client";import { useSidebar } from "@/context/SidebarContext";+import { useAgentChat } from "@/components/agent/AgentChatProvider";import { APP_CONSTANTS } from "@/lib/constants";import { cn } from "@/lib/utils";-// Offsets page content by the sidebar's current width.+// Offsets page content by the sidebar's current width, and by the agent chat+// panel's width while it is docked (lg+ only — below that the panel covers+// the viewport instead of docking).function SidebarInset({ children }: { children: React.ReactNode }) {const { expanded } = useSidebar();+ const { isOpen, panelWidth, isResizing } = useAgentChat();return (<divclassName={cn(- "flex flex-1 flex-col transition-[padding] duration-200 ease-in-out sm:gap-4 sm:py-4",+ "flex flex-1 flex-col sm:gap-4 sm:py-4",+ // Following the drag handle 200ms late reads as lag, not animation.+ isResizing+ ? "transition-none"+ : "transition-[padding] duration-200 ease-in-out",expanded? APP_CONSTANTS.SIDEBAR_WIDTH.expanded.contentOffset- : APP_CONSTANTS.SIDEBAR_WIDTH.collapsed.contentOffset+ : APP_CONSTANTS.SIDEBAR_WIDTH.collapsed.contentOffset,+ isOpen && "lg:pr-(--agent-chat-offset)")}+ // Only while open: panelWidth is seeded from localStorage, so emitting+ // it during SSR (always closed) is a hydration mismatch.+ style={+ isOpen+ ? ({+ "--agent-chat-offset": `min(${panelWidth}px, ${APP_CONSTANTS.RESIZABLE_PANEL_MAX_WIDTH_RATIO * 100}vw)`,+ } as React.CSSProperties)+ : undefined+ }>{children}</div>diff --git a/src/components/agent/AgentChatInput.tsx b/src/components/agent/AgentChatInput.tsxindex 5ed4529..9a95da9 100644--- a/src/components/agent/AgentChatInput.tsx+++ b/src/components/agent/AgentChatInput.tsx@@ -67,6 +67,7 @@ export function AgentChatInput() {clearError,preflight,prefill,+ composerNonce,} = useAgentChat();const [text, setText] = useState("");@@ -133,6 +134,15 @@ export function AgentChatInput() {if (prefill) setText(prefill.text);}, [prefill]);+ // Clearing the conversation clears the composer with it. The textarea empties+ // by remounting on the same nonce below — nothing else resets it.+ useEffect(() => {+ if (!composerNonce) return;+ setText("");+ setChip(undefined);+ setQueued(undefined);+ }, [composerNonce]);+const onStop = useCallback(() => {void stop();}, [stop]);@@ -215,7 +225,7 @@ export function AgentChatInput() {resets it on submit. `text` mirrors it only to enable send. */}<PromptInputTextareadefaultValue={prefill?.text}- key={prefill?.nonce}+ key={prefill?.nonce ?? composerNonce}onChange={(event) => setText(event.currentTarget.value)}onPaste={onPaste}placeholder="Ask or paste a job posting…"diff --git a/src/components/agent/AgentChatMessages.tsx b/src/components/agent/AgentChatMessages.tsxindex 8037b1b..99a9558 100644--- a/src/components/agent/AgentChatMessages.tsx+++ b/src/components/agent/AgentChatMessages.tsx@@ -29,14 +29,17 @@ function PasteChip({ data }: { data: AgentPastePartData }) {// The seeded transcript ending on a user message means the reply never came// back — the tab was closed mid-turn, or the server died. Same remedy as an-// explicitly interrupted turn.-function endsAwaitingReply(messages: UIMessage[]): boolean {+// explicitly interrupted turn. Gated on status because a turn still waiting on+// its first chunk looks identical, and on a local model that wait is 30–60s.+function endsAwaitingReply(messages: UIMessage[], status: string): boolean {+ if (status === "submitted" || status === "streaming") return false;return messages[messages.length - 1]?.role === "user";}export function AgentChatMessages() {const {messages,+ status,regenerate,addToolApprovalResponse,interruptedTurn,@@ -46,7 +49,7 @@ export function AgentChatMessages() {const pastedText = resolvePastedText(messages);const showContinue =- !dismissed && (interruptedTurn || endsAwaitingReply(messages));+ !dismissed && (interruptedTurn || endsAwaitingReply(messages, status));const dismiss = () => {setDismissed(true);diff --git a/src/components/agent/AgentChatPanel.tsx b/src/components/agent/AgentChatPanel.tsxindex 38a2e60..2774626 100644--- a/src/components/agent/AgentChatPanel.tsx+++ b/src/components/agent/AgentChatPanel.tsx@@ -7,16 +7,17 @@ import { AgentChatEmptyState } from "@/components/agent/AgentChatEmptyState";import { AgentChatInput } from "@/components/agent/AgentChatInput";import { AgentChatMessages } from "@/components/agent/AgentChatMessages";import { useAgentChat } from "@/components/agent/AgentChatProvider";-import { useResizablePanel } from "@/hooks/useResizablePanel";import { APP_CONSTANTS } from "@/lib/constants";export function AgentChatPanel() {- const { isOpen, close, clear, messages } = useAgentChat();- // Not "ai-panel-width": that key is shared by the three AI sheets, and- // dragging this panel would silently resize all of them.- const { width, handleMouseDown } = useResizablePanel(- APP_CONSTANTS.AGENT_CHAT_PANEL_WIDTH_KEY,- );+ const {+ isOpen,+ close,+ clear,+ messages,+ panelWidth: width,+ startResize,+ } = useAgentChat();return (<Sheet@@ -44,14 +45,14 @@ export function AgentChatPanel() {{/* VS Code-style drag handle; docking only applies at lg+ */}<divclassName="absolute left-0 top-0 h-full w-1 cursor-col-resize z-10 group hidden lg:block"- onMouseDown={handleMouseDown}+ onMouseDown={startResize}><div className="h-full w-px bg-transparent group-hover:bg-primary/50 transition-colors" /></div><div className="flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0"><SheetTitle className="text-[11px] font-bold tracking-[0.15em] uppercase text-foreground leading-none shrink-0 m-0">- JOBSYNC AGENT+ AI AGENT</SheetTitle><span className="text-muted-foreground/30 text-xs select-none">···diff --git a/src/components/agent/AgentChatProvider.tsx b/src/components/agent/AgentChatProvider.tsxindex 32f75a6..4fcf5f2 100644--- a/src/components/agent/AgentChatProvider.tsx+++ b/src/components/agent/AgentChatProvider.tsx@@ -19,6 +19,8 @@ import {} from "ai";import { hasPendingApproval } from "@/lib/agent/paste";import { useRightRail } from "@/context/RightRailContext";+import { useResizablePanel } from "@/hooks/useResizablePanel";+import { APP_CONSTANTS } from "@/lib/constants";import { clearChatConversation } from "@/actions/agentChat.actions";import { getUserSettings } from "@/actions/userSettings.actions";import { checkOllamaConnection } from "@/utils/ai.utils";@@ -39,6 +41,15 @@ function useAgentChatValue(initialMessages: UIMessage[]) {const { holder, requestOpen, close: releaseRail } = useRightRail();const [isOpen, setIsOpen] = useState(false);+ // Lives here, not in the panel: SidebarInset offsets page content by this+ // width so the panel docks beside the page instead of over it.+ // Not "ai-panel-width": that key is shared by the three AI sheets, and+ // dragging this panel would silently resize all of them.+ const {+ width: panelWidth,+ handleMouseDown: startResize,+ isDragging: isResizing,+ } = useResizablePanel(APP_CONSTANTS.AGENT_CHAT_PANEL_WIDTH_KEY);const [interruptedTurn, setInterruptedTurn] = useState(false);const [preflight, setPreflight] = useState<Preflight>({checked: false,@@ -133,6 +144,17 @@ function useAgentChatValue(initialMessages: UIMessage[]) {if (isOpen && holder !== AGENT_CHAT_PANEL_ID) close();}, [holder, isOpen, close]);+ // A signal, not a value: the composer's textarea is uncontrolled, so it+ // remounts on the nonce and picks the text up as its defaultValue.+ const [prefill, setPrefill] = useState<{ text: string; nonce: number }>();+ const prefillComposer = useCallback(+ (text: string) => setPrefill({ text, nonce: Date.now() }),+ [],+ );++ // Same reason as prefill: nothing else empties an uncontrolled textarea.+ const [composerNonce, setComposerNonce] = useState(0);+// Order matters: a late onFinish would otherwise write the conversation// back after the delete.const clear = useCallback(async () => {@@ -141,6 +163,10 @@ function useAgentChatValue(initialMessages: UIMessage[]) {chat.setMessages([]);chat.clearError();setInterruptedTurn(false);+ // Dropped, not kept: a stale prefill would refill the textarea the next+ // time it remounts.+ setPrefill(undefined);+ setComposerNonce((n) => n + 1);}, [chat]);const approvalPending = useMemo(@@ -150,14 +176,6 @@ function useAgentChatValue(initialMessages: UIMessage[]) {const dismissInterrupted = useCallback(() => setInterruptedTurn(false), []);- // A signal, not a value: the composer's textarea is uncontrolled, so it- // remounts on the nonce and picks the text up as its defaultValue.- const [prefill, setPrefill] = useState<{ text: string; nonce: number }>();- const prefillComposer = useCallback(- (text: string) => setPrefill({ text, nonce: Date.now() }),- [],- );-return {isOpen,open,@@ -177,6 +195,10 @@ function useAgentChatValue(initialMessages: UIMessage[]) {preflight,prefill,prefillComposer,+ composerNonce,+ panelWidth,+ startResize,+ isResizing,};}diff --git a/src/hooks/useResizablePanel.ts b/src/hooks/useResizablePanel.tsindex 322ee0c..f7d004b 100644--- a/src/hooks/useResizablePanel.ts+++ b/src/hooks/useResizablePanel.ts@@ -13,6 +13,8 @@ export function useResizablePanel(storageKey: string) {getFromLocalStorage(storageKey, DEFAULT_WIDTH));const isDragging = useRef(false);+ // Mirrored into state so consumers can suppress width transitions mid-drag.+ const [dragging, setDragging] = useState(false);const startX = useRef(0);const startWidth = useRef(0);const widthRef = useRef(width);@@ -23,6 +25,7 @@ export function useResizablePanel(storageKey: string) {const handleMouseDown = useCallback((e: React.MouseEvent) => {isDragging.current = true;+ setDragging(true);startX.current = e.clientX;startWidth.current = widthRef.current;document.body.style.userSelect = "none";@@ -43,6 +46,7 @@ export function useResizablePanel(storageKey: string) {const onMouseUp = () => {if (!isDragging.current) return;isDragging.current = false;+ setDragging(false);document.body.style.userSelect = "";document.body.style.cursor = "";saveToLocalStorage(storageKey, widthRef.current);@@ -56,5 +60,5 @@ export function useResizablePanel(storageKey: string) {};}, [storageKey]);- return { width, handleMouseDown };+ return { width, handleMouseDown, isDragging: dragging };}