Repository navigation
feat(site): show project instructions in the project page details panel - #30370
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a767efc4fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
`AgentCreateForm` no longer takes the `header`/`footer` slots added in #30378, and no longer owns the page wrapper. The centered `max-w-3xl` wrapper moves into `AgentCreateFormFrame`, which the new-chat page, the project page, and the board draft wrap around the form. The project page renders its existing `ProjectComposerHeader` and `ProjectComposerFooter` (#30379) around the form inside the frame, so nothing changes visually. The form keeps its `project` prop, per-project drafts, and remount per project from #30378. `ChatDiffStats` (from `ChatTreeNode`) and `ProjectActionsMenuItems` (from `ProjectFolders`) are moved into their own files unchanged so the redesigned project page can reuse them. Most of the `AgentCreateForm.tsx` diff is re-indentation; review with whitespace hidden. --- Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: - #30377 data layer and project dialog (f0ssel) - #30378 new-chat form locked to a project (f0ssel) - #30379 project page route (f0ssel) - #29583 sidebar folders (f0ssel), the base of this stack - #30291 composer frame 👈 - #30292 project chat list caches - #30293 project page header - #30294 project chats list - #30367 instructions storage and prompt injection - #30368 instructions API - #30369 instructions editor dialog - #30370 instructions Details panel --------- Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds a project chat list query family (`projectChatsKey`) next to the sidebar's chat lists, so the project page's chat list stays current. - `updateInfiniteChatsCache`, `invalidateChatListQueries`, `cancelChatListRefetches`, `cancelChatListQueries`, and the archive-state patching cover both families. Project lists only hold unarchived chats, so archived chats are dropped. - `archiveChat` snapshots project lists and restores them when archiving fails. - A new project chat invalidates its project list instead of being prepended. Prepending would shift the offset pages and repeat a row on the next page. - `findChatInListCaches` looks a chat up across both families. `AgentsPageLayout` uses it for the chime's previous status and the archive-and-delete `created_at`. The family is kept outside `chatListFamilyKey` because the sidebar helpers assume sidebar-shaped keys. The query factory that fills these caches lands with its consumer in the chats list PR. --- Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: - #30377 data layer and project dialog (f0ssel) - #30378 new-chat form locked to a project (f0ssel) - #30379 project page route (f0ssel) - #29583 sidebar folders (f0ssel), the base of this stack - #30291 composer frame - #30292 project chat list caches 👈 - #30293 project page header - #30294 project chats list - #30367 instructions storage and prompt injection - #30368 instructions API - #30369 instructions editor dialog - #30370 instructions Details panel --------- Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Redesigns the top of `/agents/projects/:projectId`: a left-aligned header with the project icon, name, and an actions menu, then the description and a badge row. The composer fills the page column. - **Actions menu:** Edit project and Delete project replace the "Edit project" button under the composer. Deleting toasts "Project deleted", clears the project's composer drafts as the sidebar's delete does, and returns to `/agents`, keeping the sidebar's filter query string. - **Badges:** Project owner shows "you" for your own projects. Other owners are looked up, with a skeleton while loading and "Unknown" on error. Created shows the date, with the full timestamp in a keyboard-focusable tooltip. Organization only appears when organizations are shown. `ProjectComposerHeader` (#30378) and `ProjectComposerFooter` with its stories (#30379) are removed. The page keeps #30379's loading, "Project not found", and retryable error states, and the `ProjectLoaded` story now waits for the actions menu. The `ProjectComposer` story is removed with the header, so `chatProjectNameMaxChars` and `chatProjectDescriptionMaxChars` are no longer exported. --- Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: - #30377 data layer and project dialog (f0ssel) - #30378 new-chat form locked to a project (f0ssel) - #30379 project page route (f0ssel) - #29583 sidebar folders (f0ssel), the base of this stack - #30291 composer frame - #30292 project chat list caches - #30293 project page header 👈 - #30294 project chats list - #30367 instructions storage and prompt injection - #30368 instructions API - #30369 instructions editor dialog - #30370 instructions Details panel --------- Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
<img width="1506" height="734" alt="Project page" src="https://github.com/user-attachments/assets/bfcfba12-f229-4dfe-87a2-304bc0551ae1" /> Lists the project's unarchived chats below the composer, loaded from `GET /api/v2/chats?project_id=` with infinite scroll. Each row shows the status, title, PR state, owner, and AI Gateway cost (when enabled), with the chat actions menu when the agents layout provides it. Row links keep the sidebar's filter query string. Adds the `projectChats` query factory, whose caches the previous PR keeps in sync. --- Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: - #30377 data layer and project dialog (f0ssel) - #30378 new-chat form locked to a project (f0ssel) - #30379 project page route (f0ssel) - #29583 sidebar folders (f0ssel), the base of this stack - #30291 composer frame - #30292 project chat list caches - #30293 project page header - #30294 project chats list 👈 - #30367 instructions storage and prompt injection - #30368 instructions API - #30369 instructions editor dialog - #30370 instructions Details panel --------- Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ion (#30367) Adds storage for project-level instructions in Coder Agents chat projects and injects them into every chat in the project. This is the first of four stacked PRs that replace #30349. A new `chat_project_instructions` table (migration 000613) holds at most one row per project, scoped to the project's organization. It records `updated_by` and cascades on project delete. The dbauthz wrappers authorize against the parent project: read access to get the instructions, update access to upsert or delete them. No new RBAC resource is added; project RBAC comes in a later PR. chatd loads the instructions on every turn, so edits reach existing chats on their next turn. They are added to the system prompt as a `<project-instructions>` block after the memory guidance and before personal instructions, so a user's personal instructions still win a conflict. Subagent chats carry no `project_id`, so they use their root chat's project. A load error other than no rows is logged, and the turn continues without instructions. **What to scrutinize:** the prompt ordering in `buildSystemPrompt`, and the choice to inject per turn rather than snapshot at chat creation. Per-turn injection costs one prompt-cache miss after each edit; the org instructions in #30272 use a creation-time snapshot instead. **Generated** (`make gen` from the migration and `queries/chatprojectinstructions.sql`): `dump.sql`, `models.go`, `querier.go`, `queries.sql.go`, `dbmetrics/querymetrics.go`, `dbmock/dbmock.go`, and the `*_constraint.go` files. `coderd/x/chatd/ARCHITECTURE.md` gets two TODOs for the PR author to replace with the real description, per AGENTS.md. **Validation:** `make gen` leaves no diff. `go test ./coderd/database/dbauthz -run TestMethodTestSuite/TestChats`, `go test ./coderd/x/chatd -run 'SystemPrompt|ProjectInstructions|Memory'`, and `go test ./coderd/database/migrations/...` pass. --- Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: - #30377 data layer and project dialog (f0ssel) - #30378 new-chat form locked to a project (f0ssel) - #30379 project page route (f0ssel) - #29583 sidebar folders (f0ssel), the base of this stack - #30291 composer frame - #30292 project chat list caches - #30293 project page header - #30294 project chats list - #30367 instructions storage and prompt injection 👈 - #30368 instructions API - #30369 instructions editor dialog - #30370 instructions Details panel --------- Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds the experimental API for chat project instructions: `GET`, `PUT`,
and `DELETE
/api/experimental/organizations/{organization}/chats/projects/{project}/instructions`,
behind the `chat-projects` experiment.
- `GET` returns 200 with empty instructions and null
`updated_by`/`updated_at` when nothing is set, so clients don't need a
404 path.
- `PUT` requires update access only (the read-back runs under a system
context, so a custom role with update but not read can save). It
sanitizes the text with `SanitizePromptText`. It rejects blank text with
400, pointing the caller to `DELETE`, and rejects text over the chat
prompt byte limit. It records the caller as `updated_by`. The upsert and
the read-back that returns the editor's profile run in one transaction.
- `DELETE` returns 204, including when nothing is set.
- Users without access to the project get 404, like the other project
routes.
- `PUT` and `DELETE` are audited as a new `chat_project_instructions`
resource (`write` and `delete`), with the project as the resource ID and
its name as the target. The diff tracks only the instruction text.
Saving unchanged text and deleting unset instructions are not audited. A
per-project advisory lock serializes reading the previous value with the
write, so concurrent edits produce accurate diffs. Migration `000615`
adds the enum value.
The codersdk client gains `ChatProjectInstructions`,
`UpdateChatProjectInstructions`, and `DeleteChatProjectInstructions`.
**What to scrutinize:** writes are last-writer-wins with no version
precondition, matching the deployment, user, and organization prompt
settings.
**Generated:** `coderd/apidoc/docs.go`, `coderd/apidoc/swagger.json`,
and `docs/reference/api/schemas.md` come from the Swagger annotations;
`site/src/api/typesGenerated.ts` comes from `codersdk`;
`docs/admin/security/audit-logs.md`, `coderd/database/dump.sql`, and
`coderd/database/models.go` come from the audit table and migration.
Together they are about 400 of this PR's lines.
**Validation:** `make gen` leaves no diff. `go test ./coderd -run
TestChatProject` and `go test ./enterprise/coderd -run
TestChatProjectInstructions` pass. `TestChatProjectInstructionsAudit`
checks the audit entries for create, update, and delete, and that no-op
saves and deletes are not audited. It covers unset GET, create, update,
blank and oversized PUT, delete, access denial, and cascade on project
delete.
---
Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches
- #30293 project page header
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API 👈
- #30369 instructions editor dialog
- #30370 instructions Details panel
---------
Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Adds `ProjectInstructionsDialog`, the dialog for creating, editing, and
deleting a chat project's instructions. The Details panel in the next PR
opens it.
- Save is disabled when the draft is blank or unchanged once normalized
the way the server stores it. `sanitizePromptText` mirrors
`codersdk.SanitizePromptText`: it strips invisible characters, trims
trailing whitespace on each line, and collapses extra blank lines.
- If the saved instructions change while the dialog is open (another
editor saved them), a warning appears. Save and Delete stay disabled
until the user picks Load latest or Keep my draft. The check only
applies while the dialog is open, so the user's own save does not flash
the warning during the close animation.
- An error without an API message is labelled by the action that failed
("Failed to save instructions." or "Failed to delete instructions.").
**What to scrutinize:** the conflict handling in
`ProjectInstructionsForm`, which keeps the instructions the draft
started from as its baseline.
**Validation:** `ProjectInstructionsDialog.test.tsx` asserts the
`onSave`/`onDelete` callbacks for blank drafts, edits the server would
discard, and conflicts. `invisibleUnicode.test.ts` checks
`sanitizePromptText` against cases verified with the Go function.
Stories cover the create, edit, error, error-without-message,
invisible-character warning, saving, deleting, and conflict states.
`pnpm exec tsc`, biome, oxlint, and knip pass.
---
Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches
- #30293 project page header
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API
- #30369 instructions editor dialog 👈
- #30370 instructions Details panel
---------
Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Lay out the project page with Chats and Details columns below the composer. The Details panel loads the project's instructions and shows a Create button when unset, or a three-line preview with a pen icon button that opens the editor. Mutations write their result to the cache after cancelling in-flight fetches, and the panel remounts per project so an open editor never saves to the next project.
Attempt Save during a refetch conflict and assert no update is sent, instead of checking the disabled state, and drop the panel's copies of the draft rules the dialog tests now cover. Double click Save through userEvent with no delay between clicks.
3035dc6 to
d21f2df
Compare
…ils panel to the merged instructions dialog The base PR renamed onDraftChange to onResetErrors, now also called before save and delete, and added a delete confirmation step. Pass the renamed prop, confirm deletes in the tests, and skip the reset while a mutation is in flight: a fast second submit still sees the previous render's error and would otherwise reset the running retry, dropping its per-call callbacks and leaving the in-flight guard stuck.
Shows chat project instructions on the project page. Below the composer, the page now has Chats and Details columns; the columns follow the page width and stack on narrow screens. In Details, Instructions shows a Create button when unset, or a three-line preview with a pen icon button that opens the editor from the previous PR.
What to scrutinize: the cache handling in
updateChatProjectInstructionsanddeleteChatProjectInstructionsinqueries/chatProjects.ts.Validation:
ProjectDetailsPanel.test.tsxasserts API calls and cache state for create, edit, delete, save failure, error replacement, a fast double click on Save, focus refetch, a refetch conflict resolved with Keep my draft, stale refetches after Save and Delete, load retry, and switching projects. Stories cover the view states. Dogfood UAT ran on a remote Coder Agents workspace against the combined branch in #30349 and passed. It covered the UI flows, the API, and a real model following instructions in new and existing chats.Screenshots
From UAT, except "Instructions set", which shows the current pen icon design from Storybook.
Chat following project instructions
The instructions asked the model to end replies with PINEAPPLE, then were edited to MANGO. The next turn of the same chat followed the edit.
Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of the original #29583, and this stack sits on #29583: