From db781f40cb23d2c4185636908e7721416b1589c7 Mon Sep 17 00:00:00 2001 From: Felix Lu Date: Tue, 3 Dec 2024 01:11:05 -0800 Subject: [PATCH 1/2] fix: improve instruction selector loading state handling --- extensions/changelog.md | 9 + .../components/instruction-selector/index.tsx | 158 +++++++++--------- .../src/hooks/use-model-instructions.ts | 8 +- 3 files changed, 93 insertions(+), 82 deletions(-) diff --git a/extensions/changelog.md b/extensions/changelog.md index 4028234..cf9b4ed 100644 --- a/extensions/changelog.md +++ b/extensions/changelog.md @@ -2,6 +2,15 @@ # Changelog of the extensions +## fix: Instruction Selector Loading State - 12/3/2024 - @lumpinif + +### Bug Fixes + +- Improved loading state handling in instruction selector + - Fixed loading state visibility during data fetching + - Added empty state check to prevent UI flickering + - Enhanced state transitions between loading and loaded states + ## feat: Instruction Selector - 12/2/2024 - @lumpinif ### New Feature Implementation diff --git a/extensions/chrome/src/components/instruction-selector/index.tsx b/extensions/chrome/src/components/instruction-selector/index.tsx index c3fa339..cb23401 100644 --- a/extensions/chrome/src/components/instruction-selector/index.tsx +++ b/extensions/chrome/src/components/instruction-selector/index.tsx @@ -77,92 +77,92 @@ export function InstructionSelect() { const selectedInstruction = instructions.find((inst) => inst.value === value) const displayedInstruction = hoveredInstruction || selectedInstruction - if (isLoading) { - return - } - return (
- { + handleInstructionClick( + instructions.find((inst) => inst.value === value)! + ) + }} + > + + + + +
+
+ Which model instruction should Claude use? +
+ - - - - - {starsCount && ( - - {formatStarCount(starsCount)} - - )} - - - - -
-
-
-
- - {instructions.map((instruction) => ( -
setHoveredInstruction(instruction)} - onMouseLeave={() => setHoveredInstruction(null)} - > - -
- ))} - -
-
+ + + + {starsCount && ( + + {formatStarCount(starsCount)} + + )} + + + +
-
- +
+
+
+ + {instructions.map((instruction) => ( +
setHoveredInstruction(instruction)} + onMouseLeave={() => setHoveredInstruction(null)} + > + +
+ ))} + +
+
+
+
+ +
-
- - + + + )}
) } diff --git a/extensions/chrome/src/hooks/use-model-instructions.ts b/extensions/chrome/src/hooks/use-model-instructions.ts index 5df8a11..d2971e6 100644 --- a/extensions/chrome/src/hooks/use-model-instructions.ts +++ b/extensions/chrome/src/hooks/use-model-instructions.ts @@ -23,7 +23,6 @@ export const useModelInstructions = () => { const fetchModelInstructions = async (signal: AbortSignal) => { try { - setIsLoading(true) setError(null) const response = await fetch(GITHUB_API_URL, { signal }) @@ -95,8 +94,6 @@ export const useModelInstructions = () => { err instanceof Error ? err.message : "Failed to load model instructions" ) setInstructions([]) - } finally { - setIsLoading(false) } } @@ -140,6 +137,11 @@ export const useModelInstructions = () => { fetchStarsCount(signal), fetchModelInstructions(signal), ]) + } catch (err) { + // Handle any errors from the parallel fetches + if (err instanceof Error && err.name !== "AbortError") { + console.error("Error during parallel fetches:", err) + } } finally { setIsLoading(false) } From 3c6f99dbc8a88034b80372fe6c997512783b8e9b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 3 Dec 2024 09:12:13 +0000 Subject: [PATCH 2/2] chore: bump version to 3.2.1 [skip ci] --- extensions/chrome/package.json | 2 +- extensions/chrome/public/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/chrome/package.json b/extensions/chrome/package.json index 7d45f42..7f0ab63 100644 --- a/extensions/chrome/package.json +++ b/extensions/chrome/package.json @@ -1,6 +1,6 @@ { "name": "thinking-claude", - "version": "3.2.0", + "version": "3.2.1", "description": "Chrome extension for letting Claude think like a real human", "type": "module", "scripts": { diff --git a/extensions/chrome/public/manifest.json b/extensions/chrome/public/manifest.json index 24f7605..2e357cf 100644 --- a/extensions/chrome/public/manifest.json +++ b/extensions/chrome/public/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Thinking Claude", - "version": "3.2.0", + "version": "3.2.1", "description": "Chrome extension for letting Claude think like a real human", "background": { "service_worker": "background.js"