Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-9200: multica view create/update/duplicate/delete (#10555)
Jiayuan Zhangf7365ff8b867
diff --git a/apps/docs/content/docs/cli.fr.mdx b/apps/docs/content/docs/cli.fr.mdxindex e013a124cb..88712322c4 100644--- a/apps/docs/content/docs/cli.fr.mdx+++ b/apps/docs/content/docs/cli.fr.mdx@@ -405,7 +405,7 @@ Les tableaux ci-dessous couvrent toutes les commandes de premier niveau actuelle| | `resource list/add/update/remove` | Gérer les ressources d'un projet | `--type`, `--url`, `--default-branch-hint`, `--ref`, `--local-path`, `--daemon-id`, `--execution-mode` (`in_place` / `worktree` pour un répertoire local) || `label` | `list/get/create/update/delete` | Gérer les étiquettes de l'espace de travail | `list` : `--resource-type` (`issue` ou `skill`), `--full-id` ; `create` : `--name`, `--color`, `--resource-type` (`issue` ou `skill`), `--description` || `property` | `list/get/create/update/archive/unarchive` | Gérer les propriétés personnalisées de l'espace de travail | `create` : `--name`, `--type` (`text`, `number`, `select`, `multi_select`, `date`, `checkbox`, `url`, `actor`, `multi_actor`), `--option` (répétable, types select uniquement) ; `list` : `--include-archived` ; le type ne peut plus être modifié après la création |-| `view` | `list/get/issues` | Lire les vues que vous pouvez ouvrir (les vôtres et celles partagées avec l'espace de travail) ; `issues` liste les tâches qu'une vue affiche, dans son ordre enregistré, avec tous ses filtres appliqués par le serveur. Pendant l'exécution d'un agent, les vues et les conditions « moi » sont celles du propriétaire du runtime | `<view>` accepte un ID, un préfixe d'ID ou le nom exact ; `list` : `--scope` (`workspace`, `my`, `project`), `--project`, `--full-id` ; `issues` : `--limit` (100 au maximum), `--cursor` (le `next_cursor` de la page précédente), `--today` (le jour de référence des filtres d'échéance relatifs ; aujourd'hui par défaut), `--fields` (JSON uniquement), `--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | Lire les vues que vous pouvez ouvrir (les vôtres et celles partagées avec l'espace de travail) ; `issues` liste les tâches qu'une vue affiche, dans son ordre enregistré, avec tous ses filtres appliqués par le serveur. `create`, `update`, `duplicate` et `delete` enregistrent les vues au même format que l'application : elles apparaissent dans la barre latérale et restent modifiables dans l'application ; `update` ne change que ce que ses options nomment et refuse d'écraser une vue modifiée depuis sa lecture. Seul le propriétaire (et, pour une vue partagée, les propriétaires et administrateurs de l'espace de travail) peut modifier ou supprimer une vue. Pendant l'exécution d'un agent, les vues et les conditions « moi » sont celles du propriétaire du runtime | `<view>` accepte un ID, un préfixe d'ID ou le nom exact ; `list` : `--scope` (`workspace`, `my`, `project`), `--project`, `--full-id` ; `issues` : `--limit` (100 au maximum), `--cursor` (le `next_cursor` de la page précédente), `--today` (le jour de référence des filtres d'échéance relatifs ; aujourd'hui par défaut), `--fields` (JSON uniquement), `--full-id` ; `create` : `--name`, `--scope`, `--project`, `--scope-variant`, `--visibility` ; filtres de `create/update/duplicate` : `--status`, `--priority`, `--assignee`, `--creator`, `--label`, `--project-filter`, `--property "Name=Value"`, `--negate <filter>`, etc. ; affichage : `--view-mode`, `--grouping`, `--sort`, `--direction`, `--show-sub-issues`, etc. ; `--definition-file`, `--clear-filters`, `--dry-run` || `agent` | `list/get/create/update/archive/restore` | Gérer les agents | `--name`, `--runtime-id` (obligatoire pour `create`), `--instructions`, `--conversation-starters`, `--model`, `--thinking-level`, `--custom-env` / `--custom-env-file` / `--custom-env-stdin` (`create` uniquement), `--custom-args`, `--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`, `--permission-mode`, `--visibility` (ancienne forme), `--max-concurrent-tasks` || | `copy <agent-id>` | Copier dans un nouvel agent ; l'original reste intact | `--name` (par défaut, le nom d'origine suivi de ` (copy)`), `--runtime-id` (copier vers un autre runtime exige aussi `--model`), `--no-skills` ; la configuration secrète comme `custom_env`, `mcp_config` et `runtime_config` n'est pas copiée — fournissez-la à nouveau avec les mêmes options que pour `create` || | `tasks <id>` | Afficher les exécutions d'un agent | |diff --git a/apps/docs/content/docs/cli.ja.mdx b/apps/docs/content/docs/cli.ja.mdxindex d138d590e5..bf4a30cf84 100644--- a/apps/docs/content/docs/cli.ja.mdx+++ b/apps/docs/content/docs/cli.ja.mdx@@ -397,7 +397,7 @@ CLI の設定ファイルには、あなたとして Multica にアクセスで| | `resource list/add/update/remove` | プロジェクトの追加リソースを管理 | `--type`、`--url`、`--default-branch-hint`、`--ref`、`--local-path`、`--daemon-id`、`--execution-mode`(ローカルディレクトリの `in_place` / `worktree`) || `label` | `list/get/create/update/delete` | ワークスペースのラベルを管理 | `list`: `--resource-type`(`issue` または `skill`)、`--full-id`;`create`: `--name`、`--color`、`--resource-type`(`issue` または `skill`)、`--description` || `property` | `list/get/create/update/archive/unarchive` | ワークスペースのカスタムプロパティを管理 | `create`: `--name`、`--type`(`text`、`number`、`select`、`multi_select`、`date`、`checkbox`、`url`、`actor`、`multi_actor`、`multi_text`、`multi_url`)、`--option`(繰り返し可、select 系のみ);`list`: `--include-archived`;タイプは作成後に変更できません |-| `view` | `list/get/issues` | 開けるビュー(自分のものとワークスペースで共有されたもの)を読み取り、`issues` でビューに表示されるタスクを保存された並び順で一覧(保存されたフィルターはすべてサーバー側で適用)。エージェントの実行中は、ビューと「自分」の条件はランタイム所有者のものになります | `<view>` は ID、ID プレフィックス、または完全な名前を受け付けます;`list`: `--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`: `--limit`(最大 100)、`--cursor`(前のページの `next_cursor`)、`--today`(相対的な期日フィルターの基準日、既定は今日)、`--fields`(JSON のみ)、`--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | 開けるビュー(自分のものとワークスペースで共有されたもの)を読み取り、`issues` でビューに表示されるタスクを保存された並び順で一覧(保存されたフィルターはすべてサーバー側で適用)。`create`・`update`・`duplicate`・`delete` はアプリと同じ形式でビューを書き込むため、サイドバーに表示され、アプリで引き続き編集できます。`update` は指定した項目だけを変更し、読み取り後に他の人が変更したビューは上書きせずに拒否します。変更・削除できるのは所有者(共有ビューはワークスペースのオーナーと管理者も)だけです。エージェントの実行中は、ビューと「自分」の条件はランタイム所有者のものになります | `<view>` は ID、ID プレフィックス、または完全な名前を受け付けます;`list`: `--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`: `--limit`(最大 100)、`--cursor`(前のページの `next_cursor`)、`--today`(相対的な期日フィルターの基準日、既定は今日)、`--fields`(JSON のみ)、`--full-id`;`create`: `--name`、`--scope`、`--project`、`--scope-variant`、`--visibility`;`create/update/duplicate` のフィルター: `--status`、`--priority`、`--assignee`、`--creator`、`--label`、`--project-filter`、`--property "Name=Value"`、`--negate <filter>` など;表示: `--view-mode`、`--grouping`、`--sort`、`--direction`、`--show-sub-issues` など;`--definition-file`、`--clear-filters`、`--dry-run` || `agent` | `list/get/create/update/archive/restore` | エージェントを管理 | `--name`、`--runtime-id`(`create` では必須)、`--instructions`、`--conversation-starters`、`--model`、`--thinking-level`、`--custom-env` / `--custom-env-file` / `--custom-env-stdin`(`create` のみ)、`--custom-args`、`--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`、`--permission-mode`、`--visibility`(古い書き方)、`--max-concurrent-tasks` || | `copy <agent-id>` | 新しいエージェントとして複製。元のエージェントは変更されません | `--name`(デフォルトは元の名前 + ` (copy)`)、`--runtime-id`(別のランタイムへ複製する場合は `--model` の同時指定が必須)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` などの機密設定は複製されないため、`create` と同じフラグで再指定してください || | `tasks <id>` | エージェントの実行を表示 | |diff --git a/apps/docs/content/docs/cli.ko.mdx b/apps/docs/content/docs/cli.ko.mdxindex e76745494c..7315da09f9 100644--- a/apps/docs/content/docs/cli.ko.mdx+++ b/apps/docs/content/docs/cli.ko.mdx@@ -397,7 +397,7 @@ CLI 설정 파일에는 사용자를 대신해 Multica에 접근할 수 있는 t| | `resource list/add/update/remove` | 프로젝트 추가 리소스 관리 | `--type`, `--url`, `--default-branch-hint`, `--ref`, `--local-path`, `--daemon-id`, `--execution-mode`(로컬 디렉터리의 `in_place` / `worktree`) || `label` | `list/get/create/update/delete` | 워크스페이스 라벨 관리 | `list`: `--resource-type`(`issue` 또는 `skill`), `--full-id`; `create`: `--name`, `--color`, `--resource-type`(`issue` 또는 `skill`), `--description` || `property` | `list/get/create/update/archive/unarchive` | 워크스페이스 사용자 지정 속성 관리 | `create`: `--name`, `--type`(`text`, `number`, `select`, `multi_select`, `date`, `checkbox`, `url`, `actor`, `multi_actor`, `multi_text`, `multi_url`), `--option`(반복 가능, select 유형만). `list`: `--include-archived`. 유형은 생성 후 변경 불가 |-| `view` | `list/get/issues` | 열 수 있는 뷰(내 뷰와 워크스페이스에 공유된 뷰)를 읽고, `issues`로 뷰에 보이는 태스크를 저장된 정렬 순서대로 나열(저장된 필터는 모두 서버에서 적용). 에이전트 실행 중에는 뷰와 '나' 조건이 런타임 소유자 기준 | `<view>`는 ID, ID 접두사 또는 정확한 이름을 받음. `list`: `--scope`(`workspace`, `my`, `project`), `--project`, `--full-id`. `issues`: `--limit`(최대 100), `--cursor`(이전 페이지의 `next_cursor`), `--today`(상대 마감일 필터의 기준일, 기본값은 오늘), `--fields`(JSON 전용), `--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | 열 수 있는 뷰(내 뷰와 워크스페이스에 공유된 뷰)를 읽고, `issues`로 뷰에 보이는 태스크를 저장된 정렬 순서대로 나열(저장된 필터는 모두 서버에서 적용). `create`, `update`, `duplicate`, `delete`는 앱과 같은 형식으로 뷰를 저장하므로 사이드바에 보이고 앱에서 계속 편집할 수 있음. `update`는 지정한 항목만 바꾸며, 읽은 뒤 다른 사람이 바꾼 뷰는 덮어쓰지 않고 거부함. 소유자(공유 뷰는 워크스페이스 소유자와 관리자도)만 수정하거나 삭제할 수 있음. 에이전트 실행 중에는 뷰와 '나' 조건이 런타임 소유자 기준 | `<view>`는 ID, ID 접두사 또는 정확한 이름을 받음. `list`: `--scope`(`workspace`, `my`, `project`), `--project`, `--full-id`. `issues`: `--limit`(최대 100), `--cursor`(이전 페이지의 `next_cursor`), `--today`(상대 마감일 필터의 기준일, 기본값은 오늘), `--fields`(JSON 전용), `--full-id`. `create`: `--name`, `--scope`, `--project`, `--scope-variant`, `--visibility`. `create/update/duplicate` 필터: `--status`, `--priority`, `--assignee`, `--creator`, `--label`, `--project-filter`, `--property "Name=Value"`, `--negate <filter>` 등. 표시: `--view-mode`, `--grouping`, `--sort`, `--direction`, `--show-sub-issues` 등. `--definition-file`, `--clear-filters`, `--dry-run` || `agent` | `list/get/create/update/archive/restore` | 에이전트 관리 | `--name`, `--runtime-id`(`create`에서 필수), `--instructions`, `--conversation-starters`, `--model`, `--thinking-level`, `--custom-env` / `--custom-env-file` / `--custom-env-stdin`(`create` 전용), `--custom-args`, `--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`, `--permission-mode`, `--visibility`(예전 방식), `--max-concurrent-tasks` || | `copy <agent-id>` | 원래 에이전트에 영향 없이 새 에이전트로 복사 | `--name`(기본값은 원래 이름 + ` (copy)`), `--runtime-id`(다른 런타임으로 복사할 때 `--model`도 필수), `--no-skills`. `custom_env`, `mcp_config`, `runtime_config` 같은 기밀 설정은 복사되지 않으며 `create`와 같은 flag로 다시 제공해야 함 || | `tasks <id>` | 에이전트 실행 확인 | |diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdxindex bdeecbae2c..e17c7ff75c 100644--- a/apps/docs/content/docs/cli.mdx+++ b/apps/docs/content/docs/cli.mdx@@ -432,7 +432,7 @@ Migration from CSV parsing: replace `--attachment a,b` with `--attachment a --at| `issue-status` | `list/get/create/update/archive` | Manage the workspace status catalog — the statuses every workflow picks from. To change an issue's current status, use `issue status` | `create`: `--name`, `--category`, `--color`, `--key`, `--icon`; `update`: `--name`, `--description`, `--color`, `--icon` (empty resets to the category default), `--position`; `list`: `--include-archived`. Mutations require workspace owner/admin || `label` | `list/get/create/update/delete` | Manage workspace labels | `list`: `--resource-type` (`issue` or `skill`), `--full-id`; `create`: `--name`, `--color`, `--resource-type` (`issue` or `skill`), `--description` || `property` | `list/get/create/update/archive/unarchive` | Manage workspace custom properties | `create`: `--name`, `--type` (`text`, `number`, `select`, `multi_select`, `date`, `checkbox`, `url`, `actor`, `multi_actor`, `multi_text`, `multi_url`), `--option` (repeatable, select types only); `list`: `--include-archived`; the type cannot be changed after creation |-| `view` | `list/get/issues` | Read the saved views you can open (your own and workspace-shared ones); `issues` lists what a view shows, in its saved order, with every saved filter applied by the server. Inside an agent run, the views and any "my" conditions are the runtime owner's | `<view>` accepts an ID, ID prefix, or exact name; `list`: `--scope` (`workspace`, `my`, `project`), `--project`, `--full-id`; `issues`: `--limit` (at most 100), `--cursor` (the previous page's `next_cursor`), `--today` (the day relative due-date filters resolve against; default today), `--fields` (JSON only), `--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | Read the saved views you can open (your own and workspace-shared ones); `issues` lists what a view shows, in its saved order, with every saved filter applied by the server. `create`, `update`, `duplicate` and `delete` write views exactly as the app saves them, so they show in the sidebar and stay editable there; `update` changes only what its flags name and refuses to overwrite a view that changed since it was read. Only the owner, or a workspace owner/admin for a shared view, can change or delete one. Inside an agent run, the views and any "my" conditions are the runtime owner's | `<view>` accepts an ID, ID prefix, or exact name; `list`: `--scope` (`workspace`, `my`, `project`), `--project`, `--full-id`; `issues`: `--limit` (at most 100), `--cursor` (the previous page's `next_cursor`), `--today` (the day relative due-date filters resolve against; default today), `--fields` (JSON only), `--full-id`; `create`: `--name`, `--scope`, `--project`, `--scope-variant`, `--visibility`; `create/update/duplicate` filters: `--status`, `--priority`, `--assignee`, `--creator`, `--label`, `--project-filter`, `--project-status`, `--relation`, `--due`, `--property "Name=Value"`, `--negate <filter>`, `--include-no-assignee`, `--include-no-project`, `--agent-running`, `--agent-idle`, `--unread`; display: `--view-mode`, `--grouping`, `--table-grouping`, `--swimlane-grouping`, `--gantt-zoom`, `--sort`, `--direction`, `--show-sub-issues`; `--definition-file` (JSON `query`/`display`, e.g. edited `view get` output), `--clear-filters` (update/duplicate), `--dry-run` || `agent` | `list/get/create/update/archive/restore` | Manage agents | `--name`, `--runtime-id` (required for `create`), `--instructions`, `--conversation-starters`, `--model`, `--thinking-level`, `--custom-env` / `--custom-env-file` / `--custom-env-stdin` (`create` only), `--custom-args`, `--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`, `--permission-mode`, `--visibility` (older form), `--max-concurrent-tasks` || | `copy <agent-id>` | Copy into a new agent; the original is untouched | `--name` (defaults to the original name plus ` (copy)`), `--runtime-id` (copying to another runtime also requires `--model`), `--no-skills`; secret configuration such as `custom_env`, `mcp_config`, and `runtime_config` is not copied — re-provide it with the same flags as `create` || | `tasks <id>` | View an agent's runs | |diff --git a/apps/docs/content/docs/cli.zh-Hant.mdx b/apps/docs/content/docs/cli.zh-Hant.mdxindex 8dc3e4fcca..c60b39ba5b 100644--- a/apps/docs/content/docs/cli.zh-Hant.mdx+++ b/apps/docs/content/docs/cli.zh-Hant.mdx@@ -406,7 +406,7 @@ CLI 配置檔案包含可代表你訪問 Multica 的令牌。不要提交到倉| `issue-status` | `list/get/create/update/archive` | 管理工作區狀態目錄,即所有工作流共用的狀態。修改任務目前狀態請用 `issue status` | `create`:`--name`、`--category`、`--color`、`--key`、`--icon`;`update`:`--name`、`--description`、`--color`、`--icon`(空值恢復為分類預設圖示)、`--position`;`list`:`--include-archived`。變更需要工作區擁有者或管理員權限 || `label` | `list/get/create/update/delete` | 管理工作區標籤 | `list`:`--resource-type`(`issue` 或 `skill`)、`--full-id`;`create`:`--name`、`--color`、`--resource-type`(`issue` 或 `skill`)、`--description` || `property` | `list/get/create/update/archive/unarchive` | 管理工作區自定義屬性 | `create`:`--name`、`--type`(`text`、`number`、`select`、`multi_select`、`date`、`checkbox`、`url`、`actor`、`multi_actor`、`multi_text`、`multi_url`)、`--option`(可重複,僅 select 型別);`list`:`--include-archived`;型別建立後不可修改 |-| `view` | `list/get/issues` | 讀取你能開啟的檢視(自己的和工作區共享的);`issues` 按檢視儲存的排序列出檢視裡的任務,檢視儲存的全部篩選條件都由服務端執行。在 AI 代理執行中,看到的檢視和其中「我的」條件都屬於執行時的所有者 | `<view>` 接受 ID、ID 字首或完整名稱;`list`:`--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`:`--limit`(最多 100)、`--cursor`(上一頁的 `next_cursor`)、`--today`(相對到期日篩選按哪一天計算,預設今天)、`--fields`(僅 JSON)、`--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | 讀取你能開啟的檢視(自己的和工作區共享的);`issues` 按檢視儲存的排序列出檢視裡的任務,檢視儲存的全部篩選條件都由服務端執行。`create`、`update`、`duplicate`、`delete` 按應用儲存檢視的同一格式寫入,檢視會出現在側邊欄並可繼續在應用裡編輯;`update` 只改傳入的參數,檢視在讀取後被他人改過時拒絕覆寫。只有擁有者(共享檢視還包括工作區擁有者和管理員)能修改或刪除檢視。在 AI 代理執行中,看到的檢視和其中「我的」條件都屬於執行時的所有者 | `<view>` 接受 ID、ID 字首或完整名稱;`list`:`--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`:`--limit`(最多 100)、`--cursor`(上一頁的 `next_cursor`)、`--today`(相對到期日篩選按哪一天計算,預設今天)、`--fields`(僅 JSON)、`--full-id`;`create`:`--name`、`--scope`、`--project`、`--scope-variant`、`--visibility`;`create/update/duplicate` 篩選:`--status`、`--priority`、`--assignee`、`--creator`、`--label`、`--project-filter`、`--property "Name=Value"`、`--negate <filter>` 等;顯示:`--view-mode`、`--grouping`、`--sort`、`--direction`、`--show-sub-issues` 等;`--definition-file`、`--clear-filters`、`--dry-run` || `agent` | `list/get/create/update/archive/restore` | 管理 AI 代理 | `--name`、`--runtime-id`(`create` 必填)、`--instructions`、`--conversation-starters`、`--model`、`--thinking-level`、`--custom-env` / `--custom-env-file` / `--custom-env-stdin`(僅 `create`)、`--custom-args`、`--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`、`--permission-mode`、`--visibility`(舊寫法)、`--max-concurrent-tasks` || | `copy <agent-id>` | 複製為新 AI 代理,原 AI 代理不受影響 | `--name`(預設為原名加 ` (copy)`)、`--runtime-id`(複製到其他執行時時必須同時指定 `--model`)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` 等機密配置不會複製,需用與 `create` 相同的 flag 重新提供 || | `tasks <id>` | 檢視 AI 代理的執行 | |diff --git a/apps/docs/content/docs/cli.zh.mdx b/apps/docs/content/docs/cli.zh.mdxindex 4323d36f1d..89f3e1ba1d 100644--- a/apps/docs/content/docs/cli.zh.mdx+++ b/apps/docs/content/docs/cli.zh.mdx@@ -409,7 +409,7 @@ CLI 配置文件包含可代表你访问 Multica 的令牌。不要提交到仓| `issue-status` | `list/get/create/update/archive` | 管理工作区状态目录,即所有工作流共用的状态。修改任务当前状态请用 `issue status` | `create`:`--name`、`--category`、`--color`、`--key`、`--icon`;`update`:`--name`、`--description`、`--color`、`--icon`(空值恢复为分类默认图标)、`--position`;`list`:`--include-archived`。变更需要工作区所有者或管理员权限 || `label` | `list/get/create/update/delete` | 管理工作区标签 | `list`:`--resource-type`(`issue` 或 `skill`)、`--full-id`;`create`:`--name`、`--color`、`--resource-type`(`issue` 或 `skill`)、`--description` || `property` | `list/get/create/update/archive/unarchive` | 管理工作区自定义属性 | `create`:`--name`、`--type`(`text`、`number`、`select`、`multi_select`、`date`、`checkbox`、`url`、`actor`、`multi_actor`、`multi_text`、`multi_url`)、`--option`(可重复,仅 select 类型);`list`:`--include-archived`;类型创建后不可修改 |-| `view` | `list/get/issues` | 读取你能打开的视图(自己的和工作区共享的);`issues` 按视图保存的排序列出视图里的任务,视图保存的全部筛选条件都由服务端执行。在智能体运行中,看到的视图和其中「我的」条件都属于运行时的所有者 | `<view>` 接受 ID、ID 前缀或完整名称;`list`:`--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`:`--limit`(最多 100)、`--cursor`(上一页的 `next_cursor`)、`--today`(相对到期日筛选按哪一天计算,默认今天)、`--fields`(仅 JSON)、`--full-id` |+| `view` | `list/get/issues/create/update/duplicate/delete` | 读取你能打开的视图(自己的和工作区共享的);`issues` 按视图保存的排序列出视图里的任务,视图保存的全部筛选条件都由服务端执行。`create`、`update`、`duplicate`、`delete` 按应用保存视图的同一格式写入,视图会出现在侧边栏并可继续在应用里编辑;`update` 只改传入的参数,视图在读取后被他人改过时拒绝覆盖。只有所有者(共享视图还包括工作区所有者和管理员)能修改或删除视图。在智能体运行中,看到的视图和其中「我的」条件都属于运行时的所有者 | `<view>` 接受 ID、ID 前缀或完整名称;`list`:`--scope`(`workspace`、`my`、`project`)、`--project`、`--full-id`;`issues`:`--limit`(最多 100)、`--cursor`(上一页的 `next_cursor`)、`--today`(相对到期日筛选按哪一天计算,默认今天)、`--fields`(仅 JSON)、`--full-id`;`create`:`--name`、`--scope`、`--project`、`--scope-variant`、`--visibility`;`create/update/duplicate` 筛选:`--status`、`--priority`、`--assignee`、`--creator`、`--label`、`--project-filter`、`--property "Name=Value"`、`--negate <filter>` 等;显示:`--view-mode`、`--grouping`、`--sort`、`--direction`、`--show-sub-issues` 等;`--definition-file`、`--clear-filters`、`--dry-run` || `agent` | `list/get/create/update/archive/restore` | 管理智能体 | `--name`、`--runtime-id`(`create` 必填)、`--instructions`、`--conversation-starters`、`--model`、`--thinking-level`、`--custom-env` / `--custom-env-file` / `--custom-env-stdin`(仅 `create`)、`--custom-args`、`--mcp-config` / `--mcp-config-file` / `--mcp-config-stdin`、`--permission-mode`、`--visibility`(旧写法)、`--max-concurrent-tasks` || | `copy <agent-id>` | 复制为新智能体,原智能体不受影响 | `--name`(默认为原名加 ` (copy)`)、`--runtime-id`(复制到其他运行时时必须同时指定 `--model`)、`--no-skills`;`custom_env`、`mcp_config`、`runtime_config` 等机密配置不会复制,需用与 `create` 相同的 flag 重新提供 || | `tasks <id>` | 查看智能体的运行 | |diff --git a/server/cmd/multica/cmd_view.go b/server/cmd/multica/cmd_view.goindex b41155378b..d67e3cf57c 100644--- a/server/cmd/multica/cmd_view.go+++ b/server/cmd/multica/cmd_view.go@@ -14,18 +14,18 @@ import ()// View commands — read the saved issue views a member can open, and the-// issues each one lists.+// issues each one lists. Writes live in cmd_view_write.go.const viewIssuesMaxPageSize = 100var viewCmd = &cobra.Command{Use: "view",- Short: "Read saved issue views and the issues they list",- Long: `Read saved issue views and the issues they list.+ Short: "Read and manage saved issue views",+ Long: `Read and manage saved issue views, and list the issues they show.A view is the caller's own or a workspace-shared saved filter. Inside an agent-run the caller is the runtime owner, so the views listed and any "my" scope or-"assigned to me" condition are the runtime owner's.`,+run the caller is the runtime owner, so the views listed, the views created,+and any "my" scope or "assigned to me" condition are the runtime owner's.`,}var viewListCmd = &cobra.Command{diff --git a/server/cmd/multica/cmd_view_write.go b/server/cmd/multica/cmd_view_write.gonew file mode 100644index 0000000000..02d2d29cbd--- /dev/null+++ b/server/cmd/multica/cmd_view_write.go@@ -0,0 +1,1089 @@+package main++import (+ "context"+ "encoding/json"+ "errors"+ "fmt"+ "net/http"+ "net/url"+ "os"+ "slices"+ "strings"+ "unicode/utf8"++ "github.com/spf13/cobra"++ "github.com/multica-ai/multica/server/internal/cli"+)++// View write commands — create, update, duplicate and delete saved views.+//+// A view's query and display are the web client's IssueViewDefinition+// (packages/core/issue-views/definition.ts). The client merges a partial+// definition over its defaults when it opens a view, so these commands write+// only the keys a flag sets and keep every other key as stored.++// issueViewDefinitionVersion is the definition format this CLI writes. A view+// stored in any other format is refused instead of rewritten in this one.+const issueViewDefinitionVersion = 1++const issueViewNameMaxLen = 80++var (+ viewScopeVariants = map[string][]string{+ "workspace": {"all", "members", "agents"},+ "project": {"all", "members", "agents"},+ "my": {"any", "assigned", "created", "involved"},+ }+ viewVisibilities = []string{"private", "workspace"}+ viewModes = []string{"board", "list", "table", "gantt", "swimlane"}+ viewGroupings = []string{"status", "assignee", "project"}+ viewTableGroupings = []string{"none", "status", "assignee", "project"}+ viewSwimlaneGroupings = []string{"parent", "project", "assignee"}+ viewGanttZooms = []string{"day", "week", "month"}+ viewSortFields = []string{"position", "status", "priority", "start_date", "due_date", "created_at", "updated_at", "title"}+ viewRelations = []string{"assigned", "created", "my_agents", "subscribed"}+ viewDueDates = []string{"overdue", "today", "this_week", "next_7_days", "none"}+ // viewNegatableDimensions maps each --negate value to its query key, in+ // the client's canonical order.+ viewNegatableDimensions = []struct{ flag, dimension string }{+ {"status", "status"},+ {"priority", "priority"},+ {"assignee", "assignee"},+ {"creator", "creator"},+ {"project", "project"},+ {"project-status", "projectStatus"},+ {"label", "label"},+ {"relation", "relation"},+ {"due", "dueDate"},+ }+)++// viewFlatFilterFlags write the simple-mode filter fields. While a view+// filters with an advanced condition tree the client keeps these fields+// empty, so they cannot be combined with one.+var viewFlatFilterFlags = []string{+ "status", "priority", "assignee", "include-no-assignee", "creator",+ "project-filter", "include-no-project", "project-status", "label",+ "relation", "due", "property", "negate",+}++var viewFilterFlags = append(slices.Clone(viewFlatFilterFlags), "agent-running", "agent-idle", "unread")++var viewDisplayFlags = []string{+ "view-mode", "grouping", "table-grouping", "swimlane-grouping", "gantt-zoom",+ "sort", "direction", "show-sub-issues",+}++var viewCreateCmd = &cobra.Command{+ Use: "create",+ Short: "Create a saved view",+ Long: `Create a saved view. It is saved exactly as the web app saves one, so it shows+in the sidebar and can be opened and edited there.++Filter flags take names the way the UI shows them; the CLI resolves them to+IDs before writing. List flags are repeatable and also accept comma-separated+values. Unset flags keep the app's defaults.++--definition-file takes a JSON file with "query" and/or "display" objects,+for example the output of ` + "`multica view get`" + ` edited by hand; flags apply on+top of it. --dry-run prints the request without saving. After saving, preview+what the view lists with ` + "`multica view issues <view>`" + `.++Inside an agent run the view is created for, and owned by, the runtime owner.`,+ Example: ` multica view create --name "Open bugs" --label Bug --status done --status cancelled --negate status+ multica view create --name "My review queue" --scope my --scope-variant assigned --status in_review --view-mode list+ multica view create --name "Launch" --project "Website" --view-mode table --sort due_date --visibility workspace`,+ Args: exactArgs(0),+ RunE: runViewCreate,+}++var viewUpdateCmd = &cobra.Command{+ Use: "update <view>",+ Short: "Change a saved view",+ Long: `Change a saved view. <view> is a view ID, ID prefix, or exact name+(case-insensitive). Only what a flag names changes; every other filter and+display setting stays as saved. A list flag replaces that filter's values;+pass it an empty value (--status "") to clear the filter.++--clear-filters drops every saved filter before the filter flags apply, which+is also how to replace a view's advanced condition tree with simple filters.++The write carries the revision that was read, so if the view changed in the+meantime the server refuses it instead of overwriting; re-run to apply the+change on top of the latest version. A --definition-file exported from this+view with ` + "`view get`" + ` carries its own revision: if the view changed after the+export, nothing is saved, so export it again and redo the edits. Only the owner can change a private view;+a workspace-shared view can also be changed by workspace owners and admins.`,+ Example: ` multica view update "Open bugs" --priority urgent --priority high+ multica view update "Open bugs" --status "" --view-mode board --grouping assignee+ multica view update 6a1b2c3d --visibility workspace --name "Team bugs"`,+ Args: exactArgs(1),+ RunE: runViewUpdate,+}++var viewDuplicateCmd = &cobra.Command{+ Use: "duplicate <view>",+ Short: "Copy a saved view into a new view of your own",+ Long: `Copy a saved view into a new private view you own, in the same scope. Any+filter or display flag changes the copy, the same way it changes a view with+` + "`multica view update`" + `; the original is left as it is.`,+ Example: ` multica view duplicate "Open bugs" --name "Open bugs (urgent)" --priority urgent`,+ Args: exactArgs(1),+ RunE: runViewDuplicate,+}++var viewDeleteCmd = &cobra.Command{+ Use: "delete <view>",+ Short: "Delete a saved view",+ Long: `Delete a saved view. <view> is a view ID, ID prefix, or exact name+(case-insensitive). Only the owner can delete a private view; a+workspace-shared view can also be deleted by workspace owners and admins.`,+ Args: exactArgs(1),+ RunE: runViewDelete,+}++func init() {+ viewCmd.AddCommand(viewCreateCmd)+ viewCmd.AddCommand(viewUpdateCmd)+ viewCmd.AddCommand(viewDuplicateCmd)+ viewCmd.AddCommand(viewDeleteCmd)++ viewCreateCmd.Flags().String("name", "", "View name (required, at most 80 characters)")+ viewCreateCmd.Flags().String("scope", "", "Page the view belongs to: workspace (All issues, the default), my (My issues), or project")+ viewCreateCmd.Flags().String("project", "", "Project the view belongs to (name, ID, or ID prefix); implies --scope project")+ viewCreateCmd.Flags().String("scope-variant", "", "Tab within the scope: all, members or agents for workspace and project views; any (default), assigned, created or involved for my views")+ viewCreateCmd.Flags().String("visibility", "private", "private, or workspace to share it with every member (my views are always private)")+ addViewDefinitionFlags(viewCreateCmd, false)+ viewCreateCmd.Flags().String("output", "json", "Output format: table or json")++ viewUpdateCmd.Flags().String("name", "", "New name (at most 80 characters)")+ viewUpdateCmd.Flags().String("scope-variant", "", "New tab within the view's scope (see `view create --help`); the scope itself cannot change")+ viewUpdateCmd.Flags().String("visibility", "", "private or workspace")+ addViewDefinitionFlags(viewUpdateCmd, true)+ viewUpdateCmd.Flags().String("output", "json", "Output format: table or json")++ viewDuplicateCmd.Flags().String("name", "", `Name of the copy (default: "<name> (copy)")`)+ viewDuplicateCmd.Flags().String("visibility", "private", "private or workspace")+ addViewDefinitionFlags(viewDuplicateCmd, true)+ viewDuplicateCmd.Flags().String("output", "json", "Output format: table or json")++ viewDeleteCmd.Flags().String("output", "table", "Output format: table or json")+}++func addViewDefinitionFlags(cmd *cobra.Command, clearable bool) {+ f := cmd.Flags()+ f.StringArray("status", nil, "Status key or name to match")+ f.StringArray("priority", nil, "Priority to match: "+strings.Join(validIssuePriorities, ", "))+ f.StringArray("assignee", nil, "Assignee to match: member, agent or squad name, email, or ID")+ f.Bool("include-no-assignee", false, "Also match unassigned issues")+ f.StringArray("creator", nil, "Creator to match: member or agent name, email, or ID")+ f.StringArray("project-filter", nil, "Project to match (name, ID, or ID prefix); not available on project views")+ f.Bool("include-no-project", false, "Also match issues without a project; not available on project views")+ f.StringArray("project-status", nil, "Status of the issue's project to match: "+strings.Join(validProjectStatuses, ", "))+ f.StringArray("label", nil, "Label to match (name, ID, or ID prefix)")+ f.StringArray("relation", nil, "How the viewer relates to the issue: "+strings.Join(viewRelations, ", ")+"; not available on my views")+ f.StringArray("due", nil, "Due date bucket to match: "+strings.Join(viewDueDates, ", "))+ f.StringArray("property", nil, `Custom property condition, written as for `+"`issue list --property`"+`: "Name=Value", "Score>=3", "Notes~=review" (one per flag; repeating a property matches any of its values)`)+ f.StringArray("negate", nil, "Filter that matches \"is not\" instead of \"is\": "+strings.Join(viewNegatableFlagNames(), ", "))+ f.Bool("agent-running", false, "Only issues an agent is working on right now")+ f.Bool("agent-idle", false, "Only issues without running or queued agent work")+ f.Bool("unread", false, "Only issues with an agent result the viewer has not seen")++ f.String("view-mode", "", "Layout: "+strings.Join(viewModes, ", "))+ f.String("grouping", "", "Board columns: status, assignee, project, or property:<name> for a select property")+ f.String("table-grouping", "", "Table groups: none, status, assignee, project, or property:<name> for a select or checkbox property")+ f.String("swimlane-grouping", "", "Swimlanes: "+strings.Join(viewSwimlaneGroupings, ", "))+ f.String("gantt-zoom", "", "Gantt zoom: "+strings.Join(viewGanttZooms, ", "))+ f.String("sort", "", "Sort: "+strings.Join(viewSortFields, ", ")+", or property:<name>; position (manual order) needs status grouping")+ f.String("direction", "", "Sort direction: asc or desc (default: desc for created_at and updated_at, asc otherwise)")+ f.Bool("show-sub-issues", true, "Show sub-issues (--show-sub-issues=false lists top-level issues only)")++ f.String("definition-file", "", `JSON file with "query" and/or "display" objects (e.g. edited `+"`view get`"+` output); flags apply on top`)+ if clearable {+ f.Bool("clear-filters", false, "Drop every saved filter before the filter flags apply")+ }+ f.Bool("dry-run", false, "Print the request instead of saving it")+}++func viewNegatableFlagNames() []string {+ names := make([]string, len(viewNegatableDimensions))+ for i, d := range viewNegatableDimensions {+ names[i] = d.flag+ }+ return names+}++// issueViewDefinition is a view's query and display as generic JSON, so keys+// this CLI does not know round-trip untouched.+type issueViewDefinition struct {+ Query map[string]any+ Display map[string]any+}++func copyJSONObject(value any) (map[string]any, error) {+ raw, err := json.Marshal(value)+ if err != nil {+ return nil, err+ }+ var out map[string]any+ if err := json.Unmarshal(raw, &out); err != nil {+ return nil, err+ }+ if out == nil {+ out = map[string]any{}+ }+ return out, nil+}++// definitionOfView returns a copy of a stored view's definition, refusing a+// format this CLI would corrupt by rewriting.+func definitionOfView(view map[string]any) (issueViewDefinition, error) {+ version, _ := view["definition_version"].(float64)+ if version != issueViewDefinitionVersion {+ return issueViewDefinition{}, fmt.Errorf("view %q is stored as definition_version %v, but this CLI writes version %d; update with `multica update`", strVal(view, "name"), view["definition_version"], issueViewDefinitionVersion)+ }+ query, err := copyJSONObject(view["query"])+ if err != nil {+ return issueViewDefinition{}, fmt.Errorf("read view query: %w", err)+ }+ display, err := copyJSONObject(view["display"])+ if err != nil {+ return issueViewDefinition{}, fmt.Errorf("read view display: %w", err)+ }+ return issueViewDefinition{Query: query, Display: display}, nil+}++// viewDefinitionFile is a parsed --definition-file. Query or Display is nil+// when the file omits it, meaning "keep the current one". ID and Revision are+// set when the file is a view exported with `view get`.+type viewDefinitionFile struct {+ Query, Display map[string]any+ ID string+ Revision float64+}++// loadViewDefinitionFile reads --definition-file, or returns nil when unset.+func loadViewDefinitionFile(cmd *cobra.Command) (*viewDefinitionFile, error) {+ path, _ := cmd.Flags().GetString("definition-file")+ if path == "" {+ return nil, nil+ }+ return readViewDefinitionFile(path)+}++// checkExportedRevision refuses a file exported from this view at an older+// revision: writing its query/display would undo whatever changed since.+// A file without a revision, or exported from another view, is a template.+func checkExportedRevision(file *viewDefinitionFile, view map[string]any) error {+ if file == nil || file.Revision == 0 || (file.ID != "" && file.ID != strVal(view, "id")) {+ return nil+ }+ if current, _ := view["revision"].(float64); file.Revision != current {+ return fmt.Errorf("--definition-file was exported from view %q at revision %v, but the view is now at revision %v; nothing was saved. Export it again with `multica view get` and redo your edits", strVal(view, "name"), file.Revision, view["revision"])+ }+ return nil+}++func readViewDefinitionFile(path string) (*viewDefinitionFile, error) {+ data, err := os.ReadFile(path)+ if err != nil {+ return nil, fmt.Errorf("read --definition-file: %w", err)+ }+ var doc map[string]json.RawMessage+ if err := json.Unmarshal(data, &doc); err != nil || doc == nil {+ return nil, fmt.Errorf("--definition-file must hold a JSON object with \"query\" and/or \"display\"")+ }+ if raw, ok := doc["definition_version"]; ok {+ var version float64+ if json.Unmarshal(raw, &version) != nil || version != issueViewDefinitionVersion {+ return nil, fmt.Errorf("--definition-file has definition_version %s, but this CLI writes version %d", string(raw), issueViewDefinitionVersion)+ }+ }+ file := &viewDefinitionFile{}+ if raw, ok := doc["id"]; ok {+ if json.Unmarshal(raw, &file.ID) != nil {+ return nil, fmt.Errorf("--definition-file: \"id\" must be a string")+ }+ }+ if raw, ok := doc["revision"]; ok {+ if json.Unmarshal(raw, &file.Revision) != nil || file.Revision < 1 {+ return nil, fmt.Errorf("--definition-file: \"revision\" must be a positive number")+ }+ }+ decode := func(key string) (map[string]any, error) {+ raw, ok := doc[key]+ if !ok {+ return nil, nil+ }+ var object map[string]any+ if json.Unmarshal(raw, &object) != nil || object == nil {+ return nil, fmt.Errorf("--definition-file: %q must be a JSON object", key)+ }+ return object, nil+ }+ if file.Query, err = decode("query"); err != nil {+ return nil, err+ }+ if file.Display, err = decode("display"); err != nil {+ return nil, err+ }+ if file.Query == nil && file.Display == nil {+ return nil, fmt.Errorf("--definition-file has neither \"query\" nor \"display\"")+ }+ return file, nil+}++func anyFlagChanged(cmd *cobra.Command, names []string) bool {+ for _, name := range names {+ if flag := cmd.Flags().Lookup(name); flag != nil && flag.Changed {+ return true+ }+ }+ return false+}++// viewDefinitionChanged reports whether any flag touches the definition.+func viewDefinitionChanged(cmd *cobra.Command) bool {+ return anyFlagChanged(cmd, viewFilterFlags) || anyFlagChanged(cmd, viewDisplayFlags) ||+ anyFlagChanged(cmd, []string{"definition-file", "clear-filters"})+}++// viewFlagValues reads a repeatable list flag, splitting comma-separated+// values. An empty value yields an empty list, which clears the filter.+func viewFlagValues(cmd *cobra.Command, name string) []string {+ raw, _ := cmd.Flags().GetStringArray(name)+ values := []string{}+ for _, item := range raw {+ for _, part := range strings.Split(item, ",") {+ if part = strings.TrimSpace(part); part != "" && !slices.Contains(values, part) {+ values = append(values, part)+ }+ }+ }+ return values+}++func checkViewEnum(flag string, values []string, allowed []string) error {+ for _, value := range values {+ if !slices.Contains(allowed, value) {+ return fmt.Errorf("invalid --%s %q; valid values: %s", flag, value, strings.Join(allowed, ", "))+ }+ }+ return nil+}++// matchNamedID resolves a ref against candidates by full ID, exact name+// (case-insensitive), then ID prefix.+func matchNamedID(kind, ref string, candidates []idCandidate) (idCandidate, error) {+ ref = strings.TrimSpace(ref)+ var named []idCandidate+ for _, c := range candidates {+ if c.ID == "" {+ continue+ }+ if strings.EqualFold(c.ID, ref) {+ return c, nil+ }+ if strings.EqualFold(strings.TrimSpace(c.Display), ref) {+ named = append(named, c)+ }+ }+ switch len(named) {+ case 1:+ return named[0], nil+ case 0:+ default:+ return idCandidate{}, fmt.Errorf("more than one %s is named %q; pass its ID:\n%s", kind, ref, joinCandidateIDs(named))+ }+ prefix, err := normalizeUUIDPrefix(ref)+ if err != nil {+ return idCandidate{}, fmt.Errorf("no %s named %q", kind, ref)+ }+ var matches []idCandidate+ for _, c := range candidates {+ if c.ID != "" && strings.HasPrefix(compactUUID(c.ID), prefix) {+ matches = append(matches, c)+ }+ }+ switch len(matches) {+ case 0:+ return idCandidate{}, fmt.Errorf("no %s named or matching ID prefix %q", kind, ref)+ case 1:+ return matches[0], nil+ default:+ return idCandidate{}, ambiguousIDPrefixError(kind, ref, matches)+ }+}++func resolveNamedProject(ctx context.Context, client *cli.APIClient, ref string) (idCandidate, error) {+ candidates, err := fetchProjectCandidates(ctx, client)+ if err != nil {+ return idCandidate{}, fmt.Errorf("resolve project: %w", err)+ }+ return matchNamedID("project", ref, candidates)+}++// viewDefinitionBuilder applies the filter and display flags to a definition,+// fetching each catalog it needs at most once.+type viewDefinitionBuilder struct {+ ctx context.Context+ client *cli.APIClient+ cmd *cobra.Command+ properties []propertyDTO+ loaded bool+ members memberDirectory+}++func (b *viewDefinitionBuilder) propertyCatalog() ([]propertyDTO, error) {+ if !b.loaded {+ properties, err := fetchProperties(b.ctx, b.client)+ if err != nil {+ return nil, err+ }+ b.properties, b.loaded = properties, true+ }+ return b.properties, nil+}++// propertyKey resolves "property:<name-or-id>" to "property:<id>" for a+// property of one of the given types.+func (b *viewDefinitionBuilder) propertyKey(flag, value string, types []string) (string, error) {+ ref := strings.TrimPrefix(value, "property:")+ properties, err := b.propertyCatalog()+ if err != nil {+ return "", err+ }+ property, err := resolvePropertyRef(properties, ref)+ if err != nil {+ return "", err+ }+ if property.Archived {+ return "", fmt.Errorf("--%s: property %q is archived; restore it first with `multica property unarchive`", flag, property.Name)+ }+ if !slices.Contains(types, property.Type) {+ return "", fmt.Errorf("--%s: %s property %q cannot be used here; allowed property types: %s", flag, property.Type, property.Name, strings.Join(types, ", "))+ }+ return "property:" + property.ID, nil+}++func (b *viewDefinitionBuilder) actors(flag string, kinds assigneeKinds) ([]any, error) {+ refs := viewFlagValues(b.cmd, flag)+ actors := make([]any, 0, len(refs))+ for _, ref := range refs {+ actorType, id, err := resolveAssignee(b.ctx, b.client, ref, kinds)+ if err != nil {+ return nil, fmt.Errorf("--%s: %w", flag, err)+ }+ actors = append(actors, map[string]any{"type": actorType, "id": id})+ }+ return actors, nil+}++func (b *viewDefinitionBuilder) changed(name string) bool {+ flag := b.cmd.Flags().Lookup(name)+ return flag != nil && flag.Changed+}++func (b *viewDefinitionBuilder) applyFilters(query map[string]any, scopeType string) error {+ cmd := b.cmd+ if anyFlagChanged(cmd, viewFlatFilterFlags) {+ if tree, ok := query["advancedFilter"]; ok && tree != nil {+ return fmt.Errorf("this view filters with an advanced condition tree, which the filter flags cannot edit; add --clear-filters to replace its filters, or edit query.advancedFilter through --definition-file")+ }+ }+ if scopeType == "project" && anyFlagChanged(cmd, []string{"project-filter", "include-no-project"}) {+ return fmt.Errorf("--project-filter and --include-no-project do not apply to a project view, which always shows its own project")+ }+ if scopeType == "my" && b.changed("relation") {+ return fmt.Errorf("--relation does not apply to a my view; its scope variant sets how you relate to the issues")+ }++ if b.changed("status") {+ refs := viewFlagValues(cmd, "status")+ keys := make([]any, 0, len(refs))+ if len(refs) > 0 {+ statuses, err := fetchIssueStatuses(b.ctx, b.client, true)+ if err != nil {+ return err+ }+ for _, ref := range refs {+ status, err := resolveIssueStatusRef(statuses, ref)+ if err != nil {+ return fmt.Errorf("--status: %w", err)+ }+ keys = append(keys, status.Key)+ }+ }+ query["statusFilters"] = keys+ }+ enumLists := []struct {+ flag, key string+ allowed []string+ }{+ {"priority", "priorityFilters", validIssuePriorities},+ {"project-status", "projectStatusFilters", validProjectStatuses},+ {"relation", "relationFilters", viewRelations},+ {"due", "dueDateFilters", viewDueDates},+ }+ for _, list := range enumLists {+ if !b.changed(list.flag) {+ continue+ }+ values := viewFlagValues(cmd, list.flag)+ if err := checkViewEnum(list.flag, values, list.allowed); err != nil {+ return err+ }+ query[list.key] = values+ }+ if b.changed("assignee") {+ actors, err := b.actors("assignee", issueAssigneeKinds)+ if err != nil {+ return err+ }+ query["assigneeFilters"] = actors+ }+ if b.changed("creator") {+ actors, err := b.actors("creator", memberOrAgentKinds)+ if err != nil {+ return err+ }+ query["creatorFilters"] = actors+ }+ namedLists := []struct {+ flag, key, kind string+ fetch func(context.Context, *cli.APIClient) ([]idCandidate, error)+ }{+ {"project-filter", "projectFilters", "project", fetchProjectCandidates},+ {"label", "labelFilters", "label", func(ctx context.Context, client *cli.APIClient) ([]idCandidate, error) {+ return fetchLabelCandidates(ctx, client, "issue")+ }},+ }+ for _, list := range namedLists {+ if !b.changed(list.flag) {+ continue+ }+ refs := viewFlagValues(cmd, list.flag)+ ids := make([]any, 0, len(refs))+ if len(refs) > 0 {+ candidates, err := list.fetch(b.ctx, b.client)+ if err != nil {+ return fmt.Errorf("resolve %s: %w", list.kind, err)+ }+ for _, ref := range refs {+ match, err := matchNamedID(list.kind, ref, candidates)+ if err != nil {+ return fmt.Errorf("--%s: %w", list.flag, err)+ }+ ids = append(ids, match.ID)+ }+ }+ query[list.key] = ids+ }+ if b.changed("property") {+ raw, _ := cmd.Flags().GetStringArray("property")+ pairs := make([]string, 0, len(raw))+ for _, pair := range raw {+ if strings.TrimSpace(pair) != "" {+ pairs = append(pairs, pair)+ }+ }+ filters := map[string]any{}+ if len(pairs) > 0 {+ properties, err := b.propertyCatalog()+ if err != nil {+ return err+ }+ encoded, err := buildPropertiesFilterQueryParam(b.ctx, b.client, &b.members, properties, pairs)+ if err != nil {+ return err+ }+ if err := json.Unmarshal([]byte(encoded), &filters); err != nil {+ return fmt.Errorf("encode --property: %w", err)+ }+ }+ query["propertyFilters"] = filters+ }+ if b.changed("negate") {+ values := viewFlagValues(cmd, "negate")+ if err := checkViewEnum("negate", values, viewNegatableFlagNames()); err != nil {+ return err+ }+ dimensions := []any{}+ for _, d := range viewNegatableDimensions {+ if slices.Contains(values, d.flag) {+ dimensions = append(dimensions, d.dimension)+ }+ }+ query["negatedFilters"] = dimensions+ }+ for _, flag := range []struct{ name, key string }{+ {"include-no-assignee", "includeNoAssignee"},+ {"include-no-project", "includeNoProject"},+ {"unread", "unreadFilter"},+ } {+ if b.changed(flag.name) {+ value, _ := cmd.Flags().GetBool(flag.name)+ query[flag.key] = value+ }+ }+ running, _ := cmd.Flags().GetBool("agent-running")+ idle, _ := cmd.Flags().GetBool("agent-idle")+ if running && idle {+ return fmt.Errorf("--agent-running and --agent-idle cannot both be set")+ }+ if b.changed("agent-running") {+ query["agentRunningFilter"] = running+ if running {+ query["agentIdleFilter"] = false+ }+ }+ if b.changed("agent-idle") {+ query["agentIdleFilter"] = idle+ if idle {+ query["agentRunningFilter"] = false+ }+ }+ return nil+}++func (b *viewDefinitionBuilder) applyDisplay(display map[string]any) error {+ cmd := b.cmd+ enums := []struct {+ flag, key string+ allowed []string+ // propertyTypes, when set, also allows property:<name> of these types.+ propertyTypes []string+ }{+ {"view-mode", "viewMode", viewModes, nil},+ {"grouping", "grouping", viewGroupings, []string{"select"}},+ {"table-grouping", "tableGrouping", viewTableGroupings, []string{"select", "checkbox"}},+ {"swimlane-grouping", "swimlaneGrouping", viewSwimlaneGroupings, nil},+ {"gantt-zoom", "ganttZoom", viewGanttZooms, nil},+ }+ for _, e := range enums {+ if !b.changed(e.flag) {+ continue+ }+ value, _ := cmd.Flags().GetString(e.flag)+ value = strings.TrimSpace(value)+ if e.propertyTypes != nil && strings.HasPrefix(value, "property:") {+ key, err := b.propertyKey(e.flag, value, e.propertyTypes)+ if err != nil {+ return err+ }+ display[e.key] = key+ continue+ }+ if err := checkViewEnum(e.flag, []string{value}, e.allowed); err != nil {+ return err+ }+ display[e.key] = value+ }++ if b.changed("sort") {+ value, _ := cmd.Flags().GetString("sort")+ value = strings.TrimSpace(value)+ if strings.HasPrefix(value, "property:") {+ properties, err := b.propertyCatalog()+ if err != nil {+ return err+ }+ property, err := resolveSortableProperty(properties, strings.TrimPrefix(value, "property:"))+ if err != nil {+ return err+ }+ value = "property:" + property.ID+ } else if err := checkViewEnum("sort", []string{value}, viewSortFields); err != nil {+ return err+ }+ display["sortBy"] = value+ if !b.changed("direction") {+ direction := "asc"+ if value == "created_at" || value == "updated_at" {+ direction = "desc"+ }+ display["sortDirection"] = direction+ }+ }+ if b.changed("direction") {+ value, _ := cmd.Flags().GetString("direction")+ value = strings.ToLower(strings.TrimSpace(value))+ if err := checkViewEnum("direction", []string{value}, []string{"asc", "desc"}); err != nil {+ return err+ }+ display["sortDirection"] = value+ }+ if b.changed("show-sub-issues") {+ value, _ := cmd.Flags().GetBool("show-sub-issues")+ display["showSubIssues"] = value+ }++ // Manual order is one shared position sequence per status column, so the+ // client only honours it under status grouping.+ if anyFlagChanged(cmd, []string{"sort", "grouping"}) {+ grouping, ok := display["grouping"].(string)+ if !ok {+ grouping = "status"+ }+ if sortBy, _ := display["sortBy"].(string); sortBy == "position" && grouping != "status" {+ return fmt.Errorf("--sort position (manual order) needs status grouping, but the view groups by %s", grouping)+ }+ }+ return nil+}++// buildViewDefinition layers file (--definition-file, may be nil),+// --clear-filters and the filter and display flags over base, in that order.+func buildViewDefinition(ctx context.Context, client *cli.APIClient, cmd *cobra.Command, base issueViewDefinition, file *viewDefinitionFile, scopeType string) (issueViewDefinition, error) {+ def := base+ if file != nil {+ if file.Query != nil {+ def.Query = file.Query+ }+ if file.Display != nil {+ def.Display = file.Display+ }+ }+ if clear, _ := cmd.Flags().GetBool("clear-filters"); clear {+ def.Query = map[string]any{}+ }+ builder := &viewDefinitionBuilder{ctx: ctx, client: client, cmd: cmd}+ if err := builder.applyFilters(def.Query, scopeType); err != nil {+ return def, err+ }+ if err := builder.applyDisplay(def.Display); err != nil {+ return def, err+ }+ return def, nil+}++func validateViewName(name string) (string, error) {+ name = strings.TrimSpace(name)+ if n := utf8.RuneCountInString(name); n < 1 || n > issueViewNameMaxLen {+ return "", fmt.Errorf("view name must be between 1 and %d characters", issueViewNameMaxLen)+ }+ return name, nil+}++func validateViewScopeVariant(scopeType, variant string) error {+ allowed := viewScopeVariants[scopeType]+ if !slices.Contains(allowed, variant) {+ return fmt.Errorf("invalid --scope-variant %q for a %s view; valid values: %s", variant, scopeType, strings.Join(allowed, ", "))+ }+ return nil+}++func validateViewVisibility(scopeType, visibility string) error {+ if err := checkViewEnum("visibility", []string{visibility}, viewVisibilities); err != nil {+ return err+ }+ if scopeType == "my" && visibility != "private" {+ return fmt.Errorf("my views are always private")+ }+ return nil+}++func printViewDryRun(method, path string, body map[string]any) error {+ fmt.Fprintf(os.Stderr, "Dry run: %s %s was not sent.\n", method, path)+ return cli.PrintJSON(os.Stdout, body)+}++func printWrittenView(ctx context.Context, cmd *cobra.Command, client *cli.APIClient, view map[string]any) error {+ if output, _ := cmd.Flags().GetString("output"); output == "table" {+ actors := loadActorDisplayLookup(ctx, client)+ cli.PrintTable(os.Stdout, []string{"ID", "NAME", "SCOPE", "VISIBILITY", "OWNER", "REVISION"}, [][]string{{+ strVal(view, "id"),+ strVal(view, "name"),+ viewScopeLabel(view, true),+ strVal(view, "visibility"),+ actors.actor("member", strVal(view, "owner_id")),+ fmt.Sprintf("%v", view["revision"]),+ }})+ return nil+ }+ return cli.PrintJSON(os.Stdout, view)+}++// viewWriteError turns the server's permission and revision refusals into+// guidance; anything else passes through.+func viewWriteError(action string, view map[string]any, err error) error {+ var httpErr *cli.HTTPError+ if errors.As(err, &httpErr) {+ switch httpErr.StatusCode {+ case http.StatusForbidden:+ return fmt.Errorf("%s view %q: only the owner can change a private view, and only the owner or a workspace owner/admin a shared one", action, strVal(view, "name"))+ case http.StatusConflict:+ return fmt.Errorf("%s view %q: it changed since it was read (revision %v), so nothing was saved; re-run to apply your change to the latest version", action, strVal(view, "name"), view["revision"])+ }+ }+ return fmt.Errorf("%s view: %w", action, err)+}++// starViewInSidebar adds a view to the user's sidebar the way the app does+// after creating one. A sidebar the user never arranged already lists their+// own views, so it is only written once it has a saved order.+func starViewInSidebar(ctx context.Context, client *cli.APIClient, viewID string) error {+ var pref struct {+ Prefs map[string]any `json:"prefs"`+ UpdatedAt string `json:"updated_at"`+ }+ if err := client.GetJSON(ctx, "/api/issue-view-preferences?"+url.Values{"scope_type": {"sidebar"}}.Encode(), &pref); err != nil {+ return err+ }+ if pref.UpdatedAt == "" {+ return nil+ }+ if pref.Prefs == nil {+ pref.Prefs = map[string]any{}+ }+ item := "view:" + viewID+ order, _ := pref.Prefs["order"].([]any)+ if slices.Contains(order, any(item)) {+ return nil+ }+ pref.Prefs["order"] = append(order, item)+ if _, ok := pref.Prefs["hidden"]; !ok {+ pref.Prefs["hidden"] = []any{}+ }+ return client.PutJSON(ctx, "/api/issue-view-preferences", map[string]any{+ "scope_type": "sidebar",+ "prefs": pref.Prefs,+ }, nil)+}++func createIssueViewAndStar(ctx context.Context, cmd *cobra.Command, client *cli.APIClient, body map[string]any) error {+ if dryRun, _ := cmd.Flags().GetBool("dry-run"); dryRun {+ return printViewDryRun(http.MethodPost, "/api/issue-views", body)+ }+ var created map[string]any+ if err := client.PostJSON(ctx, "/api/issue-views", body, &created); err != nil {+ return fmt.Errorf("create view: %w", err)+ }+ if err := starViewInSidebar(ctx, client, strVal(created, "id")); err != nil {+ fmt.Fprintf(os.Stderr, "Warning: view created, but adding it to your sidebar failed: %v\n", err)+ }+ return printWrittenView(ctx, cmd, client, created)+}++func runViewCreate(cmd *cobra.Command, _ []string) error {+ rawName, _ := cmd.Flags().GetString("name")+ name, err := validateViewName(rawName)+ if err != nil {+ return fmt.Errorf("--name: %w", err)+ }+ client, err := newAPIClient(cmd)+ if err != nil {+ return err+ }+ if client.WorkspaceID == "" {+ return fmt.Errorf("workspace_id is required to create a view")+ }+ ctx, cancel := cli.APIContext(context.Background())+ defer cancel()++ scope, _ := cmd.Flags().GetString("scope")+ projectRef, _ := cmd.Flags().GetString("project")+ if scope == "" {+ scope = "workspace"+ if projectRef != "" {+ scope = "project"+ }+ }+ if _, ok := viewScopeVariants[scope]; !ok {+ return fmt.Errorf("invalid --scope %q; valid values: workspace, my, project", scope)+ }+ body := map[string]any{+ "name": name,+ "scope_type": scope,+ "definition_version": issueViewDefinitionVersion,+ }+ switch {+ case scope == "project" && projectRef == "":+ return fmt.Errorf("--project is required for a project view")+ case scope != "project" && projectRef != "":+ return fmt.Errorf("--project names the project of a project view; it cannot be combined with --scope %s (to filter by project, use --project-filter)", scope)+ case scope == "project":+ project, err := resolveNamedProject(ctx, client, projectRef)+ if err != nil {+ return fmt.Errorf("--project: %w", err)+ }+ body["scope_id"] = project.ID+ }+ variant, _ := cmd.Flags().GetString("scope-variant")+ if variant == "" {+ variant = viewScopeVariants[scope][0]+ }+ if err := validateViewScopeVariant(scope, variant); err != nil {+ return err+ }+ body["scope_variant"] = variant+ visibility, _ := cmd.Flags().GetString("visibility")+ if scope == "my" && !cmd.Flags().Changed("visibility") {+ visibility = "private"+ }+ if err := validateViewVisibility(scope, visibility); err != nil {+ return err+ }+ body["visibility"] = visibility++ file, err := loadViewDefinitionFile(cmd)+ if err != nil {+ return err+ }+ def, err := buildViewDefinition(ctx, client, cmd, issueViewDefinition{Query: map[string]any{}, Display: map[string]any{}}, file, scope)+ if err != nil {+ return err+ }+ body["query"], body["display"] = def.Query, def.Display+ return createIssueViewAndStar(ctx, cmd, client, body)+}++func runViewDuplicate(cmd *cobra.Command, args []string) error {+ client, err := newAPIClient(cmd)+ if err != nil {+ return err+ }+ ctx, cancel := cli.APIContext(context.Background())+ defer cancel()++ source, err := resolveIssueView(ctx, client, args[0])+ if err != nil {+ return fmt.Errorf("resolve view: %w", err)+ }+ base, err := definitionOfView(source)+ if err != nil {+ return err+ }+ scope := strVal(source, "scope_type")+ name, _ := cmd.Flags().GetString("name")+ if !cmd.Flags().Changed("name") {+ name = strVal(source, "name") + " (copy)"+ if runes := []rune(name); len(runes) > issueViewNameMaxLen {+ name = string(runes[:issueViewNameMaxLen])+ }+ }+ if name, err = validateViewName(name); err != nil {+ return fmt.Errorf("--name: %w", err)+ }+ visibility, _ := cmd.Flags().GetString("visibility")+ if err := validateViewVisibility(scope, visibility); err != nil {+ return err+ }+ body := map[string]any{+ "name": name,+ "scope_type": scope,+ "scope_variant": source["scope_variant"],+ "visibility": visibility,+ "definition_version": issueViewDefinitionVersion,+ }+ if scope == "project" {+ body["scope_id"] = source["scope_id"]+ }+ file, err := loadViewDefinitionFile(cmd)+ if err != nil {+ return err+ }+ def, err := buildViewDefinition(ctx, client, cmd, base, file, scope)+ if err != nil {+ return err+ }+ body["query"], body["display"] = def.Query, def.Display+ return createIssueViewAndStar(ctx, cmd, client, body)+}++func runViewUpdate(cmd *cobra.Command, args []string) error {+ client, err := newAPIClient(cmd)+ if err != nil {+ return err+ }+ ctx, cancel := cli.APIContext(context.Background())+ defer cancel()++ view, err := resolveIssueView(ctx, client, args[0])+ if err != nil {+ return fmt.Errorf("resolve view: %w", err)+ }+ scope := strVal(view, "scope_type")+ patch := map[string]any{"expected_revision": view["revision"]}+ if cmd.Flags().Changed("name") {+ rawName, _ := cmd.Flags().GetString("name")+ name, err := validateViewName(rawName)+ if err != nil {+ return fmt.Errorf("--name: %w", err)+ }+ patch["name"] = name+ }+ if cmd.Flags().Changed("visibility") {+ visibility, _ := cmd.Flags().GetString("visibility")+ if err := validateViewVisibility(scope, visibility); err != nil {+ return err+ }+ patch["visibility"] = visibility+ }+ if cmd.Flags().Changed("scope-variant") {+ variant, _ := cmd.Flags().GetString("scope-variant")+ if err := validateViewScopeVariant(scope, variant); err != nil {+ return err+ }+ patch["scope_variant"] = variant+ }+ if viewDefinitionChanged(cmd) {+ base, err := definitionOfView(view)+ if err != nil {+ return err+ }+ file, err := loadViewDefinitionFile(cmd)+ if err != nil {+ return err+ }+ // After this check the file's revision is the one sent as+ // expected_revision, so a change landing before the write is a 409.+ if err := checkExportedRevision(file, view); err != nil {+ return err+ }+ def, err := buildViewDefinition(ctx, client, cmd, base, file, scope)+ if err != nil {+ return err+ }+ patch["query"], patch["display"] = def.Query, def.Display+ patch["definition_version"] = issueViewDefinitionVersion+ }+ if len(patch) == 1 {+ return fmt.Errorf("nothing to update; pass at least one flag (see `multica view update --help`)")+ }++ path := "/api/issue-views/" + url.PathEscape(strVal(view, "id"))+ if dryRun, _ := cmd.Flags().GetBool("dry-run"); dryRun {+ return printViewDryRun(http.MethodPatch, path, patch)+ }+ var updated map[string]any+ if err := client.PatchJSON(ctx, path, patch, &updated); err != nil {+ return viewWriteError("update", view, err)+ }+ return printWrittenView(ctx, cmd, client, updated)+}++func runViewDelete(cmd *cobra.Command, args []string) error {+ client, err := newAPIClient(cmd)+ if err != nil {+ return err+ }+ ctx, cancel := cli.APIContext(context.Background())+ defer cancel()++ view, err := resolveIssueView(ctx, client, args[0])+ if err != nil {+ return fmt.Errorf("resolve view: %w", err)+ }+ id := strVal(view, "id")+ if err := client.DeleteJSON(ctx, "/api/issue-views/"+url.PathEscape(id)); err != nil {+ return viewWriteError("delete", view, err)+ }+ if output, _ := cmd.Flags().GetString("output"); output == "json" {+ return cli.PrintJSON(os.Stdout, map[string]any{"id": id, "deleted": true})+ }+ fmt.Fprintf(os.Stdout, "View %q deleted.\n", strVal(view, "name"))+ return nil+}diff --git a/server/cmd/multica/cmd_view_write_test.go b/server/cmd/multica/cmd_view_write_test.gonew file mode 100644index 0000000000..41d5f284d0--- /dev/null+++ b/server/cmd/multica/cmd_view_write_test.go@@ -0,0 +1,533 @@+package main++import (+ "encoding/json"+ "net/http"+ "net/http/httptest"+ "os"+ "path/filepath"+ "reflect"+ "strings"+ "sync"+ "testing"++ "github.com/spf13/cobra"+)++const (+ testViewWriteLabelUUID = "1abe1000-0000-0000-0000-000000000001"+ testViewWriteProjectUUID = "9a0e0000-0000-0000-0000-000000000001"+ testViewWriteMemberUUID = "3e3be000-0000-0000-0000-000000000001"+ testViewWriteAgentUUID = "a6e17000-0000-0000-0000-000000000001"+ testViewWriteViewUUID = "6d000000-0000-0000-0000-000000000004"+)++type viewWriteRequest struct {+ method, path string+ body map[string]any+}++// viewWriteServer serves the catalogs view flags resolve against and one+// stored view, and records every write. view and sidebar are what the+// server returns for the stored view and the sidebar preference.+type viewWriteServer struct {+ mu sync.Mutex+ writes []viewWriteRequest+ view map[string]any+ sidebar map[string]any+ writeStatus int+}++func (s *viewWriteServer) recorded(method string) []viewWriteRequest {+ s.mu.Lock()+ defer s.mu.Unlock()+ var out []viewWriteRequest+ for _, w := range s.writes {+ if w.method == method {+ out = append(out, w)+ }+ }+ return out+}++func newViewWriteServer(t *testing.T) *viewWriteServer {+ t.Helper()+ s := &viewWriteServer{+ view: map[string]any{+ "id": testViewWriteViewUUID, "name": "Bugs", "scope_type": "workspace", "scope_id": nil,+ "scope_variant": nil, "visibility": "private", "owner_id": testViewWriteMemberUUID,+ "definition_version": 1, "revision": 3,+ "query": map[string]any{+ "statusFilters": []any{"todo"}, "labelFilters": []any{testViewWriteLabelUUID},+ "futureKey": "kept",+ },+ "display": map[string]any{"viewMode": "board", "cardProperties": map[string]any{"labels": true}},+ },+ sidebar: map[string]any{+ "scope_type": "sidebar",+ "prefs": map[string]any{"order": []any{"builtin:my_issues"}, "hidden": []any{}},+ "updated_at": "2026-11-01T00:00:00Z",+ },+ }+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ write := func(v any) { _ = json.NewEncoder(w).Encode(v) }+ switch {+ case r.Method == http.MethodGet && r.URL.Path == "/api/issue-statuses":+ write(map[string]any{"statuses": []any{+ map[string]any{"id": "s1", "key": "todo", "name": "Todo"},+ map[string]any{"id": "s2", "key": "in_review", "name": "In Review"},+ map[string]any{"id": "s3", "key": "qa", "name": "Waiting for QA"},+ }})+ case r.Method == http.MethodGet && r.URL.Path == "/api/labels":+ write(map[string]any{"labels": []any{map[string]any{"id": testViewWriteLabelUUID, "name": "Bug"}}})+ case r.Method == http.MethodGet && r.URL.Path == "/api/projects":+ write(map[string]any{"projects": []any{map[string]any{"id": testViewWriteProjectUUID, "title": "Website"}}})+ case r.Method == http.MethodGet && r.URL.Path == "/api/workspaces/ws-1/members":+ write([]any{map[string]any{"user_id": testViewWriteMemberUUID, "name": "Bohan", "email": "[email protected]"}})+ case r.Method == http.MethodGet && r.URL.Path == "/api/agents":+ write([]any{map[string]any{"id": testViewWriteAgentUUID, "name": "Lambda"}})+ case r.Method == http.MethodGet && r.URL.Path == "/api/squads":+ write([]any{})+ case r.Method == http.MethodGet && r.URL.Path == "/api/properties":+ write(map[string]any{"properties": []any{+ map[string]any{"id": "p-sev", "name": "Severity", "type": "select", "config": map[string]any{+ "options": []any{map[string]any{"id": "opt-high", "name": "High"}},+ }},+ map[string]any{"id": "p-notes", "name": "Notes", "type": "text"},+ }})+ case r.Method == http.MethodGet && r.URL.Path == "/api/issue-views" && r.URL.Query().Get("scope_type") == "all":+ write([]any{s.view})+ case r.Method == http.MethodGet && r.URL.Path == "/api/issue-views/"+testViewWriteViewUUID:+ write(s.view)+ case r.Method == http.MethodGet && r.URL.Path == "/api/issue-view-preferences":+ write(s.sidebar)+ case r.Method == http.MethodPost || r.Method == http.MethodPatch || r.Method == http.MethodPut || r.Method == http.MethodDelete:+ var body map[string]any+ _ = json.NewDecoder(r.Body).Decode(&body)+ s.mu.Lock()+ s.writes = append(s.writes, viewWriteRequest{method: r.Method, path: r.URL.Path, body: body})+ s.mu.Unlock()+ if s.writeStatus != 0 && r.URL.Path != "/api/issue-view-preferences" {+ w.WriteHeader(s.writeStatus)+ write(map[string]any{"error": "refused"})+ return+ }+ switch r.Method {+ case http.MethodPost:+ w.WriteHeader(http.StatusCreated)+ created := map[string]any{"id": "6e000000-0000-0000-0000-000000000005", "revision": 1}+ for k, v := range body {+ created[k] = v+ }+ write(created)+ case http.MethodDelete:+ w.WriteHeader(http.StatusNoContent)+ default:+ write(body)+ }+ default:+ t.Errorf("unexpected request %s %s", r.Method, r.URL.String())+ w.WriteHeader(http.StatusNotFound)+ }+ }))+ t.Cleanup(srv.Close)+ setCLITestServerEnv(t, srv.URL)+ return s+}++func newViewWriteTestCmd(t *testing.T, use string, flags map[string][]string) *cobra.Command {+ t.Helper()+ cmd := &cobra.Command{Use: use}+ switch use {+ case "create":+ cmd.Flags().String("name", "", "")+ cmd.Flags().String("scope", "", "")+ cmd.Flags().String("project", "", "")+ cmd.Flags().String("scope-variant", "", "")+ cmd.Flags().String("visibility", "private", "")+ addViewDefinitionFlags(cmd, false)+ case "update":+ cmd.Flags().String("name", "", "")+ cmd.Flags().String("scope-variant", "", "")+ cmd.Flags().String("visibility", "", "")+ addViewDefinitionFlags(cmd, true)+ case "duplicate":+ cmd.Flags().String("name", "", "")+ cmd.Flags().String("visibility", "private", "")+ addViewDefinitionFlags(cmd, true)+ }+ cmd.Flags().String("output", "json", "")+ for name, values := range flags {+ for _, value := range values {+ if err := cmd.Flags().Set(name, value); err != nil {+ t.Fatalf("set --%s=%s: %v", name, value, err)+ }+ }+ }+ return cmd+}++func TestViewCreateResolvesNamesAndStarsTheView(t *testing.T) {+ srv := newViewWriteServer(t)+ cmd := newViewWriteTestCmd(t, "create", map[string][]string{+ "name": {"Open bugs"},+ "project": {"website"},+ "status": {"Todo", "in_review,qa"},+ "negate": {"status"},+ "label": {"bug"},+ "assignee": {"Bohan", "Lambda"},+ "priority": {"urgent"},+ "property": {"Severity=High"},+ "view-mode": {"table"},+ "sort": {"title"},+ "agent-running": {"true"},+ "show-sub-issues": {"false"},+ })+ if _, err := captureStdout(t, func() error { return runViewCreate(cmd, nil) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ posts := srv.recorded(http.MethodPost)+ if len(posts) != 1 || posts[0].path != "/api/issue-views" {+ t.Fatalf("posts = %+v", posts)+ }+ body := posts[0].body+ if body["name"] != "Open bugs" || body["scope_type"] != "project" || body["scope_id"] != testViewWriteProjectUUID ||+ body["scope_variant"] != "all" || body["visibility"] != "private" || body["definition_version"] != float64(1) {+ t.Fatalf("view fields = %v", body)+ }+ wantQuery := map[string]any{+ "statusFilters": []any{"todo", "in_review", "qa"},+ "negatedFilters": []any{"status"},+ "labelFilters": []any{testViewWriteLabelUUID},+ "priorityFilters": []any{"urgent"},+ "propertyFilters": map[string]any{"p-sev": []any{"opt-high"}},+ "agentRunningFilter": true,+ "agentIdleFilter": false,+ "assigneeFilters": []any{+ map[string]any{"type": "member", "id": testViewWriteMemberUUID},+ map[string]any{"type": "agent", "id": testViewWriteAgentUUID},+ },+ }+ if !reflect.DeepEqual(body["query"], wantQuery) {+ t.Fatalf("query = %v\nwant %v", body["query"], wantQuery)+ }+ wantDisplay := map[string]any{"viewMode": "table", "sortBy": "title", "sortDirection": "asc", "showSubIssues": false}+ if !reflect.DeepEqual(body["display"], wantDisplay) {+ t.Fatalf("display = %v\nwant %v", body["display"], wantDisplay)+ }+ puts := srv.recorded(http.MethodPut)+ if len(puts) != 1 {+ t.Fatalf("sidebar writes = %d, want 1", len(puts))+ }+ prefs, _ := puts[0].body["prefs"].(map[string]any)+ if order, _ := prefs["order"].([]any); !reflect.DeepEqual(order, []any{"builtin:my_issues", "view:6e000000-0000-0000-0000-000000000005"}) {+ t.Fatalf("sidebar order = %v", prefs["order"])+ }+}++func TestViewCreateLeavesAnUnarrangedSidebarAlone(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.sidebar = map[string]any{"scope_type": "sidebar", "prefs": map[string]any{}, "updated_at": ""}+ cmd := newViewWriteTestCmd(t, "create", map[string][]string{"name": {"Mine"}, "scope": {"my"}})+ if _, err := captureStdout(t, func() error { return runViewCreate(cmd, nil) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ posts := srv.recorded(http.MethodPost)+ if len(posts) != 1 || posts[0].body["scope_variant"] != "any" || posts[0].body["visibility"] != "private" {+ t.Fatalf("posts = %+v", posts)+ }+ if puts := srv.recorded(http.MethodPut); len(puts) != 0 {+ t.Fatalf("an unarranged sidebar lists the owner's views already; got writes %+v", puts)+ }+}++func TestViewCreateRejectsBadInputBeforeWriting(t *testing.T) {+ for name, flags := range map[string]map[string][]string{+ "missing name": {},+ "bad priority": {"name": {"x"}, "priority": {"highest"}},+ "unknown status": {"name": {"x"}, "status": {"nope"}},+ "unknown label": {"name": {"x"}, "label": {"Feature"}},+ "project filter on project": {"name": {"x"}, "project": {"Website"}, "project-filter": {"Website"}},+ "relation on my view": {"name": {"x"}, "scope": {"my"}, "relation": {"assigned"}},+ "shared my view": {"name": {"x"}, "scope": {"my"}, "visibility": {"workspace"}},+ "bad my variant": {"name": {"x"}, "scope": {"my"}, "scope-variant": {"agents"}},+ "manual order off status": {"name": {"x"}, "grouping": {"assignee"}, "sort": {"position"}},+ "group by text property": {"name": {"x"}, "grouping": {"property:Notes"}},+ "running and idle": {"name": {"x"}, "agent-running": {"true"}, "agent-idle": {"true"}},+ "bad negate": {"name": {"x"}, "negate": {"title"}},+ } {+ t.Run(name, func(t *testing.T) {+ srv := newViewWriteServer(t)+ if err := runViewCreate(newViewWriteTestCmd(t, "create", flags), nil); err == nil {+ t.Fatal("want an error")+ }+ if posts := srv.recorded(http.MethodPost); len(posts) != 0 {+ t.Fatalf("wrote despite the error: %+v", posts)+ }+ })+ }+}++func TestViewCreateDryRunPrintsWithoutWriting(t *testing.T) {+ srv := newViewWriteServer(t)+ cmd := newViewWriteTestCmd(t, "create", map[string][]string{"name": {"Preview"}, "status": {"todo"}, "dry-run": {"true"}})+ out, err := captureStdout(t, func() error { return runViewCreate(cmd, nil) })+ if err != nil {+ t.Fatalf("run: %v", err)+ }+ var body map[string]any+ if err := json.Unmarshal([]byte(out), &body); err != nil {+ t.Fatalf("decode: %v\n%s", err, out)+ }+ if query, _ := body["query"].(map[string]any); !reflect.DeepEqual(query["statusFilters"], []any{"todo"}) {+ t.Fatalf("dry-run body = %v", body)+ }+ if len(srv.recorded(http.MethodPost))+len(srv.recorded(http.MethodPut)) != 0 {+ t.Fatal("dry run wrote")+ }+}++func TestViewUpdateChangesOnlyWhatFlagsName(t *testing.T) {+ srv := newViewWriteServer(t)+ cmd := newViewWriteTestCmd(t, "update", map[string][]string{+ "status": {""},+ "priority": {"high"},+ "grouping": {"assignee"},+ "visibility": {"workspace"},+ })+ if _, err := captureStdout(t, func() error { return runViewUpdate(cmd, []string{"bugs"}) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ patches := srv.recorded(http.MethodPatch)+ if len(patches) != 1 || patches[0].path != "/api/issue-views/"+testViewWriteViewUUID {+ t.Fatalf("patches = %+v", patches)+ }+ body := patches[0].body+ if body["expected_revision"] != float64(3) || body["definition_version"] != float64(1) || body["visibility"] != "workspace" {+ t.Fatalf("patch fields = %v", body)+ }+ if _, ok := body["name"]; ok {+ t.Fatalf("name sent without --name: %v", body)+ }+ wantQuery := map[string]any{+ "statusFilters": []any{},+ "priorityFilters": []any{"high"},+ "labelFilters": []any{testViewWriteLabelUUID},+ "futureKey": "kept",+ }+ if !reflect.DeepEqual(body["query"], wantQuery) {+ t.Fatalf("query = %v\nwant %v", body["query"], wantQuery)+ }+ wantDisplay := map[string]any{"viewMode": "board", "grouping": "assignee", "cardProperties": map[string]any{"labels": true}}+ if !reflect.DeepEqual(body["display"], wantDisplay) {+ t.Fatalf("display = %v\nwant %v", body["display"], wantDisplay)+ }+}++func TestViewUpdateWithoutDefinitionFlagsLeavesTheDefinitionOut(t *testing.T) {+ srv := newViewWriteServer(t)+ cmd := newViewWriteTestCmd(t, "update", map[string][]string{"name": {"Renamed"}})+ if _, err := captureStdout(t, func() error { return runViewUpdate(cmd, []string{"Bugs"}) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ body := srv.recorded(http.MethodPatch)[0].body+ want := map[string]any{"name": "Renamed", "expected_revision": float64(3)}+ if !reflect.DeepEqual(body, want) {+ t.Fatalf("patch = %v, want %v", body, want)+ }+}++func TestViewUpdateAppliesTheDefinitionFileThenFlags(t *testing.T) {+ srv := newViewWriteServer(t)+ path := filepath.Join(t.TempDir(), "view.json")+ if err := os.WriteFile(path, []byte(`{"id":"ignored","definition_version":1,"query":{"unreadFilter":true},"display":{"viewMode":"list"}}`), 0o600); err != nil {+ t.Fatal(err)+ }+ cmd := newViewWriteTestCmd(t, "update", map[string][]string{"definition-file": {path}, "view-mode": {"gantt"}})+ if _, err := captureStdout(t, func() error { return runViewUpdate(cmd, []string{"Bugs"}) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ body := srv.recorded(http.MethodPatch)[0].body+ if !reflect.DeepEqual(body["query"], map[string]any{"unreadFilter": true}) ||+ !reflect.DeepEqual(body["display"], map[string]any{"viewMode": "gantt"}) {+ t.Fatalf("patch = %v", body)+ }+}++func writeViewDefinitionFile(t *testing.T, content string) string {+ t.Helper()+ path := filepath.Join(t.TempDir(), "view.json")+ if err := os.WriteFile(path, []byte(content), 0o600); err != nil {+ t.Fatal(err)+ }+ return path+}++// An export edited after someone else saved the view must not overwrite that+// save: the export's revision is the write's precondition.+func TestViewUpdateRefusesAStaleExportedDefinition(t *testing.T) {+ srv := newViewWriteServer(t)+ path := writeViewDefinitionFile(t, `{"id":"`+testViewWriteViewUUID+`","revision":2,"definition_version":1,"query":{"statusFilters":["todo"]},"display":{"viewMode":"list"}}`)+ err := runViewUpdate(newViewWriteTestCmd(t, "update", map[string][]string{"definition-file": {path}}), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "revision 2") || !strings.Contains(err.Error(), "revision 3") {+ t.Fatalf("err = %v", err)+ }+ if patches := srv.recorded(http.MethodPatch); len(patches) != 0 {+ t.Fatalf("a stale export was written: %+v", patches)+ }+}++func TestViewDefinitionFileRevisionOnlyBindsItsOwnView(t *testing.T) {+ cases := map[string]struct {+ run func(cmd *cobra.Command) error+ use, content string+ method string+ }{+ "current export of this view": {+ use: "update", method: http.MethodPatch,+ content: `{"id":"` + testViewWriteViewUUID + `","revision":3,"display":{"viewMode":"list"}}`,+ },+ "template without a revision": {+ use: "update", method: http.MethodPatch,+ content: `{"display":{"viewMode":"list"}}`,+ },+ "export of another view": {+ use: "update", method: http.MethodPatch,+ content: `{"id":"6f000000-0000-0000-0000-000000000009","revision":1,"display":{"viewMode":"list"}}`,+ },+ "export used to create a new view": {+ use: "create", method: http.MethodPost,+ content: `{"id":"` + testViewWriteViewUUID + `","revision":1,"display":{"viewMode":"list"}}`,+ },+ "export used to duplicate": {+ use: "duplicate", method: http.MethodPost,+ content: `{"id":"` + testViewWriteViewUUID + `","revision":1,"display":{"viewMode":"list"}}`,+ },+ }+ for name, c := range cases {+ t.Run(name, func(t *testing.T) {+ srv := newViewWriteServer(t)+ flags := map[string][]string{"definition-file": {writeViewDefinitionFile(t, c.content)}}+ if c.use == "create" {+ flags["name"] = []string{"From export"}+ }+ cmd := newViewWriteTestCmd(t, c.use, flags)+ _, err := captureStdout(t, func() error {+ switch c.use {+ case "create":+ return runViewCreate(cmd, nil)+ case "duplicate":+ return runViewDuplicate(cmd, []string{"Bugs"})+ default:+ return runViewUpdate(cmd, []string{"Bugs"})+ }+ })+ if err != nil {+ t.Fatalf("run: %v", err)+ }+ writes := srv.recorded(c.method)+ if len(writes) != 1 || !reflect.DeepEqual(writes[0].body["display"], map[string]any{"viewMode": "list"}) {+ t.Fatalf("writes = %+v", writes)+ }+ if c.method == http.MethodPatch && writes[0].body["expected_revision"] != float64(3) {+ t.Fatalf("expected_revision = %v, want 3", writes[0].body["expected_revision"])+ }+ })+ }+}++func TestViewUpdateRefusesWhatItCannotRepresent(t *testing.T) {+ t.Run("advanced tree with flat filters", func(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.view["query"] = map[string]any{"advancedFilter": map[string]any{"type": "group", "match": "all", "children": []any{}}}+ err := runViewUpdate(newViewWriteTestCmd(t, "update", map[string][]string{"status": {"todo"}}), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "--clear-filters") {+ t.Fatalf("err = %v", err)+ }+ if len(srv.recorded(http.MethodPatch)) != 0 {+ t.Fatal("wrote despite the error")+ }+ })+ t.Run("advanced tree replaced by clear-filters", func(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.view["query"] = map[string]any{"advancedFilter": map[string]any{"type": "group", "match": "all", "children": []any{}}}+ cmd := newViewWriteTestCmd(t, "update", map[string][]string{"status": {"todo"}, "clear-filters": {"true"}})+ if _, err := captureStdout(t, func() error { return runViewUpdate(cmd, []string{"Bugs"}) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ if query := srv.recorded(http.MethodPatch)[0].body["query"]; !reflect.DeepEqual(query, map[string]any{"statusFilters": []any{"todo"}}) {+ t.Fatalf("query = %v", query)+ }+ })+ t.Run("newer definition version", func(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.view["definition_version"] = 2+ err := runViewUpdate(newViewWriteTestCmd(t, "update", map[string][]string{"priority": {"high"}}), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "definition_version") {+ t.Fatalf("err = %v", err)+ }+ if len(srv.recorded(http.MethodPatch)) != 0 {+ t.Fatal("wrote despite the error")+ }+ })+ t.Run("no flags", func(t *testing.T) {+ newViewWriteServer(t)+ if err := runViewUpdate(newViewWriteTestCmd(t, "update", nil), []string{"Bugs"}); err == nil {+ t.Fatal("want an error")+ }+ })+}++func TestViewWritesReportConflictsAndPermissionRefusals(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.writeStatus = http.StatusConflict+ err := runViewUpdate(newViewWriteTestCmd(t, "update", map[string][]string{"name": {"New"}}), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "re-run") || !strings.Contains(err.Error(), "revision 3") {+ t.Fatalf("conflict err = %v", err)+ }++ srv.writeStatus = http.StatusForbidden+ err = runViewUpdate(newViewWriteTestCmd(t, "update", map[string][]string{"name": {"New"}}), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "owner") {+ t.Fatalf("update forbidden err = %v", err)+ }+ err = runViewDelete(newViewWriteTestCmd(t, "delete", nil), []string{"Bugs"})+ if err == nil || !strings.Contains(err.Error(), "owner") {+ t.Fatalf("delete forbidden err = %v", err)+ }+}++func TestViewDuplicateCopiesTheSourceIntoANewPrivateView(t *testing.T) {+ srv := newViewWriteServer(t)+ srv.view["visibility"] = "workspace"+ cmd := newViewWriteTestCmd(t, "duplicate", map[string][]string{"priority": {"urgent"}})+ if _, err := captureStdout(t, func() error { return runViewDuplicate(cmd, []string{"Bugs"}) }); err != nil {+ t.Fatalf("run: %v", err)+ }+ body := srv.recorded(http.MethodPost)[0].body+ if body["name"] != "Bugs (copy)" || body["visibility"] != "private" || body["scope_type"] != "workspace" {+ t.Fatalf("copy fields = %v", body)+ }+ query, _ := body["query"].(map[string]any)+ if !reflect.DeepEqual(query["statusFilters"], []any{"todo"}) || !reflect.DeepEqual(query["priorityFilters"], []any{"urgent"}) {+ t.Fatalf("copy query = %v", query)+ }+ if len(srv.recorded(http.MethodPatch)) != 0 {+ t.Fatal("the source view was written")+ }+}++func TestViewDeleteSendsTheResolvedID(t *testing.T) {+ srv := newViewWriteServer(t)+ out, err := captureStdout(t, func() error { return runViewDelete(newViewWriteTestCmd(t, "delete", nil), []string{"bugs"}) })+ if err != nil {+ t.Fatalf("run: %v", err)+ }+ deletes := srv.recorded(http.MethodDelete)+ if len(deletes) != 1 || deletes[0].path != "/api/issue-views/"+testViewWriteViewUUID {+ t.Fatalf("deletes = %+v", deletes)+ }+ if !strings.Contains(out, `"deleted": true`) {+ t.Fatalf("output = %s", out)+ }+}diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex 1afa5d2664..5028a43807 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -796,7 +796,7 @@ func writeSkills(b *strings.Builder, provider string, ctx TaskContextForEnv) {// what keeps that consolidation from costing recall, and it must therefore// name the skill that actually holds those contracts.if platformSlug != "" {- b.WriteString("For a Multica platform action this brief does not fully cover — issue and PR contracts, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import — load the `" + platformSlug + "` skill and open the reference(s) its routing table names for the domains your task touches.\n\n")+ b.WriteString("For a Multica platform action this brief does not fully cover — issue and PR contracts, saved views, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import — load the `" + platformSlug + "` skill and open the reference(s) its routing table names for the domains your task touches.\n\n")}}@@ -822,7 +822,7 @@ func writeTraecliSkills(b *strings.Builder, skills []SkillContextForEnv) {}b.WriteString("\n")if platformSlug != "" {- b.WriteString("For a Multica platform action this brief does not fully cover — issue and PR contracts, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import — read `" + skillPath(platformSlug) + "` and open the reference(s) its routing table names for the domains your task touches.\n\n")+ b.WriteString("For a Multica platform action this brief does not fully cover — issue and PR contracts, saved views, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import — read `" + skillPath(platformSlug) + "` and open the reference(s) its routing table names for the domains your task touches.\n\n")}}diff --git a/server/internal/handler/issue_view.go b/server/internal/handler/issue_view.goindex 33c1056503..bf1f2d988a 100644--- a/server/internal/handler/issue_view.go+++ b/server/internal/handler/issue_view.go@@ -3,6 +3,7 @@ package handlerimport ("encoding/json""errors"+ "fmt""net/http""github.com/go-chi/chi/v5"@@ -20,6 +21,11 @@ import (const issueViewNameMaxLen = 80+// issueViewDefinitionVersionMax is the newest definition_version any client+// writes. A client that introduces a new version bumps this first, so a write+// in a format no other client can read is refused rather than stored.+const issueViewDefinitionVersionMax = 1+// issueViewBodyMaxBytes bounds every saved-view write. The query/display// blobs are filter documents — real ones are a few KB; the cap is the// abuse backstop, comfortably above any legitimate payload.@@ -187,6 +193,10 @@ func (h *Handler) CreateIssueView(w http.ResponseWriter, r *http.Request) {if req.DefinitionVersion <= 0 {req.DefinitionVersion = 1}+ if req.DefinitionVersion > issueViewDefinitionVersionMax {+ writeError(w, http.StatusBadRequest, "unsupported definition_version")+ return+ }if len(req.Query) == 0 || !isJSONObject(req.Query) {writeError(w, http.StatusBadRequest, "query must be a JSON object")return@@ -381,6 +391,11 @@ type UpdateIssueViewRequest struct {Query json.RawMessage `json:"query"`Display json.RawMessage `json:"display"`ExpectedRevision int32 `json:"expected_revision"`+ // DefinitionVersion, when sent, is the format the query/display were+ // written in. It must match the stored view's, so a client that only+ // knows an older format cannot overwrite a newer definition with it.+ // Optional because clients built before it was added never send it.+ DefinitionVersion *int32 `json:"definition_version"`}func (h *Handler) UpdateIssueView(w http.ResponseWriter, r *http.Request) {@@ -407,6 +422,12 @@ func (h *Handler) UpdateIssueView(w http.ResponseWriter, r *http.Request) {writeError(w, http.StatusBadRequest, "expected_revision is required")return}+ if req.DefinitionVersion != nil && *req.DefinitionVersion != view.DefinitionVersion {+ writeError(w, http.StatusBadRequest, fmt.Sprintf(+ "view is stored as definition_version %d; this client writes definition_version %d",+ view.DefinitionVersion, *req.DefinitionVersion))+ return+ }name := view.Nameif req.Name != nil {diff --git a/server/internal/handler/issue_view_test.go b/server/internal/handler/issue_view_test.goindex 57c4646af3..4797b8369b 100644--- a/server/internal/handler/issue_view_test.go+++ b/server/internal/handler/issue_view_test.go@@ -206,6 +206,115 @@ func TestUpdateIssueViewRevisionConflict(t *testing.T) {}}+// A shared view is writable by its owner and workspace admins only; a plain+// member who can open it is refused, and someone else's private view stays+// a 404 even for an admin.+func TestIssueViewWritesRequireOwnerOrAdmin(t *testing.T) {+ shared, code, body := createIssueViewForTest(t, map[string]any{+ "name": "Shared, owner-managed",+ "scope_type": "workspace",+ "visibility": "workspace",+ "query": map[string]any{},+ })+ if code != http.StatusCreated {+ t.Fatalf("create shared: %d %s", code, body)+ }+ private, code, body := createIssueViewForTest(t, map[string]any{+ "name": "Owner only",+ "scope_type": "workspace",+ "query": map[string]any{},+ })+ if code != http.StatusCreated {+ t.Fatalf("create private: %d %s", code, body)+ }++ patch := func(userID string, view IssueViewResponse) int {+ w := httptest.NewRecorder()+ req := newRequest("PATCH", "/api/issue-views/"+view.ID, map[string]any{+ "name": "Taken over",+ "expected_revision": view.Revision,+ })+ req.Header.Set("X-User-ID", userID)+ testHandler.UpdateIssueView(w, withURLParam(req, "id", view.ID))+ return w.Code+ }+ remove := func(userID string, view IssueViewResponse) int {+ w := httptest.NewRecorder()+ req := newRequest("DELETE", "/api/issue-views/"+view.ID, nil)+ req.Header.Set("X-User-ID", userID)+ testHandler.DeleteIssueView(w, withURLParam(req, "id", view.ID))+ return w.Code+ }++ member := createSecondWorkspaceMember(t)+ if got := patch(member, shared); got != http.StatusForbidden {+ t.Fatalf("member update of a shared view: expected 403, got %d", got)+ }+ if got := remove(member, shared); got != http.StatusForbidden {+ t.Fatalf("member delete of a shared view: expected 403, got %d", got)+ }++ if _, err := testPool.Exec(context.Background(),+ `UPDATE member SET role = 'admin' WHERE workspace_id = $1 AND user_id = $2`,+ testWorkspaceID, member); err != nil {+ t.Fatalf("promote member: %v", err)+ }+ if got := patch(member, private); got != http.StatusNotFound {+ t.Fatalf("admin update of another's private view: expected 404, got %d", got)+ }+ if got := remove(member, private); got != http.StatusNotFound {+ t.Fatalf("admin delete of another's private view: expected 404, got %d", got)+ }+ if got := patch(member, shared); got != http.StatusOK {+ t.Fatalf("admin update of a shared view: expected 200, got %d", got)+ }+ if got := remove(member, shared); got != http.StatusNoContent {+ t.Fatalf("admin delete of a shared view: expected 204, got %d", got)+ }+}++// A definition in a format newer than any client reads is refused on create,+// and an update naming a format other than the stored one cannot overwrite it.+func TestIssueViewDefinitionVersionGuards(t *testing.T) {+ _, code, body := createIssueViewForTest(t, map[string]any{+ "name": "From the future",+ "scope_type": "workspace",+ "definition_version": issueViewDefinitionVersionMax + 1,+ "query": map[string]any{},+ })+ if code != http.StatusBadRequest {+ t.Fatalf("create with an unknown definition_version: expected 400, got %d: %s", code, body)+ }++ view, code, body := createIssueViewForTest(t, map[string]any{+ "name": "Versioned",+ "scope_type": "workspace",+ "query": map[string]any{},+ })+ if code != http.StatusCreated {+ t.Fatalf("create: %d %s", code, body)+ }+ patch := func(fields map[string]any) (int, string) {+ fields["expected_revision"] = view.Revision+ w := httptest.NewRecorder()+ req := newRequest("PATCH", "/api/issue-views/"+view.ID, fields)+ testHandler.UpdateIssueView(w, withURLParam(req, "id", view.ID))+ return w.Code, w.Body.String()+ }+ if got, body := patch(map[string]any{+ "query": map[string]any{"statusFilters": []string{"todo"}},+ "definition_version": view.DefinitionVersion + 1,+ }); got != http.StatusBadRequest || !strings.Contains(body, "definition_version") {+ t.Fatalf("mismatched definition_version: expected 400, got %d: %s", got, body)+ }+ if got, body := patch(map[string]any{+ "query": map[string]any{"statusFilters": []string{"todo"}},+ "definition_version": view.DefinitionVersion,+ }); got != http.StatusOK {+ t.Fatalf("matching definition_version: expected 200, got %d: %s", got, body)+ }+}+// createSecondWorkspaceMember inserts another user + membership in the test// workspace and returns the user id.func createSecondWorkspaceMember(t *testing.T) string {diff --git a/server/internal/service/builtin_skills/multica-platform/SKILL.md b/server/internal/service/builtin_skills/multica-platform/SKILL.mdindex 5b93db77e0..b6fde83915 100644--- a/server/internal/service/builtin_skills/multica-platform/SKILL.md+++ b/server/internal/service/builtin_skills/multica-platform/SKILL.md@@ -1,6 +1,6 @@---name: multica-platform-description: "Use for Multica platform actions the runtime brief does not fully cover: issue and PR contracts, sub-issues, charts and files in comments, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import. Not for the product code you are working on."+description: "Use for Multica platform actions the runtime brief does not fully cover: issue and PR contracts, sub-issues, saved views, charts and files in comments, mentions, agents, squads, autopilots, projects, runtimes, local environments, skill import. Not for the product code you are working on."user-invocable: falseallowed-tools: Bash(multica *), Bash(git *), Bash(gh *)---@@ -19,7 +19,7 @@ Read the invariants below, then open the reference(s) your task actually needs| Open | When the task is about ||---|---|-| `references/issues.md` | Issues: PR linking, reading a linked PR's state, custom properties, status side effects, who else is running, wakeups (events, conditions, timers, check-ins), charts vs attached files in a comment |+| `references/issues.md` | Issues: PR linking, reading a linked PR's state, saved views (reading, creating, changing), custom properties, status side effects, who else is running, wakeups (events, conditions, timers, check-ins), charts vs attached files in a comment || `references/sub-issues.md` | Sub-issues: whether to split an issue at all, `todo` vs `backlog` children, serial chains, stages and the parent wakeups they drive || `references/mentions.md` | Writing a `mention://` link: which types enqueue a run, which are inert, why one silently did nothing; steering another agent's running turn (`comment add --steer`) || `references/agents.md` | Creating, copying or debugging an agent definition: fields, secrets, MCP config, skill binding |diff --git a/server/internal/service/builtin_skills/multica-platform/references/issues.md b/server/internal/service/builtin_skills/multica-platform/references/issues.mdindex b45e550467..55cd9671ab 100644--- a/server/internal/service/builtin_skills/multica-platform/references/issues.md+++ b/server/internal/service/builtin_skills/multica-platform/references/issues.md@@ -151,6 +151,34 @@ while `has_more` is true, pass `next_cursor` to `--cursor`. Views and their"me" conditions resolve against the runtime owner, so a member's private viewis only visible when that member owns the runtime.+When asked to set up or change a view, write it yourself instead of+describing the settings for the user to click through. A view written here is+the same view the app saves: it appears in the owner's sidebar and stays+editable in the app.++```bash+multica view create --name "Open bugs" --label Bug --status done,cancelled --negate status --view-mode list+multica view update "Open bugs" --priority urgent,high --visibility workspace+multica view duplicate "Open bugs" --name "Urgent bugs" --priority urgent+multica view delete "Urgent bugs"+```++- Filter flags take names (status, label, project, member, agent) and resolve+ them before writing; `--property` takes the `issue list --property` forms,+ `--negate <filter>` makes a filter "is not". Layout flags (`--view-mode`,+ `--grouping`, `--sort`, ...) are in `multica view create --help`.+- `--scope` (`workspace` default, `my`, or a project via `--project <name>`)+ is fixed at creation. Views start private and owned by the runtime owner.+- `update` changes only what its flags name; a list flag replaces that+ filter and `--status ""` clears it. A view using the app's advanced+ condition tree refuses filter flags: pass `--clear-filters`, or+ `--definition-file` with JSON edited from `view get`.+- `--dry-run` prints the request unsaved. After saving, check the result with+ `view issues`. "Changed since it was read" saved nothing: re-run; a stale+ `view get` export is refused too, so export again and redo the edits. A+ permission refusal means the runtime owner neither owns the view nor is an+ admin: report it rather than duplicating the view to work around it.+## Custom properties: typed workflow stateWorkspaces may define custom issue properties (Severity, Environment, QA