Skip to content

Commit e1bf2c4

Browse files
staredclaude
andcommitted
Fix loading states and improve WebR version detection
- Fix "Executing R Code" message to only show during actual code execution (not WebR initialization) - Add separate isExecuting state to distinguish code execution from WebR initialization - Fix WebR version display in Ready message by properly getting version from WebR instance - Add coding principle to CLAUDE.md about avoiding defensive code with multiple fallbacks - Increment version to 0.2.4 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 740f64c commit e1bf2c4

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- NEVER fail silently - always log errors and make failures visible to users when appropriate.
1010
- If a composable is used within only one Vue component, keep it in that component file - do NOT create a separate composable file.
11+
- AVOID defensive code with multiple fallbacks - choose ONE approach, implement it properly, and fail hard with clear errors if it doesn't work. Multiple fallbacks hide real problems and make debugging harder.
1112

1213
## WebR Documentation References
1314

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "webr-ggplot2-demo",
33
"private": true,
4-
"version": "0.2.3",
4+
"version": "0.2.4",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const {
2626
isReady,
2727
isLoading,
2828
isInitializing,
29+
isExecuting,
2930
loadingStatus,
3031
installedLibraries,
3132
messages,
@@ -181,6 +182,7 @@ onMounted(async () => {
181182
<OutputDisplay
182183
:messages="messages"
183184
:is-loading="isLoading"
185+
:is-executing="isExecuting"
184186
/>
185187
<ConsoleOutput
186188
ref="consoleRef"

src/components/OutputDisplay.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { WebRMessage } from '@/types'
55
interface Props {
66
messages: WebRMessage[]
77
isLoading: boolean
8+
isExecuting: boolean
89
showConsoleBelow?: boolean
910
}
1011
@@ -71,9 +72,9 @@ watch(
7172
>
7273
</div>
7374

74-
<!-- Loading overlay -->
75+
<!-- Loading overlay - only show during actual code execution -->
7576
<div
76-
v-if="isLoading"
77+
v-if="isExecuting"
7778
class="loading-overlay"
7879
>
7980
<div class="loading-content">

src/composables/useWebR.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface UseWebRReturn {
1515
isReady: Readonly<Ref<boolean>>
1616
isLoading: Readonly<Ref<boolean>>
1717
isInitializing: Readonly<Ref<boolean>>
18+
isExecuting: Readonly<Ref<boolean>>
1819
loadingStatus: Readonly<Ref<string>>
1920
webrVersion: ComputedRef<string>
2021
rVersion: ComputedRef<string>
@@ -243,6 +244,7 @@ export function useWebR(): UseWebRReturn {
243244
isReady: readonly(isReady),
244245
isLoading: readonly(isLoading),
245246
isInitializing: readonly(isInitializing),
247+
isExecuting: readonly(isExecuting),
246248
loadingStatus: readonly(status),
247249
webrVersion: computed(() => versions.value.webr),
248250
rVersion: computed(() => versions.value.r),

src/webr/core/webr-instance.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ export class WebRInstance {
8484
// Simplify version string: "R version 4.3.1 ..." -> "R 4.3.1"
8585
const rVersion = fullVersion.replace(/^R version /, 'R ')
8686

87-
// WebR version detection would go here if available in future
88-
return { r: rVersion, webr: '' }
87+
// Get WebR version from the instance
88+
const webrVersion = webR.version
89+
if (!webrVersion) {
90+
throw new WebRError('WebR instance does not provide version information')
91+
}
92+
return { r: rVersion, webr: webrVersion }
8993
} catch {
9094
return { r: 'Unknown', webr: '' }
9195
}

0 commit comments

Comments
 (0)