Skip to content

Conversation

@tomerqodo
Copy link

Benchmark PR from qodo-benchmark#230

@greptile-apps
Copy link

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This PR completes the removal of the inactive tabs feature from Firefox iOS by deleting UI components, middleware logic, state management, and associated tests.

Key Changes

  • Removed InactiveTabsModel, InactiveTabsCell, InactiveTabsHeaderView, InactiveTabsFooterView, and InactiveTabsSectionManager files
  • Eliminated inactiveTabs and isInactiveTabsExpanded state from TabsPanelState and TabDisplayModel
  • Removed inactive tab action types: toggleInactiveTabs, closeInactiveTab, undoCloseInactiveTab, closeAllInactiveTabs, undoCloseAllInactiveTabs, refreshInactiveTabs
  • Deleted middleware handlers for inactive tab operations in TabManagerMiddleware
  • Simplified TabDisplayView layout by removing inactive tabs section logic
  • Updated TabDisplayDiffableDataSource to only handle the .tabs section
  • Removed inactive tab toast types from ToastType enum
  • Deleted inactive tabs test cases from TabsPanelStateTests and other test files

Critical Issue

  • Array index out of bounds bug on TabsPanelState.swift:143 - the code now returns state.tabs.count instead of state.tabs.count - 1, which will cause a crash when attempting to scroll to the last tab when no tab is selected

Confidence Score: 0/5

  • This PR contains a critical index out-of-bounds bug that will cause runtime crashes
  • The scroll behavior change on line 143 of TabsPanelState.swift introduces an array index out-of-bounds error. When there are no selected tabs, the code attempts to scroll to state.tabs.count, which is one past the last valid index. For example, with 3 tabs (valid indices 0-2), it would try to access index 3. This will crash at runtime when scrolling. The existing test at TabsPanelStateTests.swift:152 still expects tabCount - 1, confirming this was an incorrect change.
  • Pay immediate attention to TabsPanelState.swift line 143 - this must be fixed before merge to prevent crashes

Important Files Changed

Filename Overview
firefox-ios/Client/Frontend/Browser/Tabs/State/TabsPanelState.swift Critical index out-of-bounds bug on line 143 when scrolling without selected tab
firefox-ios/Client/Frontend/Browser/Tabs/Middleware/TabManagerMiddleware.swift Removed inactive tabs middleware logic and helper methods
firefox-ios/Client/Frontend/Browser/Tabs/Views/TabDisplayView.swift Removed inactive tabs UI components and simplified layout logic
firefox-ios/firefox-ios-tests/Tests/ClientTests/TabTray/TabsPanelStateTests.swift Removed inactive tabs tests but existing test on line 152 conflicts with code change

Sequence Diagram

sequenceDiagram
    participant User
    participant TabDisplayView
    participant Store
    participant TabManagerMiddleware
    participant TabsPanelState
    participant DataSource

    Note over User,DataSource: Inactive Tabs Feature Removal

    User->>TabDisplayView: View tabs panel
    TabDisplayView->>Store: Dispatch TabPanelMiddlewareAction.didLoadTabPanel
    Store->>TabManagerMiddleware: Handle didLoadTabPanel
    TabManagerMiddleware->>TabManagerMiddleware: getTabsDisplayModel()
    Note over TabManagerMiddleware: No longer calls refreshInactiveTabs()
    TabManagerMiddleware->>Store: Dispatch refreshTab action
    Store->>TabsPanelState: Reduce TabPanelMiddlewareAction
    Note over TabsPanelState: Removed inactiveTabs & isInactiveTabsExpanded state
    TabsPanelState-->>Store: Updated state (tabs only)
    Store-->>TabDisplayView: State update
    TabDisplayView->>DataSource: updateSnapshot(state)
    Note over DataSource: Only creates .tabs section (no .inactiveTabs)
    DataSource-->>TabDisplayView: Updated UI

    User->>TabDisplayView: Switch between panels
    TabDisplayView->>Store: Dispatch willAppearTabPanel
    Store->>TabManagerMiddleware: Handle willAppearTabPanel
    TabManagerMiddleware->>TabsPanelState: Create scroll behavior
    Note over TabsPanelState: Bug: Returns state.tabs.count instead of count-1
    TabsPanelState-->>Store: ScrollState with toIndex
    Store-->>TabDisplayView: Updated scroll state
    TabDisplayView->>TabDisplayView: scrollToTab(scrollState)
    Note over TabDisplayView: IndexPath created with scrollState.toIndex
    Note over TabDisplayView: May crash if index out of bounds
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

22 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

// not contain a selected tab. In that case, we should scroll to the bottom of the panel.
// Note: Could optimize further by scrolling to the most recent tab if we had `lastExecutedTime` in our model
return ScrollState(toIndex: state.tabs.count - 1, isInactiveTabSection: false, withAnimation: shouldAnimate)
return ScrollState(toIndex: state.tabs.count, withAnimation: shouldAnimate)
Copy link

Choose a reason for hiding this comment

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

logic: index out of bounds - changed from state.tabs.count - 1 to state.tabs.count

This will cause a crash when scrolling to a non-existent index. For an array with 3 items (indices 0, 1, 2), state.tabs.count is 3, which is out of bounds. The test testCreateTabScrollBehavior_forScrollToSelectedTab_noSelectedTab_returnsLastTab_ifTabsNotEmpty in TabsPanelStateTests.swift:152 still expects tabCount - 1.

Suggested change
return ScrollState(toIndex: state.tabs.count, withAnimation: shouldAnimate)
return ScrollState(toIndex: state.tabs.count - 1, withAnimation: shouldAnimate)
Prompt To Fix With AI
This is a comment left during a code review.
Path: firefox-ios/Client/Frontend/Browser/Tabs/State/TabsPanelState.swift
Line: 143:143

Comment:
**logic:** index out of bounds - changed from `state.tabs.count - 1` to `state.tabs.count`

This will cause a crash when scrolling to a non-existent index. For an array with 3 items (indices 0, 1, 2), `state.tabs.count` is 3, which is out of bounds. The test `testCreateTabScrollBehavior_forScrollToSelectedTab_noSelectedTab_returnsLastTab_ifTabsNotEmpty` in `TabsPanelStateTests.swift:152` still expects `tabCount - 1`.

```suggestion
                return ScrollState(toIndex: state.tabs.count - 1, withAnimation: shouldAnimate)
```

How can I resolve this? If you propose a fix, please make it concise.

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.

3 participants