Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/core-app/src/main/modules/box-tool/core-box/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class CoreBoxModule extends BaseModule {
const loading = payload.loading === true
const recommendationPending = payload.recommendationPending === true

// Strict collapse condition: no results, not loading, not waiting for recommendation
const shouldCollapse = resultCount === 0 && !loading && !recommendationPending
if (shouldCollapse) {
coreBoxManager.shrink()
Expand All @@ -198,7 +199,13 @@ export class CoreBoxModule extends BaseModule {

// When waiting for data (loading/recommendation), keep current window size stable.
// This avoids collapse-then-expand jitter while results are still pending.
// However, if already collapsed, stay collapsed.
if (resultCount === 0 && (loading || recommendationPending)) {
if (coreBoxManager.isCollapsed) {
// Already collapsed, keep it collapsed
return
}
// Not collapsed yet, keep current size to avoid jitter
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ export function useResize(options: UseResizeOptions): void {
? (recommendationPending?.value ?? false)
: false

const height = calculateDesiredHeight(resultCount)
// When no results and not waiting for data, force minimum height
let height: number
if (resultCount === 0 && !isLoading && !isRecommendationPending) {
height = MIN_HEIGHT
} else {
height = calculateDesiredHeight(resultCount)
}
Comment on lines +76 to +82
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix ESLint brace-style violation.

ESLint reports style/brace-style at Line 80 because else is on the same line as the closing brace. Adjust to the configured style to avoid lint failures.

🧹 Suggested fix
-    } else {
+    }
+    else {
       height = calculateDesiredHeight(resultCount)
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// When no results and not waiting for data, force minimum height
let height: number
if (resultCount === 0 && !isLoading && !isRecommendationPending) {
height = MIN_HEIGHT
} else {
height = calculateDesiredHeight(resultCount)
}
// When no results and not waiting for data, force minimum height
let height: number
if (resultCount === 0 && !isLoading && !isRecommendationPending) {
height = MIN_HEIGHT
}
else {
height = calculateDesiredHeight(resultCount)
}
🧰 Tools
🪛 ESLint

[error] 80-80: Closing curly brace appears on the same line as the subsequent block.

(style/brace-style)

🤖 Prompt for AI Agents
In `@apps/core-app/src/renderer/src/modules/box/adapter/hooks/useResize.ts` around
lines 76 - 82, The brace-style lint error is caused by the `else` being on the
same line as the closing brace in the conditional that sets `height` (using
`resultCount`, `isLoading`, `isRecommendationPending`, `MIN_HEIGHT`, and
`calculateDesiredHeight`); fix it by moving `else` to its own line and
formatting the if/else block to match the project's brace-style (i.e., place the
closing brace on its own line followed by a newline then `else`), ensuring the
`height` assignment logic remains the same in `useResize.ts`.


const payload: CoreBoxLayoutUpdateRequest = {
height,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ export function useSearch(
pendingSearchEndById.clear()
pendingSearchUpdatesById.clear()
window.dispatchEvent(new CustomEvent('corebox:layout-refresh'))

// Trigger collapse if no input and no results
if (!searchVal.value || searchVal.value.trim() === '') {
transport.send(CoreBoxEvents.ui.expand, { mode: 'collapse' }).catch(() => {})
}
}

const broadcastDivisionBoxInput = (query: TuffQuery): void => {
Expand Down Expand Up @@ -357,7 +362,11 @@ export function useSearch(
const RECOMMENDATION_TIMEOUT_MS = 400
recommendationTimeoutId = setTimeout(() => {
if (recommendationPending.value && searchResults.value.length === 0) {
recommendationPending.value = false
loading.value = false
resetSearchState()
// Explicitly trigger collapse when recommendation times out
transport.send(CoreBoxEvents.ui.expand, { mode: 'collapse' }).catch(() => {})
}
recommendationTimeoutId = null
}, RECOMMENDATION_TIMEOUT_MS)
Expand Down