-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Theia Content Management Workflow #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add JSON-based course upload functionality allowing users to upload previously exported course structures from Themis Structure Review to continue work or export in different formats. ## New Features - JSON export format for course structures - Course upload UI with drag-drop and file picker - Comprehensive validation with user-friendly error messages - Automatic workflow resume at Structure Review step - Round-trip fidelity (export → upload → data intact) ## New Files - src/routes/theia/+page.svelte - Theia landing page - src/lib/components/theia/CourseStructureUpload.svelte - Upload component - src/lib/utils/theia/courseValidator.ts - Course validation utilities - src/data/test/courses/ - Test fixtures ## Modified Files - src/lib/types/theia.ts - Add 'json' to ExportFormat - src/lib/types/error.ts - Add CourseUploadError - src/lib/services/theiaService.ts - Add JSON export support - src/lib/components/themis/CourseStructureReview.svelte - Detect uploaded courses ## Implementation Details - Uses existing CourseData TypeScript interface for validation - Deserializes uploaded JSON (converts date strings to Date objects) - Displays validation warnings without blocking upload - Shows course statistics (arcs, modules, weeks) after upload - Integrates with Themis stores for seamless workflow continuation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add Theia to the workflow cards on the home page with proper palette integration and responsive design. ## Changes - Add Theia workflow card with icon, description, and features - Update grid layout to accommodate 4 cards (responsive: 4 → 2 → 1) - Apply Theia palette colors (bg-subtle #F7ECF3, fg-dark #B0127A) - Add Theia route prefix to palette loader - Style card with hover effects matching other workflows ## Features Highlighted - Upload course JSON - Resume workflows - Export formats 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Increase rhea-hub max-width from 900px to 1400px to give workflow cards more breathing room in desktop view. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add Theia palette definition to palettes.css with magenta/cyan colours - Update documentation comment to include Theia palette - Fix /theia page icon path to use absolute path for correct resolution - Palette now correctly applies via route detection in layout
New order: Theia → Themis → Tethys → Metis Theia moved to first position as content management workflow
- Added JSON format button to ExportConfigModal with 📦 icon - Added 'json' to valid formats list in validateAndMergeConfig - JSON export available for courses (outputs raw CourseData structure) - Enables round-trip workflow: export JSON → upload → continue
Added styled information box explaining that only JSON exports can be re-imported to continue workflows. Helps users understand format choices.
SummaryThis PR successfully implements Theia's course upload workflow, enabling users to re-import previously exported course structures. The implementation is well-architected with comprehensive validation, excellent error handling, and user-friendly UI components. Code quality is high with strong TypeScript typing and good separation of concerns. No major security issues identified, though some minor improvements around performance, validation edge cases, and testing would strengthen the implementation. 🎯 Code Quality & Best PracticesExcellent Patterns✅ Strong TypeScript Usage
✅ Separation of Concerns
✅ Error Handling Architecture
✅ Accessibility
Minor Improvements🔸 Component Size
This would improve testability and maintainability. 🔸 Magic Numbers const MAX_UPLOAD_SIZE_MB = 10;
const MAX_UPLOAD_SIZE_BYTES = MAX_UPLOAD_SIZE_MB * 1024 * 1024;🔸 Duplicate Validation Logic 🔸 Documentation
🐛 Potential IssuesHigh Priority🔴 Missing NULL Checks in Deserialization // Current:
arcs: course.arcs.map((arc: any) => ({ // Could throw if course.arcs is undefined
// Suggested:
arcs: (course.arcs || []).map((arc: any) => ({While the validation function should catch this, defensive programming is valuable here. 🟡 Race Condition in Drag-and-Drop onDestroy(() => {
dragCounter = 0;
isDragOver = false;
});Medium Priority🟡 Validation Warning vs Error Boundary return { valid: false, errors, warnings }; // Fatal - can't validate arcs structure🟡 Module Data Validation 🟡 Date Parsing Without Validation const parseDate = (dateString: string | undefined): Date => {
if (!dateString) return new Date();
const date = new Date(dateString);
return isNaN(date.getTime()) ? new Date() : date;
};
createdAt: parseDate(course.createdAt),
updatedAt: parseDate(course.updatedAt),Low Priority🟢 Console.error Side Effect ⚡ Performance ConsiderationsGood Performance Characteristics✅ Lazy Loading
✅ Efficient File Handling
Optimization Opportunities🔸 Large Course Handling Consider:
Implementation idea: export function validateCourseStructure(
course: any,
options: { maxErrors?: number } = {}
): CourseValidationResult {
const maxErrors = options.maxErrors ?? Infinity;
// ... add check in loops:
if (errors.length >= maxErrors) {
errors.push('Too many validation errors - stopping validation');
return { valid: false, errors, warnings };
}
}🔸 Validation Warnings Display
🔸 Module Count Calculation $: totalModules = uploadedCourse?.arcs.reduce((sum, arc) => sum + arc.modules.length, 0) ?? 0;Then use: File Upload Performance✅ Good: 10MB file size limit is reasonable // Stream-based parsing for large files (optional future enhancement)
const response = new Response(await file.arrayBuffer());
const reader = response.body.getReader();
// Use incremental JSON parser like 'partial-json' library🔒 Security ConcernsGood Security Practices✅ Input Validation
✅ No Dangerous Operations
Recommendations🟡 File Extension Check Insufficient if (!file.name.endsWith('.json') || file.type !== 'application/json') {
error = 'Please upload a valid JSON file';
// ...
}🟡 JSON Parsing Error Exposure Current approach is fine, but for extra safety: error = err instanceof Error ? getUserFriendlyError(err) : 'An unexpected error occurred';🟢 XSS Protection 🟢 CSRF Not Applicable 🟢 localStorage Security ✅ Test CoverageExisting Test Data✅ Good Test Fixtures
Missing Test CoverageThe implementation plan ( 🔴 Unit Tests Needed
Example test structure: // courseValidator.test.ts
import { describe, it, expect } from 'vitest';
import { validateCourseStructure } from './courseValidator';
describe('validateCourseStructure', () => {
it('validates a complete valid course', () => {
const validCourse = { /* ... */ };
const result = validateCourseStructure(validCourse);
expect(result.valid).toBe(true);
expect(result.errors).toHaveLength(0);
});
it('returns error for missing course.id', () => {
const invalidCourse = { title: 'Test' };
const result = validateCourseStructure(invalidCourse);
expect(result.valid).toBe(false);
expect(result.errors).toContain('Missing or invalid course.id');
});
// ... more tests
});🟡 Component Tests Needed
🟡 Integration Tests
🟢 E2E Test Scenarios (for future consideration) Based on implementation plan:
Test File OrganizationSuggested structure: Coverage GoalsAim for:
Additional Observations🌟 Strengths
📝 Minor Nits
🚀 Future Enhancements (out of scope for this PR)
RecommendationAPPROVE ✅ This is a solid implementation that successfully delivers the Theia upload workflow. The code is well-structured, maintainable, and follows project conventions. While there are opportunities for improvement (primarily around testing and minor edge cases), none are blocking issues. The PR delivers significant value by enabling course workflow resumption. Before Merging (Optional)Consider addressing:
Great work! 🎉 |
Updates user and developer documentation to reflect the completed Theia course structure upload implementation (PR #21). Changes emphasize Theia's new role as content manager, not just exporter, and highlight round-trip workflow capabilities. Documentation updates: - README.md: Reorder workflows (Theia first), expand features section, add Theia workflow steps with upload/export process - About-Rhea.md: Add "Recently Completed" section, update current state to reflect Theia capabilities - Technical-Overview.md: Rename Theia section to "Content Manager & Exporter", detail upload implementation components - docs/dev/status/README.md: Update Theia status with JSON upload features, add course upload to Recent Wins (#1 position) - docs/dev/status/Theia-MVP.md: Add completed milestone 4.1.2 for course upload, update milestone 2.1 status to IN PROGRESS - docs/dev/status/Rhea-MVP.md: Document Theia palette completion with magenta/cyan colour scheme All documentation now accurately represents: - Round-trip capability (export JSON → upload → continue) - Five workflow modules (Theia now functional, not planned) - JSON as the resumable format - Theia's dual role: content management + export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
SummaryThis PR successfully implements the Theia content management workflow, adding JSON-based course upload, validation, and round-trip export capabilities. The implementation is clean, well-structured, and follows established project patterns. A few minor improvements around error handling, accessibility, and validation edge cases would strengthen the implementation. 🎯 Code Quality & Best PracticesStrengths
Areas for Improvement
🐛 Potential IssuesMedium PriorityFile Upload Race Condition (src/lib/components/theia/CourseStructureUpload.svelte:78-86)
JSON.parse Error Handling (src/lib/components/theia/CourseStructureUpload.svelte:45-46)
Date Deserialization (src/lib/utils/theia/courseValidator.ts:179-180)
Low Priority
⚡ Performance ConsiderationsStrengths
Suggestions
🔒 Security ConcernsStrengths
Suggestions
✅ Test CoverageExcellent Test Fixtures Provided
Recommended Additions
Add tests in:
Minor Suggestions
Summary Recommendation✅ Approve with minor follow-ups This is a well-executed feature that successfully delivers the stated round-trip workflow capability. The suggested improvements are non-blocking and can be addressed in follow-up PRs if needed. Priority follow-ups:
Great work on maintaining architectural consistency and providing comprehensive documentation! 🎉 |
Implement Theia Content Management Workflow
Overview
This PR introduces Theia, a new workflow for uploading and managing previously generated course structures. Users can now upload JSON course files, view/edit them, and export to multiple formats (Markdown, HTML, JSON). This enables round-trip workflows: generate in Themis → export → re-upload → continue working.
Tip
No additional setup steps required after pulling. Theia is accessible from the home page.
Changes
Core Theia Implementation
New workflow for course content management with upload, validation, and export capabilities.
/theia- Main Theia page with course upload interfaceCourseStructureUpload.svelte- File upload, drag-and-drop, validation feedbackcourseValidator.ts- Comprehensive Zod-based course structure validationExport Enhancements
Extended Theia export service to support JSON format for round-trip workflows.
ExportConfigModal.sveltetheiaService.tsto handle JSON exports (raw CourseData structure)Home Page Integration
Theia workflow card added to home page and promoted to primary workflow position.
Theming & Branding
Theia palette implementation with magenta/cyan colour scheme.
palettes.css(magenta primary, cyan accent)paletteLoader.tsandpaletteTypes.tsError Handling
Enhanced error types for upload validation failures.
UploadValidationErrortoerror.tsfor file upload scenariosDocumentation
Comprehensive updates to all user and developer documentation:
Roadmaps & Status
User Documentation
README.md: Reordered workflows (Theia first), expanded features, added workflow stepsAbout-Rhea.md: Added "Recently Completed" section with Theia highlightsGetting-Started.md: No changes (still accurate)Developer Documentation
Technical-Overview.md: Renamed Theia section to "Content Manager & Exporter", detailed upload componentsdocs/dev/status/README.md: Updated Theia status with JSON upload featurespalettes.jsonc: Already current (verified)All documentation now emphasizes:
Summary
Think of this like adding a garage to your house after you've been parking your car in the driveway for months. You've been generating lovely courses with Themis and immediately exporting them to files that disappear into the void. Now Theia gives you a proper space to bring those courses back, tinker with them, check their oil, maybe export them in a different colour (format), and generally treat them like the valuable assets they are rather than one-and-done paperwork.