Skip to content

Conversation

@michaelneale
Copy link
Collaborator

Previously it would load the extensions on GUI start - and then when you start interacting, it would load them any way, this removes that un-necessary initial load.

Copilot AI review requested due to automatic review settings January 6, 2026 08:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the desktop app startup by removing unnecessary extension loading that happened on GUI initialization. Extensions are now loaded only when the agent actually starts (i.e., when the user begins interacting), preventing duplicate loading work.

Key changes:

  • Removed early extension/session loading from App.tsx on hub page load
  • Added duplicate-prevention logic to ExtensionManager to avoid re-adding already loaded extensions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ui/desktop/src/App.tsx Removed useEffect that pre-loaded chat session and extensions on hub page; removed unused imports and state setters; added explanatory comment
crates/goose/src/agents/extension_manager.rs Added early return in add_extension() to skip re-adding extensions that are already loaded

Copy link
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice. does need a bit of post LLM cleaning

@tlongwell-block
Copy link
Collaborator

/goose

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Summary: This PR improves startup performance by removing redundant extension loading on GUI start - extensions are now only loaded when the agent actually starts. The approach is sound, though there's some dead code cleanup that could be done.

🟡 Warnings

  1. Dead state variables in App.tsx (lines 366, 369)

    The state variables agentWaitingMessage and isExtensionsLoading now have no setters:

    const [agentWaitingMessage] = useState<string | null>(null);
    const [isExtensionsLoading] = useState(false);

    These will always be null and false respectively, making them dead code. They're still passed to ChatProvider and Hub, but will never change. Consider either:

    • Removing them entirely and updating ChatProvider/Hub to not require these props
    • Hardcoding the values directly in the JSX props if the types require them
  2. TOCTOU race condition in add_extension (extension_manager.rs:481-593)

    The early-return check acquires a lock, checks, and releases it:

    if self.extensions.lock().await.contains_key(&sanitized_name) {
        return Ok(());
    }
    // ... expensive client creation happens here without lock ...
    let mut extensions = self.extensions.lock().await;
    extensions.insert(final_name, ...);

    If two concurrent calls for the same extension occur (extensions are loaded in parallel via Promise.allSettled), both may pass the check, both create clients, and the second overwrites the first. This wastes work but doesn't cause data corruption - the end state is still correct. This is acceptable for the optimization goal of this PR, but worth noting for future improvement.

🟢 Suggestions

  1. Remove unused import cleanup (App.tsx line 42)

    The blank line where NoProviderOrModelError, useAgent was imported now just shows:

    import { View, ViewOptions } from './utils/navigationUtils';
    
    import { useNavigation } from './hooks/useNavigation';

    This could be cleaned up to remove the extra blank line, though it's very minor.

✅ Highlights

  • Good performance optimization - pre-loading extensions on startup was indeed redundant since they load when the agent starts anyway
  • The comment explaining the change is helpful: // Don't pre-load session/extensions on Hub - wait until user actually starts chatting
  • The idempotency check in add_extension is a reasonable safety measure

Review generated by goose

@michaelneale
Copy link
Collaborator Author

@DOsinga yeah this was a late night hack, I wasn't even sure I was reading things right, can tidy this up for sure.

Copilot AI review requested due to automatic review settings January 7, 2026 05:44
@michaelneale
Copy link
Collaborator Author

thanks @DOsinga @tlongwell-block there was even more I could delete!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Copy link
Collaborator

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks best in red

@michaelneale michaelneale merged commit 7d751b3 into main Jan 7, 2026
26 checks passed
@michaelneale michaelneale deleted the micn/load-extensions-on-session branch January 7, 2026 06:03
aharvard added a commit that referenced this pull request Jan 7, 2026
* main:
  fix: we load extensions when agent starts so don't do it up front (#6350)
  docs: credit HumanLayer in RPI tutorial (#6365)
  Blog: Goose Lands MCP Apps (#6172)
michaelneale added a commit that referenced this pull request Jan 8, 2026
* main: (31 commits)
  added validation and debug for invalid call tool result (#6368)
  Update MCP apps tutorial: fix _meta structure and version prereq (#6404)
  Fixed fonts (#6389)
  Update confidence levels prompt injection detection to reduce false positive rates (#6390)
  Add ML-based prompt injection detection  (#5623)
  docs: update custom extensions tutorial (#6388)
  fix ResultsFormat error when loading old sessions (#6385)
  docs: add MCP Apps tutorial and documentation updates (#6384)
  changed z-index to make sure the search highlighter does not appear on modal overlay (#6386)
  Handling special claude model response in github copilot provider (#6369)
  fix: prevent duplicate rendering when tool returns both mcp-ui and mcp-apps resources (#6378)
  fix: update MCP Apps _meta.ui.resourceUri to use nested format (SEP-1865) (#6372)
  feat(providers): add streaming support for Google Gemini provider (#6191)
  Blog: edit links in mcp apps post (#6371)
  fix: prevent infinite loop of tool-input notifications in MCP Apps (#6374)
  fix: Show platform-specific keyboard shortcuts in UI (#6323)
  fix: we load extensions when agent starts so don't do it up front (#6350)
  docs: credit HumanLayer in RPI tutorial (#6365)
  Blog: Goose Lands MCP Apps (#6172)
  Claude 3.7 is out. we had some harcoded stuff (#6197)
  ...
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.

5 participants