Skip to content

fix: hide agent chat button outside of project pages#570

Closed
AravJuneja wants to merge 2 commits intotraceroot-ai:mainfrom
AravJuneja:fix/agent-chat-button-557
Closed

fix: hide agent chat button outside of project pages#570
AravJuneja wants to merge 2 commits intotraceroot-ai:mainfrom
AravJuneja:fix/agent-chat-button-557

Conversation

@AravJuneja
Copy link
Copy Markdown

@AravJuneja AravJuneja commented Mar 25, 2026

Summary

Type of Change

  • feat - A new feature
  • fix - A bug fix
  • docs - Documentation only changes
  • style - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor - A code change that neither fixes a bug nor adds a feature
  • perf - A code change that improves performance
  • test - Adding missing tests or correcting existing tests
  • build - Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci - Changes to our Cl configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore - Other changes that don't modify sc or test files
  • revert - Reverts a previous commit
  • security - A security fix or improvement
  • github - Changes to our GitHub configuration files and scripts
  • other (please describe):

Details

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING.md
  • I have added/updated tests where applicable
  • I have added screenshots or recordings for UI changes (if applicable)
  • I have updated documentation where necessary

@AravJuneja AravJuneja requested a review from a team as a code owner March 25, 2026 22:53
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR hides the AI chat assistant button when the user is not on a project page (i.e., the URL does not contain /projects/), preventing the button from appearing on unrelated pages like settings or dashboards.

Key changes:

  • Added isProjectPage derived from usePathname() to conditionally render the AI assistant toggle button
  • The AiAssistantPanel component itself remains always-mounted; only the trigger button is hidden

Issue found:

  • The aiPanelOpen state is not reset when navigating away from a project page. Since AiAssistantPanel is always rendered with open={aiPanelOpen}, the panel can remain visible after the user leaves a project page, but the button to dismiss it is now hidden. A useEffect that sets aiPanelOpen to false when isProjectPage becomes false would address this.

Confidence Score: 3/5

  • The core fix is correct but introduces a state-management gap that can leave the AI panel stuck open with no visible way to close it.
  • The pathname-based conditional correctly hides the button on non-project pages, which is the stated goal. However, the aiPanelOpen boolean is never reset on navigation, so if the panel is open and the user navigates away, the panel remains mounted/visible while the toggle button disappears — a clear UX regression that should be addressed before merging.
  • frontend/ui/src/components/layout/app-layout.tsx — needs a useEffect to reset aiPanelOpen when isProjectPage becomes false

Important Files Changed

Filename Overview
frontend/ui/src/components/layout/app-layout.tsx Conditionally renders the AI chat button only on project pages using a pathname check, but the underlying aiPanelOpen state is not reset when navigating away, potentially leaving the panel open with no toggle button visible.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Route change] --> B{pathname includes '/projects/'?}
    B -- Yes --> C[Render AI chat button]
    B -- No --> D[Hide AI chat button]
    C --> E{User clicks button}
    E --> F[Toggle aiPanelOpen state]
    F --> G[AiAssistantPanel renders open]
    G --> H{User navigates away?}
    H -- No --> G
    H -- Yes --> B
    D --> I[aiPanelOpen NOT reset]
    I --> J[AiAssistantPanel stays open\nif previously opened]
    style J fill:#f96,stroke:#c00
Loading

Comments Outside Diff (1)

  1. frontend/ui/src/components/layout/app-layout.tsx, line 79 (link)

    P2 AI panel stays open after navigating away from a project page

    AiAssistantPanel is always rendered (line 79) with the current aiPanelOpen state, but the toggle button is now hidden on non-project pages. This means if a user opens the panel on a project page and then navigates to a non-project page, the panel will remain visible with no way to toggle it closed (unless AiAssistantPanel has its own internal close control).

    To ensure the panel is closed when leaving a project page, reset the state reactively:

    useEffect(() => {
      if (!isProjectPage) {
        setAiPanelOpen(false);
      }
    }, [isProjectPage]);

    Add this effect alongside the existing state declarations (and import useEffect from React).

Reviews (1): Last reviewed commit: "fix: hide agent chat button outside of p..." | Re-trigger Greptile

@AravJuneja AravJuneja force-pushed the fix/agent-chat-button-557 branch from dc3928c to 0aed4d9 Compare March 25, 2026 22:55
@AravJuneja AravJuneja closed this Mar 25, 2026
@AravJuneja
Copy link
Copy Markdown
Author

closing in favor of #558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants