Commit Graph
5 Commits
Author SHA1 Message Date
Bingbing b266c3c6f1 feat(examples): add example model and authoring
## Background

A request can only keep its latest response, so a request/response pair worth keeping has nowhere to live. This adds an Example document: a full snapshot of a request and a response, stored next to the request, listed in the sidebar and edited in its own tab.

## Changes

- Add the `Example` model (`exp_` prefix) with zod schemas for the request snapshot, the response snapshot, the client patch and the sidebar summary. Register it with the database, type maps, tree metadata and sync flags, so examples can be duplicated and synchronized.
- Add `services.example` (list, get, list by parents, create, update, remove, duplicate, create from request) and expose examples from the workspace data service.
- Extend the workspace children cache with example summaries and add a per-example query that carries the bodies, so workspace-wide reads stay small. The database change listener refreshes or drops an open example.
- Export and import examples in v5 files, including the generated 5.1 schema, and include them in Git sync.
- Add the example route and editor: request pane reusing the HTTP editors, response pane, breadcrumb entry under the parent request and redirect for stale URLs.
- Add example rows to the sidebar with collapse, drag and drop and rename, and give the tab a code icon instead of a method badge.
- Cover the model, services, cache and file format with unit tests and add a smoke test.

Refs INS-3997
2026-10-29 16:39:38 +08:00
yaoweiprcandClaude Opus 5.5 70b1d87670 fix: Warn when a Git Sync change cannot be discarded [INS-3830] (#10585)
* fix: Warn when a Git Sync change cannot be discarded [INS-3689]

When a committed YAML file is not in the exact format Insomnia generates
(hand-edited, or written by an older version), discarding it restores the
file, the repo file watcher imports it and re-exports it, and the change
reappears. Users get stuck with a change they can never discard.

Detect this up front by replaying the import -> export round-trip in memory
on the raw index/HEAD content. When the result equals the working copy, the
whole diff is Insomnia re-generating the file, so the Commit Changes modal
shows a warning above the diff and the discard confirmation explains that
the file needs to be committed once.

- Add sync/git/canonical-file.ts, which mirrors database.update (initModel)
  and the getWithDescendants ordering (created, then _id)
- Split getInsomniaV5DataExport into a DB fetch and a pure
  serializeInsomniaV5Export
- Return rawHead/rawStage from GitVCS.fileStatus, since head/stage are
  migrated and reordered for display
- Export initModel from insomnia-data/node

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: Replay the Git Sync round-trip on a scratch database [INS-3689]

The undiscardable-change check reimplemented parts of the import/export
pipeline (initModel, getWithDescendants ordering) to avoid touching the app
database. That copy would silently drift whenever the real pipeline changes.

Run the real pipeline instead: write the imported docs to a scratch
in-memory NeDB instance and export them with getInsomniaV5DataExport.

- Keep NeDB collections, change buffer and listeners per instance in
  createNedbDatabase. They were module-level, so a second instance's init()
  would have replaced the app's collections. flushChangesImpl is now handed
  to the wrapper instead of being exported.
- Add an optional db parameter to getInsomniaV5DataExport and drop the
  serializeInsomniaV5Export split and the initModel export

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: Ignore import timestamps when detecting undiscardable changes [INS-3689]

Import fills a missing meta.created/modified with the current time, so a
hand-added entry without timestamps got a different value in the replay
than in the working copy the watcher wrote earlier. The exact comparison
then failed and the warning never showed, although the change still came
back after every discard.

Compare the replay with the working copy using hasSignificantChanges, the
same rules the Unstaged changes list uses, so differences the list already
ignores no longer hide the warning.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: Reword the undiscardable change warning [INS-3689]

Explain the cause in user terms, using the wording suggested in the ticket.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: Shorten the undiscardable change warning [INS-3689]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: Rename committedContent to baselineContent [INS-3689]

The content a discard restores is the staged content when there is one, so
it is not necessarily committed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-14 09:53:20 +00:00
Ryan Willis 29b2e391fb fix(database): emit change notifications on document duplication (#10387) 2026-08-12 13:29:36 -07:00
26020af109 Fix inherited folder auth not applied correctly for OAuth2 requests [INS-2671] (#9999)
* tmp

* Fix the bug that inherited auth is not applied as expected

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Add regression coverage for folder auth inheritance precedence (#10000)

* Initial plan

* test: add auth inheritance regression coverage

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-06-02 10:04:51 +00:00
Bingbing b09cde814d refactor: extract insomnia-data into workspace package (#10010)
Move insomnia-data models, services, database code, and common utilities into a dedicated workspace package. Update consumers to import from the new package entrypoints and declare workspace dependencies for the extracted package.
2026-06-02 09:49:10 +00:00