Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions en/host/mongodb-workbench-plugin-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ connection entry inside the workbench — is retired with it.
| --- | --- |
| Entry | "MongoDB: Open MongoDB workbench" in the command palette; if the panel is already open it is brought forward. The leftmost toolbar button "Connect" and the "+" in the object-tree header create a connection; double-clicking a connection row connects it, and its context menu has connect / disconnect / edit / duplicate / delete |
| Saved connections | Plugin storage (`IPluginStorage`, key `connections`); settings are stored under the string keys in `MongoSettings`, the same ones parsing uses. The tree root lists every connection (grey dot: not connected, green: connected, red: failed); grouped ones sit under a collapsible group row; recently used ones come first |
| Password | The host's encrypted key store (`ISecretsApi`, keyed by connection id); never in the connection string and never in plugin storage. Leaving the password box empty while editing keeps it; switching to anonymous deletes it |
| Password | The host's encrypted key store (`ISecretsApi`, keyed by connection id); never in the connection string and never in plugin storage. Leaving the password box empty while editing keeps it; switching to anonymous deletes it. In the URI form, a username / password written into the URI is split out on save: the username fills the Username field, the password goes to the key store, and plugin storage keeps only the URI without credentials (older connections migrate on their next save) |
| Several connections at once | Each connected connection gets a session object, and that object is what its tabs receive — the same collection in two connections is two tabs; the toolbar, the read-only switch, the server badge and the status strip follow the connection of the active tab |
| SSH jump host | Pick one of the SSH connections saved in the host (`ISessionsApi.ListSavedAsync`). On connect the plugin asks the host to open it (`OpenAsync`; the reason is shown to the user verbatim), starts a forwarding port on the local loopback, and every driver connection is paired with a stream opened on the jump host through `IRemoteTunnelApi.OpenTcpAsync`. Connections through the same jump host share one session, which closes when the last one leaves — and only if the plugin opened it (the host refuses to close the user's own terminal sessions). The plugin never sees the jump host's credentials |
| SSH jump host | Pick one of the SSH connections saved in the host (`ISessionsApi.ListSavedAsync`). On connect the plugin asks the host to open it (`OpenAsync`; the reason is shown to the user verbatim), starts a forwarding port on the local loopback, and every driver connection is paired with a stream opened on the jump host through `IRemoteTunnelApi.OpenTcpAsync`. Connections through the same jump host share one session, which closes when the last one leaves — and only if the plugin opened it (the host refuses to close the user's own terminal sessions). The plugin never sees the jump host's credentials. Both the host-list and the URI form can go through a jump host (the URI is parsed as written and only its server is replaced by the local endpoint); a `mongodb+srv://` URI, like the SRV form, cannot, and is rejected with an error rather than connecting directly around the jump host. When the shared session dies (jump host restart, network blip), the next stream open notices the session is gone, reopens it once and retries; when two connections open the same jump host at the same time, the extra session the later one opened is closed right away. TLS through a jump host: the driver connects to 127.0.0.1, so the certificate's host name is checked against the real target host instead (SAN / CN); every other certificate error is still reported |
| Certificate trust | When a self-signed certificate blocks the connection, the failure card lists the certificate (subject, issuer, expiry, SHA-1) and offers "Trust this certificate and reconnect", which pins that one thumbprint |

| Board 10 | Implementation |
| --- | --- |
| Name / group / environment | The "Basic" row; the group can be an existing one or a new one; the environment is three chips with tone dots, and picking production turns on read-only and write confirmation (unless the policy was changed by hand) |
| Host list / SRV record / connection string URI | A segmented control; the host list has one host per row (the first is the connection's host) and "+ Add host"; SRV is a single domain field and turns TLS on by default; the URI form is the whole string |
| Replica set, default database, readPreference | One row split into thirds (hidden for the URI form, where the string decides) |
| Replica set, default database, readPreference | One row split into thirds (hidden for the URI form, where the string decides: readPreference, appName, timeouts and compressors written in the URI are overridden only by settings explicitly set under "Advanced") |
| Mechanism / authSource / username / password | The mechanism defaults to negotiating SCRAM-SHA-256, with SCRAM-SHA-1, X.509 and PLAIN/LDAP as alternatives; the "Key store" tag next to the password box says where it is kept |
| "Secure channel": SSH jump / TLS cards | The jump card's switch is disabled, with the reason written underneath, when no SSH connection is saved or SRV is selected (one already on can still be turned off); TLS, once on, adds CA and client-certificate fields |
| Side panel: connection string | Built by string work only and redacted (the password is always `****`), coloured by segment role, copyable; a half-typed URI is shown as typed, redacted |
Expand Down Expand Up @@ -83,17 +83,17 @@ Two easy mistakes:

| Board | Implementation |
| --- | --- |
| 01 grid · 02 JSON view · 13 tree view | Collection workbench: typed column headers, BSON colouring, inline editing, inspector (fields / JSON / collection info, per-field type menu), staging and paging; tree view with its context menu; inline JSON-card editing with value-distribution suggestions |
| 03 query editor · 14 explain | A Navicat-style two-row toolbar (the lower row is "Connection ▾ Database ▾" plus Run, deciding where statements run); parsing and running a mongosh subset, context-aware completion (including the fields a preceding `$group` outputs), diagnostics with quick fixes, code lenses, several result tabs; explain output flattened into a stage flow with candidate plans, ESR advice and hint comparison |
| 01 grid · 02 JSON view · 13 tree view | Collection workbench: typed column headers, BSON colouring, inline editing (wide tables only realize the columns in the viewport), inspector (fields / JSON / collection info, per-field type menu), staging and paging; tree view with its context menu; inline JSON-card editing with value-distribution suggestions |
| 03 query editor · 14 explain | A Navicat-style two-row toolbar (the lower row is "Connection ▾ Database ▾" plus Run, deciding where statements run); parsing and running a mongosh subset, context-aware completion (including the fields a preceding `$group` outputs), diagnostics with quick fixes, code lenses, several result tabs; explain output flattened into a stage flow with candidate plans, ESR advice and hint comparison. When the server pushes stages down to the SBE engine (`explainVersion: "2"`, common for `$group` and friends since 7.0), the stage flow is built from `winningPlan.queryPlan`, totals come from the top level of the execution stats, and per-stage numbers are matched back by `planNodeId` where possible — the tree under `executionStages` is SBE's slot tree, whose stage names are not `IXSCAN` and the like |
| 04 aggregation pipeline | Stage cards (enable/disable, drag to reorder, per-stage output preview), two-way text mode, code export in five languages, create view, `$out` / `$merge` |
| 05 document editor | Form / JSON / diff modes, minimal `$set` / `$unset`, client-side `$jsonSchema` pre-check, "redo on the latest version" after an optimistic-concurrency conflict |
| 06 GridFS | Virtual directories, revisions of the same file name (restore, download; old revisions can be deleted one at a time, a ticked few at once, or all but the latest — the latest is never among them), streaming upload and download, drag and drop or clicking the drop zone to choose files / a folder, orphan-chunk check, metadata editing |
| 07 indexes · 07b new index · 08 schema · 16 validation | `$indexStats` usage and build progress, ESR suggestions from slow queries in `system.profile`, a full-width new-index editor (see below); `$sample`-based analysis and a generated `$jsonSchema`; server-side rule pre-check (`$nor`), trial documents, version history |
| 06 GridFS | Virtual directories, revisions of the same file name (restore, download; old revisions can be deleted one at a time, a ticked few at once, or all but the latest — the latest is never among them), streaming upload and download, drag and drop or clicking the drop zone to choose files / a folder, orphan-chunk check, metadata editing. Downloads to a folder are written to `.part` and then renamed; same-named files (already on disk, or from different virtual directories in one batch) get a number instead of being overwritten |
| 07 indexes · 07b new index · 08 schema · 16 validation | `$indexStats` usage and build progress, ESR suggestions from slow queries in `system.profile`, a full-width new-index editor (see below); `$sample`-based analysis and a generated `$jsonSchema`; server-side rule pre-check (`$nor`), trial documents, version history. Index advice never suggests dropping `_id`, TTL, unique or shard-key-supporting indexes, and an index with a different collation is not called redundant; applying a validation rule says "N of 1,000 sampled don't match", words the consequence by level / action, and is unavailable until the pre-check has finished |
| 10 new connection | See section 2 (the plugin's own dialog) |
| 11 server monitor · 15 slow queries | Delta sampling of `serverStatus` / `replSetGetStatus`, stacked bar charts, member cards, storage top list, inferred events; `$currentOp` with killOp, profiler level, slow queries grouped by query shape |
| 11 server monitor · 15 slow queries | Delta sampling of `serverStatus` / `replSetGetStatus`, stacked bar charts, member cards, storage top list, inferred events; `$currentOp` with killOp, profiler level, slow queries grouped by query shape. Nothing is sampled while the tab is hidden; the first sample after it comes back only sets a baseline, and periods with no samples are drawn as gaps rather than zeros. Storage top, profiler levels and the slow-query check run as separate background work so they don't stretch the sampling interval. When slow-query polling fails, a banner says so and the current-operations list is cleared (so nobody kills a stale opid) |
| 12 object list · 17 new collection | Navicat-style object page (stats, DDL, privileges); five collection kinds with a live command preview |
| 18 users and roles | Built-in role matrix, custom roles, authentication restrictions, effective-privilege preview; saving issues incremental grant / revoke commands |
| 19 export · 20 import · 21 data transfer | JSON / CSV / XLSX / BSON dump (mongodump compatible) / shell script; import dry-run with validator-aware issues; copying collections, buckets, indexes and rules across sessions |
| 18 users and roles | Built-in role matrix, custom roles, authentication restrictions, effective-privilege preview; saving issues incremental grant / revoke commands. A new user's password is typed twice; changing the password of the connection's own user asks for extra confirmation and, on success, updates the copy saved in the key store |
| 19 export · 20 import · 21 data transfer | JSON / CSV / XLSX / BSON dump (mongodump compatible) / shell script; import dry-run with validator-aware issues; copying collections, buckets, indexes and rules across sessions. Export defaults are lossless (Decimal128 at full precision, ISO dates with milliseconds and zone; in XLSX, Int64 / Decimal128 values a double can't hold are written as text); import strips commas only in valid thousands grouping (`1,5` is an error, not 15), "stop on error" still writes the rows read before the bad one, and a stopped or failed import reports the server-confirmed counts plus the error-report and backup file locations |
| 22 states, feedback and confirmations | Connecting / connection-failed placeholder cards (see section 2), empty / no results / long-running query (killOp), read-only banner, undo toast, delete confirmation by typed name, edit-conflict dialog |

Interactions the boards do not draw but daily use depends on (following Navicat's habits):
Expand Down Expand Up @@ -157,8 +157,14 @@ Interactions the boards do not draw but daily use depends on (following Navicat'
- **Undo**: pre-images are kept before committing; the toast's "Undo (10)" rolls back with them.
- **Read-only**: every write path calls `EnsureWritable(db)` first; in read-only mode it shows a notice with "Unlock writes" (which asks for confirmation on production).
Real read-only belongs in server-side privileges; this layer stops the classic accident of bulk-editing in a tab you thought was a test database.
"Unlock writes" lasts 15 minutes and its timer belongs to the connection — closing the tab that unlocked it still relocks on time.
- **`runCommand` in the query editor** recognizes read-only commands by an **allowlist** (`find`, `aggregate` without `$out` / `$merge`, the `*Stats` /
`list*` / `hello` family …); everything else counts as a write. `dropDatabase` / `drop` / `dropIndexes` sent through `runCommand` go through the same
confirmation and disable switch as the matching shell methods, and database-level `db.aggregate` is checked for `$out` / `$merge` too.
`.readPref()` / `.readConcern()` report "not supported" instead of being silently ignored.
- **Destructive actions** always use a red outline button and state the consequence; on production (or when what is deleted holds data) the name must be typed;
`dropDatabase` can be disabled altogether.
`dropDatabase` can be disabled altogether. Emptying a collection (`deleteMany({})`) follows the same rule as dropping it: typing the name is required when it holds data.
- **Rows per page** are capped at 10,000 (skip can still go to 1,000,000): beyond that, column statistics and rendering freeze the UI.

## 5. Colour: the board palette mapped to host tokens

Expand All @@ -173,6 +179,8 @@ The plugin hands the password of each MongoDB connection to the host's encrypted
without the password. The plugin still cannot read the host's session store: the SSH jump host is opened by asking the host for a saved connection by
id, and not one byte of the jump host's credentials passes through the plugin. The "target connection" of a data transfer is **another connection this
plugin currently has open**, or a connection string the user types in (which the user hands over themselves).
Query history is redacted before it is stored: values of `pwd` / `password` / `passwordDigest`, the password arguments of `changeUserPassword` / `db.auth` and
passwords inside connection strings are masked, and each entry is truncated to 8 KB.

## 7. Testing

Expand Down
Loading