feat(inventory-list): add item counter#186
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an item-count display feature: new config key controls display mode; TabularList computes counts per mode and filters by current name-column sort; SortedListHeader gains updateItemCount and renders a CountColumn; build sources include the new ActionScript files. Changes
Sequence Diagram(s)sequenceDiagram
participant TabularList
participant SortedListHeader
participant CountColumn
participant UI
TabularList->>TabularList: UpdateList()
TabularList->>TabularList: Read config.ItemList.itemCount.mode
TabularList->>TabularList: Iterate rows, compute totalItemsCount (mode/filter aware)
TabularList->>SortedListHeader: updateItemCount(totalItemsCount)
SortedListHeader->>SortedListHeader: if count >= 0 create/cache CountColumn
SortedListHeader->>CountColumn: apply text format, set label "(N)"
SortedListHeader->>CountColumn: position based on sort state
SortedListHeader->>SortedListHeader: adjust buttonArea._width
CountColumn->>UI: render count next to Name column
opt count < 0
SortedListHeader->>CountColumn: hide CountColumn
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 41 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@source/actionscript/Common/skyui/components/list/SortedListHeader.as`:
- Around line 6-7: The header counter is initialized visible and hiding only the
clip leaves stale hitbox widths; change the default to start hidden by setting
_countColumn._visible = false (and set _itemCount to a sentinel if used for
visibility) and update any hide/show code to both toggle _countColumn._visible
and immediately reflow the header hitboxes—adjust buttonArea._width (subtract or
add _countColumn._width) or call the existing reflow/invalidate layout routine
(e.g., reflowHeaderHitboxes or invalidateLayout) after changing visibility so
the header hitboxes update immediately.
In `@source/actionscript/Common/skyui/components/list/TabularList.as`:
- Around line 87-89: The code in TabularList.as accesses this._layout and
this._layout.columnLayoutData directly (activeColIdx =
this._layout.activeColumnIndex; and checking columnLayoutData[...] against
ListLayout.COL_TYPE_NAME) without null/bounds checks; add a defensive guard at
the start of the block to ensure this._layout is non-null,
this._layout.columnLayoutData exists, and activeColIdx is a valid index before
using it (or bail/return/choose a safe default), updating references to
activeColIdx and the type check accordingly to avoid init-order null
dereferences.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8ae6250c-c709-4172-bb0b-5f6b85b694cc
📒 Files selected for processing (4)
data/interface/skyui/config.txtsource/actionscript/Common/skyui/components/list/SortedListHeader.assource/actionscript/Common/skyui/components/list/TabularList.assource/swfsources.cmake
There was a problem hiding this comment.
♻️ Duplicate comments (1)
source/actionscript/Common/skyui/components/list/TabularList.as (1)
87-89:⚠️ Potential issue | 🟠 MajorAdd index/entry guard before active-column type access.
Line 87-Line 88 still assume
activeColIdxmaps to a validcolumnLayoutDataentry. If the index is out of range/stale,.typecan dereferenceundefined.Suggested fix
- var activeColIdx = this._layout.activeColumnIndex; - var isActiveColName = (this._layout.columnLayoutData[activeColIdx].type == skyui.components.list.ListLayout.COL_TYPE_NAME); + var activeColIdx = this._layout.activeColumnIndex; + var columnData = this._layout.columnLayoutData[activeColIdx]; + if (activeColIdx == undefined || activeColIdx < 0 || columnData == undefined) { + this.header.updateItemCount(-1); + return; + } + var isActiveColName = (columnData.type == skyui.components.list.ListLayout.COL_TYPE_NAME);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@source/actionscript/Common/skyui/components/list/TabularList.as` around lines 87 - 89, The code accesses this._layout.columnLayoutData[activeColIdx].type without verifying the index or entry exists; update the logic around activeColIdx (used in TabularList.as) to first check that this._layout and this._layout.columnLayoutData are defined and that activeColIdx is a valid index (0 <= activeColIdx < columnLayoutData.length) and that columnLayoutData[activeColIdx] is not null/undefined before reading .type, and default isActiveColName to false when the guard fails; reference the variables activeColIdx, _layout, columnLayoutData and the constant ListLayout.COL_TYPE_NAME when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@source/actionscript/Common/skyui/components/list/TabularList.as`:
- Around line 87-89: The code accesses
this._layout.columnLayoutData[activeColIdx].type without verifying the index or
entry exists; update the logic around activeColIdx (used in TabularList.as) to
first check that this._layout and this._layout.columnLayoutData are defined and
that activeColIdx is a valid index (0 <= activeColIdx < columnLayoutData.length)
and that columnLayoutData[activeColIdx] is not null/undefined before reading
.type, and default isActiveColName to false when the guard fails; reference the
variables activeColIdx, _layout, columnLayoutData and the constant
ListLayout.COL_TYPE_NAME when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9291a660-ca9b-4eab-af0f-10f3e732b5e8
📒 Files selected for processing (3)
data/interface/skyui/config.txtsource/actionscript/Common/skyui/components/list/SortedListHeader.assource/actionscript/Common/skyui/components/list/TabularList.as
🚧 Files skipped from review as they are similar to previous changes (2)
- data/interface/skyui/config.txt
- source/actionscript/Common/skyui/components/list/SortedListHeader.as
Resolve #185.
Summary by CodeRabbit