The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Fix sidebar new chat highlighting and new chat redirect logic from tfy agent (#678)
harshil-2096ef278ddfc36f
diff --git a/.changeset/quiet-chats-reset.md b/.changeset/quiet-chats-reset.mdnew file mode 100644index 000000000..a21797f5d--- /dev/null+++ b/.changeset/quiet-chats-reset.md@@ -0,0 +1,5 @@+---+"@truefoundry/trueforge-ui": patch+---++Stop highlighting New Chat while trying a named agent, and clear the Try Agent URL and history filter when starting a new chat.diff --git a/packages/trueforge-ui/src/layouts/SidebarLayout.tsx b/packages/trueforge-ui/src/layouts/SidebarLayout.tsxindex d23c9d68a..58f32be92 100644--- a/packages/trueforge-ui/src/layouts/SidebarLayout.tsx+++ b/packages/trueforge-ui/src/layouts/SidebarLayout.tsx@@ -59,7 +59,11 @@ function SidebarNav(): ReactNode {shell?.sessionsOpen === true ||shell?.schedulesOpen === true;const mode = shell?.mode;- const newChatSelected = !overlayOpen && mode?.status === 'active' && !mode.isCreateAgent;+ const newChatSelected =+ !overlayOpen &&+ mode?.status === 'active' &&+ !mode.isCreateAgent &&+ shell?.historyAgentFilter?.intent !== 'try-agent';const newAgentSelected = !overlayOpen && mode != null && shellIsCreateAgent(mode);const handleNewChat = () => {diff --git a/packages/trueforge-ui/src/server/ShellModeContext.tsx b/packages/trueforge-ui/src/server/ShellModeContext.tsxindex 4408e4899..3cb8d7a64 100644--- a/packages/trueforge-ui/src/server/ShellModeContext.tsx+++ b/packages/trueforge-ui/src/server/ShellModeContext.tsx@@ -479,6 +479,7 @@ export function ShellModeProvider({const openDraft = useCallback(() => {if (!isComposerEnabled) return;refreshCapabilities?.();+ setHistoryAgentFilter(null);selectLibraryAgent({ isMutable: true, isCreateAgent: false, agentSpec: chatSeedRef.current });}, [isComposerEnabled, refreshCapabilities, selectLibraryAgent]);diff --git a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsxindex d1380cf1c..15d8dca99 100644--- a/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx+++ b/packages/trueforge-ui/test/containers/TrueForgeUI.test.tsx@@ -604,12 +604,20 @@ describe('SidebarLayout', () => {});it('highlights New Chat, New Agent, and Settings when selected', async () => {- function TryAgentButton() {+ function NamedAgentButtons() {const shell = useShellMode();return (- <button type="button" onClick={() => shell.selectLibraryAgent({ isMutable: false, agentName: 'support' })}>- Try support- </button>+ <>+ <button type="button" onClick={() => shell.selectLibraryAgent({ isMutable: false, agentName: 'support' })}>+ Open history+ </button>+ <button+ type="button"+ onClick={() => shell.selectLibraryAgent({ isMutable: false, agentId: 'support-id', agentName: 'support' })}+ >+ Try support+ </button>+ </>);}@@ -619,7 +627,7 @@ describe('SidebarLayout', () => {<ShellModeProvider><AgentConfigInstructionsProvider><RuntimeHarness messages={[]}>- <TryAgentButton />+ <NamedAgentButtons /><div className="h-96"><SidebarLayout /></div>@@ -635,10 +643,14 @@ describe('SidebarLayout', () => {expect(newChat).toHaveAttribute('aria-current', 'page');expect(newAgent).not.toHaveAttribute('aria-current');- fireEvent.click(screen.getByRole('button', { name: 'Try support' }));+ fireEvent.click(screen.getByRole('button', { name: 'Open history' }));expect(newChat).toHaveAttribute('aria-current', 'page');expect(newAgent).not.toHaveAttribute('aria-current');+ fireEvent.click(screen.getByRole('button', { name: 'Try support' }));+ expect(newChat).not.toHaveAttribute('aria-current');+ expect(newAgent).not.toHaveAttribute('aria-current');+fireEvent.click(newAgent);const selectedNewAgent = await screen.findByRole('button', { name: 'Start new agent' });const deselectedNewChat = screen.getByRole('button', { name: 'Start new chat' });diff --git a/packages/trueforge-ui/test/routing/ShellRouteSync.test.tsx b/packages/trueforge-ui/test/routing/ShellRouteSync.test.tsxindex 99c506f58..14ebacf7f 100644--- a/packages/trueforge-ui/test/routing/ShellRouteSync.test.tsx+++ b/packages/trueforge-ui/test/routing/ShellRouteSync.test.tsx@@ -208,6 +208,18 @@ describe('ShellRouteSync', () => {expect(search).toBe('?try_agent_name=helper');});+ it('clears Try Agent URL and history filter when New Chat opens', async () => {+ renderSync({ initialEntries: ['/agents/helper'], agentConfig: { mode: 'AgentLibraryWithComposer' } });+ await waitFor(() => expect(shell.listSessionsAgentId).toBe('helper-id'));++ act(() => shell.openDraft());++ expect(pathname).toBe('/');+ expect(search).toBe('');+ expect(shell.historyAgentFilter).toBeNull();+ expect(shell.listSessionsAgentId).toBeUndefined();+ });+it('writes and clears a manual history filter without changing the chat place', () => {renderSync({ initialEntries: ['/'], agentConfig: { mode: 'AgentLibraryWithComposer' } });