diff --git a/src-ui/package.json b/src-ui/package.json
index bd61a91818..0b8515b5a9 100644
--- a/src-ui/package.json
+++ b/src-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "paperless-ngx-ui",
- "version": "3.4.2",
+ "version": "3.5.0",
"scripts": {
"preinstall": "npx only-allow pnpm",
"ng": "ng",
diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.html b/src-ui/src/app/components/admin/tasks/tasks.component.html
index 7424668d21..b5322b89c4 100644
--- a/src-ui/src/app/components/admin/tasks/tasks.component.html
+++ b/src-ui/src/app/components/admin/tasks/tasks.component.html
@@ -175,7 +175,13 @@
|
- {{ taskDisplayName(task) }}
+ @let documentCount = taskDocumentCount(task);
+
+ {{ taskDisplayName(task) }}
+ @if (documentCount !== null && documentCount > 1) {
+ ({documentCount, plural, =1 {1 document} other {{{ documentCount }} documents}})
+ }
+
@if (taskShowsSeparateTypeLabel(task)) {
{{ task.task_type_display }}
diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts
index 887e690982..694b729b2e 100644
--- a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts
+++ b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts
@@ -895,6 +895,117 @@ describe('TasksComponent', () => {
expect(sanityTaskRow.nativeElement.textContent).toContain('System')
})
+ it.each([
+ ['modify_tags', 12, 'Bulk operation: Update tags', '(12 documents)'],
+ ['run_workflow', 1, 'Run workflow', null],
+ ['delete', 3, 'Bulk operation: Move to trash', '(3 documents)'],
+ ['reprocess', 2, 'Bulk operation: Document reprocessing', '(2 documents)'],
+ ])(
+ 'shows the operation, document count and outcome for %s',
+ (operation, count, label, summary) => {
+ const task: PaperlessTask = {
+ ...tasks[4],
+ task_type:
+ operation === 'delete'
+ ? PaperlessTaskType.BulkDelete
+ : PaperlessTaskType.BulkUpdate,
+ task_type_display:
+ operation === 'delete' ? 'Bulk Delete' : 'Bulk Update',
+ trigger_source: PaperlessTaskTriggerSource.WebUI,
+ trigger_source_display: 'Web UI',
+ input_data: { operation, document_count: count },
+ result_data: { operation, document_count: count },
+ }
+ component.setSection(TaskSection.Completed)
+ flushTaskLists(25, 1, [task])
+ fixture.detectChanges()
+
+ const name = fixture.nativeElement.querySelector('tbody .name-col')
+ expect(name.textContent).toContain(label)
+ const countLabel = name.querySelector('small.text-muted')
+ if (summary) {
+ expect(countLabel.textContent).toContain(summary)
+ } else {
+ expect(countLabel).toBeNull()
+ expect(name.textContent).not.toContain('Bulk operation:')
+ }
+ expect(name.textContent).not.toContain('·')
+ expect(name.textContent).toContain('Web UI')
+ expect(name.textContent).not.toContain(task.task_type_display)
+ expect(
+ name.closest('tr').querySelector('.results-col').textContent
+ ).toContain(
+ [
+ 'reprocess',
+ 'rotate',
+ 'merge',
+ 'split',
+ 'delete_pages',
+ 'edit_pdf',
+ 'remove_password',
+ ].includes(operation)
+ ? 'Submitted for processing'
+ : 'Completed'
+ )
+ }
+ )
+
+ it('shows operation context while work is pending without reporting completion', () => {
+ const task = {
+ ...tasks[2],
+ task_type: PaperlessTaskType.BulkUpdate,
+ task_type_display: 'Bulk Update',
+ input_data: { operation: 'reprocess', document_count: 1 },
+ }
+ component.setSection(TaskSection.InProgress)
+ flushTaskLists(25, 1, [task])
+ fixture.detectChanges()
+
+ const name = fixture.nativeElement.querySelector('tbody .name-col')
+ expect(name.textContent).toContain('Document reprocessing')
+ expect(name.textContent).not.toContain('Bulk operation:')
+ expect(name.querySelector('small')).toBeNull()
+ expect(component.taskResultMessage(task)).toBeNull()
+ })
+
+ it.each([{}, { operation: 'future_operation' }])(
+ 'preserves the fallback for legacy or unknown operation data: %j',
+ (input_data) => {
+ const task = {
+ ...tasks[4],
+ task_type: PaperlessTaskType.BulkUpdate,
+ task_type_display: 'Bulk Update',
+ input_data,
+ result_data: {},
+ }
+ expect(component.taskDisplayName(task)).toBe('Bulk Update')
+ expect(component.taskDocumentCount(task)).toBeNull()
+ expect(component.taskResultMessage(task)).toBeNull()
+ }
+ )
+
+ it.each([-1, 1.5, '2', null, undefined])(
+ 'does not display an invalid document count: %s',
+ (document_count) => {
+ expect(
+ component.taskDocumentCount({
+ ...tasks[4],
+ input_data: { operation: 'modify_tags', document_count },
+ })
+ ).toBeNull()
+ }
+ )
+
+ it('retains error details for failed operation tasks', () => {
+ expect(
+ component.taskResultMessage({
+ ...tasks[0],
+ input_data: { operation: 'modify_tags', document_count: 12 },
+ result_data: { error_message: 'Insufficient permissions' },
+ })
+ ).toBe('Insufficient permissions')
+ })
+
it('should filter tasks by result', () => {
component.setSection(TaskSection.NeedsAttention)
component.filterTargetID = 1
diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.ts b/src-ui/src/app/components/admin/tasks/tasks.component.ts
index ad8793ef85..87ec037785 100644
--- a/src-ui/src/app/components/admin/tasks/tasks.component.ts
+++ b/src-ui/src/app/components/admin/tasks/tasks.component.ts
@@ -33,6 +33,10 @@ import { IfPermissionsDirective } from 'src/app/directives/if-permissions.direct
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
import { TasksService } from 'src/app/services/tasks.service'
import { ToastService } from 'src/app/services/toast.service'
+import {
+ documentOperationHasFollowUpTasks,
+ getDocumentOperationLabel,
+} from 'src/app/utils/document-operation'
import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
import { PageHeaderComponent } from '../../common/page-header/page-header.component'
import { LoadingComponentWithPermissions } from '../../loading-component/loading.component'
@@ -414,11 +418,30 @@ export class TasksComponent
}
taskDisplayName(task: PaperlessTask): string {
- return task.input_data?.filename?.toString() || task.task_type_display
+ const filename = task.input_data?.filename?.toString()
+ if (filename) return filename
+ const operation = this.taskOperationLabel(task)
+ const count = this.taskDocumentCount(task)
+ if (operation && count !== null && count > 1) {
+ return $localize`Bulk operation: ${operation}`
+ }
+ return operation || task.task_type_display
}
taskShowsSeparateTypeLabel(task: PaperlessTask): boolean {
- return this.taskDisplayName(task) !== task.task_type_display
+ return (
+ !this.taskOperationLabel(task) &&
+ this.taskDisplayName(task) !== task.task_type_display
+ )
+ }
+
+ private taskOperationLabel(task: PaperlessTask): string | null {
+ return getDocumentOperationLabel(task.input_data?.operation)
+ }
+
+ taskDocumentCount(task: PaperlessTask): number | null {
+ const count = task.input_data?.document_count
+ return Number.isInteger(count) && count >= 0 ? count : null
}
taskResultMessage(task: PaperlessTask): string | null {
@@ -446,6 +469,15 @@ export class TasksComponent
return errorMessage
}
+ if (
+ task.status === PaperlessTaskStatus.Success &&
+ this.taskOperationLabel(task)
+ ) {
+ return documentOperationHasFollowUpTasks(task.input_data?.operation)
+ ? $localize`Submitted for processing`
+ : $localize`Completed`
+ }
+
return null
}
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
index 85b16547c7..3d0e9b4e0a 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
+++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts
@@ -33,6 +33,7 @@ import { RemoteVersionService } from 'src/app/services/rest/remote-version.servi
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SearchService } from 'src/app/services/rest/search.service'
import { SettingsService } from 'src/app/services/settings.service'
+import { TaskNotificationService } from 'src/app/services/task-notification.service'
import { TasksService } from 'src/app/services/tasks.service'
import { ToastService } from 'src/app/services/toast.service'
import { UploadDocumentsService } from 'src/app/services/upload-documents.service'
@@ -198,14 +199,14 @@ describe('AppFrameComponent', () => {
fixture.detectChanges()
})
- it('refreshes and notifies on completion without client-side task tracking', () => {
+ it('refreshes and updates the task notification on completion', () => {
const list = TestBed.inject(DocumentListViewService)
const reload = jest.spyOn(list, 'reload').mockImplementation(() => {})
jest.spyOn(list, 'reduceSelectionToFilter').mockImplementation(() => {})
const tasksReload = jest
.spyOn(tasksService, 'reload')
.mockImplementation(() => {})
- const success = jest.spyOn(toastService, 'showSuccess')
+ const success = jest.spyOn(toastService, 'show')
const refresh = jest
.spyOn(openDocumentsService, 'refreshDocument')
.mockImplementation(() => {})
@@ -230,7 +231,12 @@ describe('AppFrameComponent', () => {
expect(refresh).toHaveBeenCalledWith(document.id)
expect(maybeRefreshSpy).toHaveBeenCalledTimes(1)
expect(tasksReload).toHaveBeenCalledTimes(1)
- expect(success).toHaveBeenCalledWith('Bulk operation completed.')
+ expect(success).toHaveBeenCalledWith(
+ expect.objectContaining({
+ id: 'task-bulk-task',
+ content: "Operation 'Set permissions' completed.",
+ })
+ )
fixture.destroy()
bulkEvents.next({
task_id: 'bulk-task',
@@ -245,14 +251,14 @@ describe('AppFrameComponent', () => {
const reload = jest.spyOn(list, 'reload').mockImplementation(() => {})
jest.spyOn(list, 'reduceSelectionToFilter').mockImplementation(() => {})
jest.spyOn(tasksService, 'reload').mockImplementation(() => {})
- const error = jest.spyOn(toastService, 'showError')
+ const error = jest.spyOn(toastService, 'show')
const success = jest.spyOn(toastService, 'showSuccess')
for (const status of [
PaperlessTaskStatus.Failure,
PaperlessTaskStatus.Revoked,
]) {
bulkEvents.next({
- task_id: 'bulk-task',
+ task_id: `${status}-task`,
operation: 'set_permissions',
status,
error:
@@ -262,11 +268,36 @@ describe('AppFrameComponent', () => {
})
}
expect(reload).toHaveBeenCalledTimes(2)
- expect(error).toHaveBeenCalledWith(expect.any(String), 'Could not update')
expect(error).toHaveBeenCalledWith(
- 'Bulk operation revoked.',
- 'Task expired before execution.'
+ expect.objectContaining({
+ content:
+ "Operation 'Set permissions' failed. Some changes may already have been applied.",
+ error: 'Could not update',
+ })
)
+ expect(error).toHaveBeenCalledWith(
+ expect.objectContaining({
+ content: "Operation 'Set permissions' revoked.",
+ error: 'Task expired before execution.',
+ })
+ )
+ expect(success).not.toHaveBeenCalled()
+ })
+
+ it('passes delete completion to the shared task notification handler', () => {
+ const success = jest.spyOn(toastService, 'showSuccess')
+ const notifications = TestBed.inject(TaskNotificationService)
+ const handleStatus = jest.spyOn(notifications, 'complete')
+ bulkEvents.next({
+ task_id: 'delete-1',
+ operation: 'delete',
+ status: PaperlessTaskStatus.Success,
+ })
+ expect(handleStatus).toHaveBeenCalledWith({
+ task_id: 'delete-1',
+ operation: 'delete',
+ status: PaperlessTaskStatus.Success,
+ })
expect(success).not.toHaveBeenCalled()
})
diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts
index beae9bb4f6..e47e13ab04 100644
--- a/src-ui/src/app/components/app-frame/app-frame.component.ts
+++ b/src-ui/src/app/components/app-frame/app-frame.component.ts
@@ -57,6 +57,7 @@ import {
} from 'src/app/services/rest/remote-version.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SettingsService } from 'src/app/services/settings.service'
+import { TaskNotificationService } from 'src/app/services/task-notification.service'
import { TasksService } from 'src/app/services/tasks.service'
import { ToastService } from 'src/app/services/toast.service'
import { UploadDocumentsService } from 'src/app/services/upload-documents.service'
@@ -115,6 +116,7 @@ export class AppFrameComponent
settingsService = inject(SettingsService)
tasksService = inject(TasksService)
private readonly toastService = inject(ToastService)
+ private readonly taskNotifications = inject(TaskNotificationService)
private modalService = inject(NgbModal)
permissionsService = inject(PermissionsService)
private djangoMessagesService = inject(DjangoMessagesService)
@@ -182,9 +184,11 @@ export class AppFrameComponent
),
takeUntilDestroyed(this.destroyRef)
)
- .subscribe(({ status, error }) => {
+ .subscribe((result) => {
this.documentList.reload(null, false)
- this.documentList.reduceSelectionToFilter()
+ if (!this.documentList.allSelected) {
+ this.documentList.reduceSelectionToFilter()
+ }
// maybe someday we can optimize to only refresh affected documents
this.openDocumentsService.getOpenDocuments().forEach((doc) => {
this.openDocumentsService.refreshDocument(doc.id)
@@ -198,16 +202,7 @@ export class AppFrameComponent
) {
this.tasksService.reload()
}
- if (status === PaperlessTaskStatus.Success) {
- this.toastService.showSuccess($localize`Bulk operation completed.`)
- } else if (status === PaperlessTaskStatus.Revoked) {
- this.toastService.showError($localize`Bulk operation revoked.`, error)
- } else {
- this.toastService.showError(
- $localize`Bulk operation failed. Some changes may already have been applied.`,
- error
- )
- }
+ this.taskNotifications.complete(result)
})
this.lastScrollY = window.scrollY
diff --git a/src-ui/src/app/components/chat/chat/chat.component.spec.ts b/src-ui/src/app/components/chat/chat/chat.component.spec.ts
index b38cef7efa..5c6ec39e52 100644
--- a/src-ui/src/app/components/chat/chat/chat.component.spec.ts
+++ b/src-ui/src/app/components/chat/chat/chat.component.spec.ts
@@ -188,6 +188,62 @@ describe('ChatComponent', () => {
expect(component.loading()).toBe(false)
})
+ it('should reveal a complete answer within one second', () => {
+ component.input.set('Hello')
+ component.sendMessage()
+
+ const answer = 'A'.repeat(660)
+ mockStream$.next(answer)
+ mockStream$.complete()
+
+ expect(component.messages()[1].content.length).toBeGreaterThan(0)
+ expect(component.messages()[1].content.length).toBeLessThan(answer.length)
+ expect(component.loading()).toBe(true)
+
+ jest.advanceTimersByTime(800)
+ expect(component.messages()[1].content).toBe(answer)
+ expect(component.loading()).toBe(false)
+ })
+
+ it('should give a long answer more time to reveal', () => {
+ component.input.set('Hello')
+ component.sendMessage()
+
+ const answer = 'A'.repeat(3000)
+ mockStream$.next(answer)
+ mockStream$.complete()
+
+ jest.advanceTimersByTime(800)
+ expect(component.messages()[1].content.length).toBeLessThan(answer.length)
+ expect(component.loading()).toBe(true)
+
+ jest.advanceTimersByTime(2500)
+ expect(component.messages()[1].content).toBe(answer)
+ expect(component.loading()).toBe(false)
+ })
+
+ it('should reveal fast incoming chunks without making them pop in', () => {
+ component.input.set('Hello')
+ component.sendMessage()
+
+ let answer = ''
+ for (let i = 0; i < 20; i++) {
+ answer += 'A'.repeat(100)
+ const visibleBefore = component.messages()[1].content.length
+ mockStream$.next(answer)
+ jest.advanceTimersByTime(10)
+ expect(
+ component.messages()[1].content.length - visibleBefore
+ ).toBeLessThan(100)
+ }
+ expect(component.messages()[1].content.length).toBeLessThan(answer.length)
+
+ mockStream$.complete()
+ jest.advanceTimersByTime(5200)
+ expect(component.messages()[1].content).toBe(answer)
+ expect(component.loading()).toBe(false)
+ })
+
it('should show a slow response message while waiting', () => {
component.input.set('Hello')
component.sendMessage()
diff --git a/src-ui/src/app/components/chat/chat/chat.component.ts b/src-ui/src/app/components/chat/chat/chat.component.ts
index cdd3f8473d..cfa0855696 100644
--- a/src-ui/src/app/components/chat/chat/chat.component.ts
+++ b/src-ui/src/app/components/chat/chat/chat.component.ts
@@ -21,6 +21,9 @@ import {
import { pngxPopperOptions } from 'src/app/utils/popper-options'
const SLOW_RESPONSE_DELAY_MS = 8000
+const TYPEWRITER_MIN_DURATION_MS = 750
+const TYPEWRITER_MAX_DURATION_MS = 3000
+const TYPEWRITER_INTERVAL_MS = 16
@Component({
selector: 'pngx-chat',
@@ -73,6 +76,7 @@ export class ChatComponent implements OnInit {
private typewriterBuffer: string[] = []
private typewriterActive = false
private typewriterTimeout: ReturnType
+ private typewriterDeadline = 0
private streamSubscription: Subscription
private streamingMessage: ChatMessage
private streamFinished = false
@@ -134,7 +138,7 @@ export class ChatComponent implements OnInit {
if (nextResponse.content.length < lastVisibleContent.length) {
this.resetTypewriter(assistantMessage, nextResponse.content)
lastVisibleContent = nextResponse.content
- } else {
+ } else if (nextResponse.content.length > lastVisibleContent.length) {
const visibleDelta = nextResponse.content.substring(
lastVisibleContent.length
)
@@ -214,6 +218,12 @@ export class ChatComponent implements OnInit {
if (!chunk) return
this.typewriterBuffer.push(...chunk.split(''))
+ // Longer bursts need more time to remain readable as the chat scrolls.
+ const revealDuration = Math.min(
+ TYPEWRITER_MAX_DURATION_MS,
+ Math.max(TYPEWRITER_MIN_DURATION_MS, this.typewriterBuffer.length)
+ )
+ this.typewriterDeadline = Date.now() + revealDuration
if (!this.typewriterActive) {
this.typewriterActive = true
@@ -222,19 +232,29 @@ export class ChatComponent implements OnInit {
}
playTypewriter(message: ChatMessage): void {
- if (this.typewriterBuffer.length === 0) {
- this.typewriterActive = false
- if (this.streamFinished) this.finishStreaming(message)
- return
- }
-
- const nextChar = this.typewriterBuffer.shift()
- message.content += nextChar
+ // Spread the queued text across the updates left before the deadline
+ const remainingUpdates = Math.max(
+ 1,
+ Math.ceil((this.typewriterDeadline - Date.now()) / TYPEWRITER_INTERVAL_MS)
+ )
+ const charactersToShow = Math.ceil(
+ this.typewriterBuffer.length / remainingUpdates
+ )
+ message.content += this.typewriterBuffer
+ .splice(0, charactersToShow)
+ .join('')
this.notifyMessagesChanged()
this.scrollToBottom()
- // 10ms per character
- this.typewriterTimeout = setTimeout(() => this.playTypewriter(message), 10)
+ if (this.typewriterBuffer.length === 0) {
+ this.typewriterActive = false
+ if (this.streamFinished) this.finishStreaming(message)
+ } else {
+ this.typewriterTimeout = setTimeout(
+ () => this.playTypewriter(message),
+ TYPEWRITER_INTERVAL_MS
+ )
+ }
}
private notifyMessagesChanged(): void {
diff --git a/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html
index e46d3454be..e6cf5e7109 100644
--- a/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html
+++ b/src-ui/src/app/components/common/confirm-dialog/run-workflow-confirm-dialog/run-workflow-confirm-dialog.component.html
@@ -18,8 +18,13 @@
|