Skip to content

Commit cdbbbc7

Browse files
committed
Changed radio buttons to regular buttons. Fixed color issue
1 parent 42cc576 commit cdbbbc7

File tree

5 files changed

+148
-107
lines changed

5 files changed

+148
-107
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
- Backend truncates context to 2000 characters (last 2000 for previous context, first 2000 for next context)
77
- Provides richer context for AI text generation while managing token usage
88
- Added comprehensive tests: truncation with long paragraphs and multi-paragraph collection with short paragraphs
9+
- Redesigned AI generation UI for improved usability
10+
- Removed separate "Generate" button
11+
- Replaced radio buttons with large, descriptive icon buttons (Ideas 💡, Rewrite ✏️, Improve ✨, Proofread 🔍)
12+
- Each button includes hover tooltips explaining its purpose
13+
- Direct click triggers generation immediately
14+
- Visual feedback with pulsing indicator during generation
15+
- Streamlined workflow reduces clicks and improves discoverability
16+
- Fixed dark mode styling issues
17+
- Replaced hard-coded light backgrounds with CSS variables that adapt to dark mode
18+
- Fixed loading indicators, dropdowns, form inputs, sections, and containers
19+
- Dark mode now has consistent dark theming throughout the application
20+
- Improved text contrast and border visibility in dark mode
21+
- Fixed light mode background to use proper light gradient (was incorrectly using dark colors)
22+
- Background now properly changes when toggling between light and dark modes
923

1024
## 0.1.1
1125
- Addressed "information exposure through exception" issue

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ When making a change, write a unit test that fails without the change, verify th
1212
make the change and then verity that the unit test now passes. Notify the user if it is not reasonable
1313
to write the unit test.
1414
User interfaces should be visually appealing and maintain consistency with each other.
15-
Th
15+
1616
## Development Commands
1717

1818
### Installation

src/writing_assistant/app/static/script.js

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class WritingAssistant {
117117
setupEventListeners() {
118118
const titleInput = document.getElementById('document-title');
119119
const documentTextarea = document.getElementById('document-text');
120-
const generateBtn = document.getElementById('generate-btn');
121120
const useSuggestionBtn = document.getElementById('use-suggestion-btn');
122121

123122
// Document title
@@ -128,8 +127,15 @@ class WritingAssistant {
128127
documentTextarea.addEventListener('click', () => this.handleCursorChange());
129128
documentTextarea.addEventListener('keyup', () => this.handleCursorChange());
130129

131-
// AI suggestion controls
132-
generateBtn.addEventListener('click', () => this.generateSuggestionForCurrentSection());
130+
// Mode button controls (Ideas, Rewrite, Improve, Proofread)
131+
document.querySelectorAll('.mode-btn').forEach(btn => {
132+
btn.addEventListener('click', () => {
133+
const mode = btn.getAttribute('data-mode');
134+
this.generateSuggestionForCurrentSection(mode);
135+
});
136+
});
137+
138+
// Use suggestion button
133139
useSuggestionBtn.addEventListener('click', () => this.useSuggestion());
134140

135141
// Initialize undo/redo system
@@ -624,49 +630,49 @@ class WritingAssistant {
624630

625631
updateSuggestionPanel() {
626632
const suggestionText = document.getElementById('suggestion-text');
627-
const generateBtn = document.getElementById('generate-btn');
633+
const modeButtons = document.querySelectorAll('.mode-btn');
628634
const useSuggestionBtn = document.getElementById('use-suggestion-btn');
629635
const infoElement = document.getElementById('current-section-info');
630636

631637
if (this.currentSectionIndex === -1 || this.sections.length === 0) {
632638
suggestionText.textContent = 'Position your cursor in a section above to see AI suggestions for that section.';
633-
generateBtn.disabled = true;
634-
this.setGenerateButtonText('⚡ Generate');
639+
modeButtons.forEach(btn => btn.disabled = true);
635640
useSuggestionBtn.disabled = true;
636641
infoElement.textContent = 'No section selected';
637642
} else {
638643
const currentSection = this.sections[this.currentSectionIndex];
639644
const sectionNum = this.currentSectionIndex + 1;
640645
infoElement.textContent = `Section ${sectionNum} of ${this.sections.length} selected`;
641646

642-
// Generate button is always enabled when a section is selected
643-
generateBtn.disabled = false;
647+
// Mode buttons are always enabled when a section is selected
648+
modeButtons.forEach(btn => btn.disabled = false);
644649

645650
if (currentSection.generated_text) {
646651
suggestionText.textContent = currentSection.generated_text;
647-
this.setGenerateButtonText('🔄 Regenerate');
648652
useSuggestionBtn.disabled = false;
649653
} else {
650-
suggestionText.textContent = 'Click "Generate" to get AI suggestions for this section.';
651-
this.setGenerateButtonText('⚡ Generate');
654+
suggestionText.textContent = 'Click a mode button below to get AI suggestions for this section.';
652655
useSuggestionBtn.disabled = true;
653656
}
654657
}
655658
}
656659

657-
async generateSuggestionForCurrentSection() {
660+
async generateSuggestionForCurrentSection(mode = 'ideas') {
658661
if (this.currentSectionIndex === -1 || this.sections.length === 0) {
659662
this.showMessage('Please position your cursor in a section first', 'error');
660663
return;
661664
}
662665

663666
const currentSection = this.sections[this.currentSectionIndex];
664-
const generateBtn = document.getElementById('generate-btn');
665667
const suggestionText = document.getElementById('suggestion-text');
668+
const modeButtons = document.querySelectorAll('.mode-btn');
669+
const activeButton = document.querySelector(`.mode-btn[data-mode="${mode}"]`);
666670

667671
// Show loading state
668-
generateBtn.disabled = true;
669-
this.setGenerateButtonText('⏳ Generating...');
672+
modeButtons.forEach(btn => btn.disabled = true);
673+
if (activeButton) {
674+
activeButton.classList.add('generating');
675+
}
670676
suggestionText.textContent = 'Generating AI suggestion...';
671677

672678
try {
@@ -688,15 +694,12 @@ class WritingAssistant {
688694

689695
const title = document.getElementById('document-title').value || '';
690696

691-
// Get selected generation mode
692-
const selectedMode = document.querySelector('input[name="generation-mode"]:checked').value;
693-
694697
const formData = new FormData();
695698
formData.append('user_text', currentSection.text);
696699
formData.append('title', title);
697700
formData.append('prev_paragraph', prevContext);
698701
formData.append('next_paragraph', nextContext);
699-
formData.append('generation_mode', selectedMode);
702+
formData.append('generation_mode', mode);
700703

701704
// Send metadata with each request - read current values from form fields
702705
formData.append('writing_style', document.getElementById('writing-style')?.value || this.documentMetadata.writing_style || 'formal');
@@ -741,12 +744,10 @@ class WritingAssistant {
741744
this.showMessage('Error generating suggestion. Please try again.', 'error');
742745
suggestionText.textContent = 'Error generating suggestion. Please try again.';
743746
} finally {
744-
generateBtn.disabled = false;
745-
// Update button text based on whether we have generated text
746-
if (currentSection.generated_text) {
747-
this.setGenerateButtonText('🔄 Regenerate');
748-
} else {
749-
this.setGenerateButtonText('⚡ Generate');
747+
// Re-enable all mode buttons
748+
modeButtons.forEach(btn => btn.disabled = false);
749+
if (activeButton) {
750+
activeButton.classList.remove('generating');
750751
}
751752
}
752753
}
@@ -1624,9 +1625,10 @@ undo() {
16241625

16251626
if (pressedKey === this.hotkeys.generate) {
16261627
e.preventDefault();
1627-
const generateBtn = document.getElementById('generate-btn');
1628-
if (!generateBtn.disabled) {
1629-
this.generateSuggestionForCurrentSection();
1628+
// Trigger ideas mode by default with hotkey
1629+
const ideasBtn = document.querySelector('.mode-btn[data-mode="ideas"]');
1630+
if (ideasBtn && !ideasBtn.disabled) {
1631+
this.generateSuggestionForCurrentSection('ideas');
16301632
}
16311633
} else if (pressedKey === this.hotkeys.useText) {
16321634
e.preventDefault();
@@ -1677,20 +1679,9 @@ undo() {
16771679
}
16781680

16791681
updateButtonLabels() {
1680-
this.setGenerateButtonText();
16811682
this.setUseSuggestionButtonText();
16821683
}
16831684

1684-
setGenerateButtonText(baseText = null) {
1685-
const generateBtn = document.getElementById('generate-btn');
1686-
if (!generateBtn) return;
1687-
1688-
if (baseText === null) {
1689-
baseText = generateBtn.textContent.split('(')[0].trim();
1690-
}
1691-
generateBtn.textContent = `${baseText} (${this.hotkeys.generate})`;
1692-
}
1693-
16941685
setUseSuggestionButtonText(baseText = null) {
16951686
const useSuggestionBtn = document.getElementById('use-suggestion-btn');
16961687
if (!useSuggestionBtn) return;

0 commit comments

Comments
 (0)