# Increasing suggestions granularity

You can control how and when the track changes feature joins suggestions from the same user. Use the [`config.trackChanges.mergeNestedSuggestions`](../../../api/module_track-changes_trackchangesconfig-TrackChangesConfig.md#member-mergeNestedSuggestions) configuration option to control merging of suggestions on an object with suggestions inside that object, and [tracking sessions](#tracking-sessions) to prevent joining suggestions created in different sessions.

By default, the feature automatically joins suggestions added by the same user – for example, two insertion suggestions made next to each other, or two formatting suggestions on the same text. This keeps the number of suggestions low and the UI less cluttered, which generally provides a better user experience.

<a id="auto-merging-nested-suggestions">

## Auto-merging nested suggestions

By default, suggestions **on** an object (such as image or table) will be automatically merged with suggestions **inside** the object (for example, a change in image caption, or a table cell). For example, creating a table and writing some text inside the table will result in one suggestion.

This behavior can be changed by setting the [`config.trackChanges.mergeNestedSuggestions`](../../../api/module_track-changes_trackchangesconfig-TrackChangesConfig.md#member-mergeNestedSuggestions) configuration option to `false`. In the scenario above, there would be two separate suggestions: one for the inserted table and one for the inserted text.

```js
{
	trackChanges: {
		mergeNestedSuggestions: false
	}
	// Other configuration
}
```

<a id="tracking-sessions">

## Tracking sessions

To stop track changes from automatically joining suggestions made by the same user, [start a new tracking session](#starting-a-new-tracking-session). Suggestions created in the new tracking session will not be joined with suggestions created in any of the previous tracking session.

From the technical point of view, after starting a new tracking session, newly created suggestions will have a unique `trackingSessionId` [attribute](../../../api/module_track-changes_suggestion-Suggestion.md#member-attributes). This will prevent them from being joined to already existing suggestions.

If you are using a asynchronous integration, make sure that you correctly save and load suggestion `attributes` together with the rest of the suggestion data.

<a id="starting-a-new-tracking-session">

### Starting a new tracking session

To start a new tracking session, call the [`TrackChangesEditing#startTrackingSession()`](../../../api/module_track-changes_trackchangesediting-TrackChangesEditing.md#function-startTrackingSession) method. From now on, all newly created suggestions will have a unique `trackingSessionId` attribute set. That ID value is returned by the method.

```js
editor.plugins.get( 'TrackChangesEditing' ).startTrackingSession();
```

<a id="resuming-previous-session">

### Resuming previous session

You can also resume one of the previous tracking sessions by calling [`TrackChangesEditing#startTrackingSession()`](../../../api/module_track-changes_trackchangesediting-TrackChangesEditing.md#function-startTrackingSession) and passing a previously set `trackingSessionId` as the `id` parameter.

```js
editor.plugins.get( 'TrackChangesEditing' ).startTrackingSession( 'somePreviousId' );
```

To “resume” tracking session for suggestions that were added before introducing [`TrackChangesEditing#startTrackingSession()`](../../../api/module_track-changes_trackchangesediting-TrackChangesEditing.md#function-startTrackingSession) you may pass `null` as the `id` parameter. It will also stop adding the `trackingSessionId` attribute to new suggestions.

```js
editor.plugins.get( 'TrackChangesEditing' ).startTrackingSession( null );
```

<a id="demo">

## Demo

1. Add some text with track changes enabled. You may add more text next to created suggestions to see how the suggestions are automatically expanded.
2. Press the “Start new tracking session” button above the editor, and continue typing after one of the previously created suggestions.
3. See how new suggestion is created instead of expanding the existing suggestion.

<!-- AI-AGENT-NOTE: An interactive demo is embedded here but is not represented in this Markdown file. If you need to see it in action, open this page in a browser (e.g. via a browser-automation MCP like Chrome DevTools or Playwright), or let the user know a live demo is available on this page. -->

This demo presents a limited set of features. Visit the [feature-rich editor example](../../../examples/builds-custom/full-featured-editor.md) to see more in action.

<a id="starting-a-new-session-on-editor-initialization">

## Starting a new session on editor initialization

One of the primary use cases is to start a new tracking session whenever the user opens the editor and/or after some time has passed.

Below you will find an example where a new tracking session is started whenever editor is created.

```js
ClassicEditor
	.create( {
		// ... Editor configuration ...
	} )
	.then( editor => {
		// You can store the id if you need it later to resume previous tracking session.
		const trackingSessionId = editor.plugins.get( 'TrackChangesEditing' ).startTrackingSession();
	} )
	.catch( /* ... */ );
```

---

Full index of the CKEditor 5 documentation: [llms.txt](../../../../llms.txt)
