Commit graph

3 commits

Author SHA1 Message Date
Mike Sawka
f3b1c16882
improve the schema for widgets.json (#2913) 2026-02-20 16:59:38 -08:00
Copilot
e8d4cddb5a
Add optional per-workspace widget visibility via workspaces in widgets.json (#2898)
This change adds an optional `workspaces` field to widget config entries
so widgets can be scoped to specific workspace UUIDs. Widgets with no
`workspaces` field (or an empty array) continue to render globally,
preserving current `widgets.json` behavior.

- **Config model updates**
- Added `workspaces []string` to `wconfig.WidgetConfigType` with
`json:"workspaces,omitempty"`.
- Updated frontend generated type `WidgetConfigType` with `workspaces?:
string[]`.

- **Sidebar widget filtering**
- `frontend/app/workspace/widgets.tsx` now applies workspace-aware
filtering when building the sidebar widget list:
    - include if `workspaces` is missing or empty
    - include if current `workspace.oid` is present in `workspaces`
    - otherwise exclude
  - Existing `defwidget@ai` filtering logic remains intact.

- **Isolated filtering logic + coverage**
  - Added `frontend/app/workspace/widgetfilter.ts` with:
    - `shouldIncludeWidgetForWorkspace(widget, workspaceId)`
- Added focused tests in `frontend/app/workspace/widgetfilter.test.ts`
for:
    - missing/empty `workspaces`
    - matching/non-matching workspace IDs
    - missing active workspace ID

```ts
function shouldIncludeWidgetForWorkspace(widget: WidgetConfigType, workspaceId?: string): boolean {
  const workspaces = widget.workspaces;
  return !Array.isArray(workspaces) || workspaces.length === 0 || (workspaceId != null && workspaces.includes(workspaceId));
}
```

- **Screenshot**
-
<screenshot>https://github.com/user-attachments/assets/b1727003-793b-4eff-8fc1-00eac9c50b83</screenshot>

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <mike@commandline.dev>
2026-02-19 16:14:22 -08:00
Sylvie Crowe
3e0712c55e
feat: add schema for widgets.json (#1929) 2025-02-07 15:39:57 -08:00