Chat threads and files
Each person's single Rover thread, its message history, clearing it, and the files that come and go with it.
Every staff member or guest who uses Rover has exactly one chat thread. The thread holds their message history and the files Rover made or they attached. This page covers the routes that read and clear the thread, and the routes for its files. How a single turn runs is on What happens on a chat turn.
All routes below need a staff or guest token, and the AI chat feature for that user type (AI_CHAT_STAFF or AI_CHAT_GUEST). None of them take a thread id from the client. The server always works on the caller's own thread, so one person cannot read another's history or files.
The thread
| Method and path | operationId | What it does |
|---|---|---|
GET /api/v1/ai-thread | getMyAiThread | Returns the caller's thread, creating it if there is none yet |
GET /api/v1/ai-thread/messages | listAiThreadMessages | Cursor page of messages, newest first. Page backwards to walk up the history. An empty page when there is no thread yet |
POST /api/v1/ai-thread/reset | resetAiThread | Clears the history and returns a new, empty thread |
Clearing really deletes
resetForUser calls clearForUser, then creates a fresh thread. clearForUser is a hard delete, unlike almost everything else in the API. A comment in the code explains why: people who press clear expect the conversation to be gone, and the agent's saved state holds the full content, including tool results.
It runs in this order:
- Resets the user's Redis chat stream, so a reload cannot pick up a paused turn from the old thread.
- Removes the thread's files (below).
- Hard-deletes the messages, then the thread row.
- Tells the worker to delete the agent's saved conversation state for that thread.
The new thread has a new id, so Rover starts with no memory of the old conversation.
The route description says soft delete
The OpenAPI description on resetAiThread says the thread and messages are soft-deleted. The code hard-deletes them. The code is what happens.
Files
Chat files are things Rover produced for the person, such as a document or a slide deck, and attachments the person sent. They are stored in R2.
| Method and path | operationId | Who | What it does |
|---|---|---|---|
GET /api/v1/ai-thread-file | listAiThreadFiles | Staff, guest | The caller's chat files, newest first |
POST /api/v1/ai-thread-file/upload-url | createAiThreadFileUploadUrl | Staff, guest | Reserves a signed R2 upload for an attachment. The storage record is tied to the caller's thread by the server. Without a thread: Start a chat before attaching a file |
POST /api/v1/ai-thread-file/from-drive | importAiThreadFileFromDrive | Staff | Copies a OneDrive file the caller can read into their thread. The OneDrive file is not changed. Files over 100 MB are refused |
POST /api/v1/ai-thread-file/:id/keep | keepAiThreadFile | Staff | Moves the file into the teacher's own files, under personal, so it survives clearing the chat. It then appears in My Files. The Rover folder is a separate keep; see Files. A file that changed meanwhile is 409 This file changed, try again |
DELETE /api/v1/ai-thread-file/upload/:storageId | discardAiThreadFileUpload | Staff, guest | Deletes an attachment that was uploaded but removed before sending. 204. Refuses one that belongs to another thread (Attachment does not belong to this thread) or is already in the chat (Attachment is already part of this chat) |
GET /api/v1/ai-thread-file/:id/url | getAiThreadFileUrl | Staff, guest | A signed link to preview or download the file, valid for an hour and made fresh on each request |
GET /api/v1/ai-thread-file/:id/pdf | getAiThreadFilePdfUrl | Staff, guest | A signed link to a PDF of an HTML chat file, valid for an hour. Converted on first request and cached until the file changes. 503 while the converter is unavailable, 400 for a file that is not HTML |
When a thread is cleared, removeForThread deletes every chat file's row and its R2 object. A file that was kept is left alone, because it now belongs to the teacher's own files. A failure to delete an R2 object is logged, not thrown.
Background pieces
A background piece makes one file after the plan was already approved. RoverJobRunner.pieceMessage tells the model to save that file itself with save_artifact, even when the brief says not to save, and to give the file a name of its own so it does not replace another piece's file. A file left in the workspace is lost. The piece is ready only when at least one file id was recorded. With none, it fails with No file was made.
propose refuses on that turn. When the run carries background_piece, the tool returns This piece was approved before it started. Do not propose: make it now.
On API staging 99a853f47c0f8efa3a28f2f1cc1682bd48d26823 (merge of PR #687, 28 November 2026, 08:24 GMT), not on main d0fbb403, AgentStreamRunner passes durability: 'exit' only when that same metadata flag is set. A chat turn does not pass durability. The contract test expects one checkpoint put at the end for 'exit', and more than one when the option is omitted. The same test still stores __interrupt__ during the run and resumes it with the answer. Read in apps/worker/src/naalya-agent/core/stream/agent-stream-runner.ts and langgraph-stream-contract.spec.ts. The tests were not run. No load was measured. A merge to staging is not a running deploy. No new environment variable and no migration.
The step list the watcher sees keeps only whether a step failed. A failed step keeps the error, cut at 200 characters. Any other result is stored as ok. The list lasts 24 hours, or 30 days while the piece is waiting for an answer. A waiting piece keeps its thread. Any other outcome deletes the job thread.
keep was re-read at API f57b8103. It defaults to personal. The other chat-file routes above were not re-opened at that tip. How a document or a deck is designed is a playbook on Adding a skill.
Staff routes for pieces
These routes need a staff token and Feature.ROVER_BACKGROUND_JOBS. They start at /api/v1/rover-jobs. No piece was started or stopped.
| Method and path | operationId | What it does |
|---|---|---|
GET /rover-jobs | listMyRoverJobs | The caller's pieces, oldest first. Stopped pieces are left out, and so is a ready piece that has already been opened |
POST /rover-jobs/:id/answer | answerRoverJob | 204. The body field is decisions, taken from ChatResumeDto, which was not opened. A missing piece, or one that is not yours, is Background piece not found. A piece that is not waiting on an answer is This piece is not waiting on an answer. The OpenAPI text says The piece is not waiting for an answer |
POST /rover-jobs/:id/stop | stopRoverJob | 204. Waiting, asking, or failed becomes stopped. A running piece that has not started, stopped a second time, becomes stopped at once. A running piece that has started only sets a Redis stop flag for 1 hour and stays running until the worker reports. A ready piece is left as it is. Stopping a piece that was asking deletes that job's checkpoints |
POST /rover-jobs/:id/retry | retryRoverJob | 204, and only for a failed or stopped piece. Anything else is Only a failed or stopped piece can be tried again. The OpenAPI text says The piece is not failed or stopped |
POST /rover-jobs/:id/open | openRoverJob | 204. Sets openedAt on the caller's piece. It does not check that the piece is ready |
At most 10 of one person's pieces are running or waiting on an answer at once. The count is read without a lock, so two starts at the same moment can pass that by a few. A piece that cannot be queued fails with Could not start.
A batch refuses two pieces that share a key (Two pieces share a key), a piece that waits on a key that is not in the batch, and a loop (Pieces wait on each other in a loop). The HTTP controller does not expose that create. The caller that starts a batch was not re-opened.
The worker runs the rover-job queue at ROVER_JOB_CONCURRENCY, or 5 when that is unset. A stalled run is not tried again (maxStalledCount is 0). A missing brief fails the piece with Could not start. A thrown run fails with Something went wrong. A run the worker lost fails with Stopped unexpectedly. The brief and report calls time out after 60 seconds. When the brief is marked refused, the worker logs it and does not report again. The server has usually already settled the piece.
The brief handler parses a job id and marks the piece started. These are the refusals.
| What the server sees | Code sent back | What happens to the piece |
|---|---|---|
| A payload that is not a job id | not running | Left as it is |
| The piece is not running, or it was already started | not running | Left as it is |
| A stop flag is already set | stopped | Reported as stopped. No model call |
| Background pieces are off for that person | feature off | That piece stops, and so does every waiting piece of theirs |
| The account is not active | account not active | Failed with Account not active |
| Any other error while building the context | could not start | Failed with Could not start |
A brief that is allowed drops ROVER_BACKGROUND_JOBS from the features, so the piece cannot start another piece. If the piece was waiting on an answer, the question and the decisions go back with the brief.
A report the server cannot parse returns ok: false and does not change the piece. A report it accepts is applied and returns ok: true.
Announcing finished work
News uses its own queue, rover-job-announce, so it does not wait behind piece runs. The worker runs 5 at a time. One job id is announce- plus the user id, with 60 attempts and a fixed wait of 5 seconds. A reply of busy throws Chat is busy, and the job is tried again. Any other announce error is thrown too, so it is tried again.
announceJobs does not start a turn when there is no chat, no untold news, the account is not active, or background pieces are off. A stop on its own is not news. An open question, or a turn already running, returns busy and does not take the notes. When the chat is free, the notes are taken once and sent as STAFF_CHAT_ANNOUNCE, with the file ids of ready pieces. The personal channel rover-job then carries announce: true. Notes that were already told release the chat claim and return nothing.
A teacher's own message also picks up untold notes when background pieces are on. A failure to take them is logged, and the message still goes. getInterruptStatus was not opened beyond the call that treats a pending question as busy.
Proposals in the files panel
The Hub files panel lists proposals from the loaded chat, newest first, under Proposals. Opening the newest one, when its title and body match the proposal still waiting, opens the proposal panel. An older proposal stays read-only in the panel, even when the words match. An HTML chat file in that panel is laid out at A4 width and scaled down to fit, so a narrow panel does not reflow the text. When the library has more than one file, Previous file and Next file step through it. The propose activity line is "Waiting for your go-ahead..." and then "Made a proposal." Read in Hub commits 4f5a22842f and fa64983f54, which 40067f22 contains. No proposal was sent.
Download progress
A chat file, a kept staff file, and a lesson-planning file share the same previews. While the bytes are still arriving, FileLoading shows a bar and the line "Downloading" plus the rounded percent, for example "Downloading 25%" when a quarter of the file is in. The bar's accessible name is "Downloading file". When the size is unknown, the same component shows a spinner and no percent.
fetchFileBlob asks for a signed URL, then reads the response. It reports a fraction from 0 to 1 only when Content-Length is a number above 0 and the body can be read in chunks. A missing length, a length of 0, or a body that cannot be read that way returns the blob with no progress calls. A failed response throws Could not load file (HTTP plus the status. Once the blob is stored, the hook clears the fraction, so a text file that is still being turned into text shows the spinner. A slide deck that has already downloaded shows a spinner while it renders. The HTML, image, PDF, slides, text, video, Word, audio, and unsupported previews use this while they wait for bytes. No file was opened in a browser.
Those kinds are Hub main b791c665cd31510be30fd3909d9546ab980fe8cd (merge of PR #465, 24 November 2026, 03:57 GMT). It shares tree a3295290aae8fd92cd614bb6b18acf148f423e5d with staging fb4a140c, so PR #464 is on main. Word is .docx. It loads docx-preview 0.4.1 when the file opens, does not draw embedded web content (renderAltChunks is false), removes iframe, script, object, and embed, and keeps a link only when it starts with http:, https:, or mailto:. Audio is .mp3, .wav, .m4a, .ogg, and .aac. Pictures are .png, .jpg, .jpeg, .webp, .gif, .svg, and .avif. Text is .md, .markdown (drawn as Markdown), .txt, .json, .csv, .tsv, .log, .xml, .yaml, and .yml. Video is .mp4, .webm, .mov, and .m4v. PDF, .pptx, and HTML stay. .xlsx and .doc still show "Preview not available". Compare 1fd1a034...b791c665 is those 10 files, and none is an environment file. The unit test that routes .docx, .mp3, and .xlsx was read and not run. A merge to main is not a running deploy.
The same tree closes the Train Rover panel after a successful save and leaves it open when the save throws. The handbook has no other page for that panel. The department Subjects card only adds self-start. That alignment is not written up.
Sources
The thread and file routes were read at API fbb63d5178bcfe171292daebb19b6cbdac025a44, not run. ai-thread-file.controller.ts keep and the background piece were read at f57b8103547bf5f3a33214e2c814a2e3c1bf1cc0:
apps/server/src/app/ai-thread/ai-thread.controller.tsandai-thread.service.ts(getOrCreateForUser,listMessages,resetForUser,clearForUser).apps/server/src/app/ai-thread-file/ai-thread-file.controller.ts,ai-thread-file-pdf.controller.ts,ai-thread-file.service.ts(createUploadIntent,discardUpload,keep,removeForThread), andai-thread-file-import.service.ts.libs/shared/src/storage/storage-limits.ts(MAX_UPLOAD_BYTES, 100 MB).apps/worker/src/naalya-agent/rover-job/rover-job.runner.ts(pieceMessage,stepResult,NOTHING_MADE).apps/worker/src/naalya-agent/core/tools/local/propose.tool.ts(BACKGROUND_PIECE,createProposeTool).- API
f57b8103547bf5f3a33214e2c814a2e3c1bf1cc0:rover-job.controller.ts,rover-job.service.ts(answer,stop,retry,markOpened,createBatch,dispatch,start,hasNews,report),answer-rover-job.dto.ts,libs/shared/src/rover-job/rover-job.types.ts(ROVER_JOB_MAX_ACTIVE,roverJobStopKey),apps/worker/src/naalya-agent/rover-job/rover-job.processor.ts,rover-job-announce.processor.ts,apps/server/src/app/naalya-ai/rover-job-rpc.controller.ts(brief,announce,report),naalya-ai.service.ts(announceJobs, and the notes taken insidestaffChat).ChatResumeDtoandgetInterruptStatuswere not opened. No piece was started and no announce was sent. The announce tests inannounce-jobs.spec.tswere read and not run. - Hub
staging7d078e35d6ee086f043455b0cdf882a7fde293c0(merge of PR #462, parent40067f22):src/lib/fetch-file-blob.ts,src/components/rover/chat-files/use-chat-file-source.ts,src/components/rover/chat-files/previews/file-loading.tsx, the HTML, image, PDF, slides, text, video, and unsupported previews,staff-file-content.ts, andlesson-planning-file-content.ts. The unit test insrc/lib/tests/fetch-file-blob.test.tswas read and not run. No file was opened in a browser. - Hub
mainb791c665cd31510be30fd3909d9546ab980fe8cd(merge of PR #465) shares treea3295290aae8fd92cd614bb6b18acf148f423e5dwith stagingfb4a140c. Compare1fd1a034...b791c665ispackage.json(docx-preview0.4.1),bun.lock,chat-file-preview.tsx,previews/docx-file-preview.tsx,previews/audio-file-preview.tsx,previews/text-file-preview.tsx,tests/chat-file-preview.test.ts,train-rover.panel.tsxand its test, andself-starton the department Subjects card. Those tests were read and not run. No environment file is in the compare. No file was opened in a browser.
The RPC hop
One agent tool call from model.invoke to the domain service. The worker proxy, the RabbitMQ call, execute(), tenant scope, the two auth postures, and audit.
AI helpers on staff screens
The small one-shot AI calls behind buttons like Suggest, Triage, and Rewrite, and the rule they all follow.