diff --git a/backend/app/api/routes/support.py b/backend/app/api/routes/support.py index 5b04b26c0..8cdc78c03 100644 --- a/backend/app/api/routes/support.py +++ b/backend/app/api/routes/support.py @@ -212,7 +212,7 @@ def _read_log_entries( if parsed: # Found a new log entry start if current_entry: - # Apply filters and add previous entry + # Apply filters and add previous entry (without multi_line_buffer - it belongs to new entry) should_include = True # Level filter @@ -229,21 +229,23 @@ def _read_log_entries( should_include = False if should_include: - # Append any multi-line content - if multi_line_buffer: - current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer)) entries.append(current_entry) if len(entries) >= limit: break + # Set new entry and attach any accumulated multi-line content to it + # (in reverse order, continuation lines come before their parent entry) current_entry = parsed + if multi_line_buffer: + current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer)) multi_line_buffer = [] - elif current_entry and line.strip(): - # Continuation of multi-line log entry + elif line.strip(): + # Continuation of multi-line log entry (will be attached to next parsed entry) multi_line_buffer.append(line.rstrip()) # Don't forget the last (oldest) entry + # Note: any remaining multi_line_buffer would be orphaned lines before the first entry if current_entry and len(entries) < limit: should_include = True if level_filter and current_entry.level.upper() != level_filter.upper(): @@ -256,8 +258,6 @@ def _read_log_entries( ): should_include = False if should_include: - if multi_line_buffer: - current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer)) entries.append(current_entry) except Exception as e: diff --git a/frontend/src/__tests__/components/PrintModal.test.tsx b/frontend/src/__tests__/components/PrintModal.test.tsx index 21883a0b0..8db3431fb 100644 --- a/frontend/src/__tests__/components/PrintModal.test.tsx +++ b/frontend/src/__tests__/components/PrintModal.test.tsx @@ -454,7 +454,7 @@ describe('PrintModal', () => { expect(mockOnClose).toHaveBeenCalled(); }); - it('shows printer dropdown for single selection', async () => { + it('shows printer selector for single selection', async () => { const item = createMockQueueItem(); render( @@ -467,8 +467,9 @@ describe('PrintModal', () => { /> ); + // PrinterSelector shows printer names directly await waitFor(() => { - expect(screen.getByText('Printer')).toBeInTheDocument(); + expect(screen.getByText('P1S')).toBeInTheDocument(); }); }); }); @@ -489,7 +490,7 @@ describe('PrintModal', () => { }); }); - it('shows info message when multiple printers selected', async () => { + it('shows selected count when multiple printers selected', async () => { const user = userEvent.setup(); render( { await user.click(screen.getByText('Select all')); await waitFor(() => { - expect(screen.getByText(/Slot mapping below applies to all/)).toBeInTheDocument(); + expect(screen.getByText(/2 printers selected/)).toBeInTheDocument(); }); });