Skip to content

Bugs: Template tab - isWebMode not set correctly when clicking/cloning web templates #3727

@devin-ai-integration

Description

@devin-ai-integration

Bug Report: Template Tab Navigation Issues

Bug 1: Clicking a web template from TemplatesHomepage does not navigate to template details

Location: apps/desktop/src/components/main/body/templates/index.tsx

From TemplatesHomepage, clicking a web template card calls onSelectWebTemplate which maps to setSelectedWebIndex (line 210-220). This sets selectedWebIndex and showHomepage: false, but does not set isWebMode: true.

The default state created by getDefaultState sets isWebMode: null, and isWebMode is read as tab.state.isWebMode ?? userTemplates.length === 0 (line 174). Since the user never manually switched to web mode, isWebMode stays false (assuming the user has any templates). The TemplateDetailsColumn (details.tsx:33) checks isWebMode first — when it's false, it looks for selectedMineId instead of selectedWebTemplate, resulting in "Select a template to view details" being shown instead of the web template preview.

Expected: Clicking a web template from the homepage should show its details.
Actual: Nothing happens (empty detail pane) because isWebMode stays false.

Bug 2: Cloning a web template does not switch user to the cloned template

Location: apps/desktop/src/components/main/body/templates/index.tsx, handleCloneTemplate (line 267-291)

const handleCloneTemplate = useCallback(
  (template) => {
    // ... creates new template ...
    setIsWebMode(false);       // Call 1
    setSelectedMineId(newId);  // Call 2
  },
  [user_id, setRow, setIsWebMode, setSelectedMineId],
);

Both setIsWebMode and setSelectedMineId call updateTabState by spreading tab.state. Since both callbacks capture the same tab from the closure (React state hasn't updated yet), setSelectedMineId spreads the old tab.state which still has isWebMode: true (or null). This effectively overrides the isWebMode: false set by setIsWebMode.

Expected: After cloning, user should see the cloned template in "My Templates" mode.
Actual: isWebMode remains truthy, so the detail column stays in web mode.

Design Issue: isWebMode should be derived state

isWebMode is stored independently alongside selectedMineId and selectedWebIndex, allowing unrepresentable states such as:

  • isWebMode: true with selectedMineId set
  • isWebMode: false with selectedWebIndex set

isWebMode should ideally be derived from selectedMineId / selectedWebIndex (or a similar single source of truth), eliminating the class of bugs where these values get out of sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions