Fix: coding when no source was selected#215
Merged
jankapunkt merged 7 commits intomainfrom Dec 3, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a user experience issue where navigating to the coding view without locked sources resulted in a 404 error. The fix allows the page to load gracefully and display an informative message guiding users to lock sources.
Key changes:
- Modified backend controller to return
nullinstead of throwing an error when no source is available - Added null-safe access patterns throughout the frontend using optional chaining (
source?.id,source?.selections) - Implemented conditional rendering in the Vue component to show a helpful empty state when no source is present
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
web/app/Http/Controllers/CodingController.php |
Changed query from firstOrFail() to first() to return null instead of throwing exception, reordered operations to handle null source, and added conditional content loading |
web/resources/js/domain/codes/useCodes.js |
Added optional chaining for source?.id and source?.selections to handle null source gracefully |
web/resources/js/Pages/coding/selections/useSelections.js |
Added optional chaining for source?.id to prevent errors when source is undefined |
web/resources/js/Pages/CodingPage.vue |
Added conditional rendering with v-if="$props.source" for editor, created empty state UI with helpful message, added null-safe checks for source property access, and imported new UI components |
Comments suppressed due to low confidence (1)
web/resources/js/Pages/CodingPage.vue:77
- The menu section is displayed even when
props.sourceis null/undefined, allowing users to potentially interact with code creation and management features. This could cause errors sinceuseCodes()is called unconditionally (line 190) and passessourcetoCodes.create(), which will fail with a null reference error when accessingsource.id. Consider wrapping the menu content in av-if="props.source"condition or disabling interactive elements when no source is available.
<ActivityIndicator v-if="!codingInitialized">
Loading codes and selections...
</ActivityIndicator>
<div v-else class="inline md:flex items-center justify-between mb-4">
<CreateDialog
:schema="createNewCodeSchema"
:title="`Create a new ${codesView === 'codes' ? 'Code' : 'Codebook'}`"
:submit="createCodeHandler"
>
<template #trigger="createCodeTriggerProps">
<Button
variant="outline-secondary"
class="w-full md:w-auto"
@click="createCodeTriggerProps.onClick(openCreateCodeDialog)"
>
<PlusIcon class="w-4 h-4 me-1" />
<span v-if="codesView === 'codes' && range?.length">
Create In-Vivo
</span>
<span v-else>Create</span>
</Button>
</template>
</CreateDialog>
<CreateDialog
:title="`Edit ${editTarget?.name}`"
:schema="editSchema"
buttonTitle="Update code"
:submit="updateCode"
:show="!!editSchema"
/>
<DeleteDialog
:title="`Permanently delete ${deleteTarget?.name}`"
:target="deleteTarget"
:challenge="deleteChallenge"
:message="deleteMessage"
:submit="deleteCode"
/>
<ResponsiveTabList
:tabs="codesTabs"
:initial="codesView"
@change="(value) => (codesView = value)"
/>
</div>
<Cleanup v-if="codesView === 'cleanup'" />
<CodeTree
v-for="codebook in codebooks"
:key="codebook.id"
:codebook="codebook"
:codes="codes.filter((code) => code.codebook === codebook.id)"
v-if="codesView === 'codes'"
/>
<FilesList
v-if="codesView === 'sources'"
:documents="sourceDocuments"
:fixed="true"
:focus-on-hover="true"
:actions="[]"
@select="switchFile"
/>
<p
v-if="codesView === 'sources' && !sourceDocuments?.length"
class="p-3 text-foreground/60"
>
No other sources locked for coding. Go to
<Link :href="route('source.index', projectId)"
>the preparations page</Link
>
to edit and lock sources for coding.
</p>
<div class="mt-auto">
<Footer />
</div>
</BaseContainer>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a new project it is likely that users forgot to lock sources for coding but navigate to the coding view.
In this scenario the page returns a 404 error.
With this fix the page will load but display a message that a source is required to be locked for coding.