cozy-viewer 26.2.0 → 26.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [26.2.2](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.2.1...cozy-viewer@26.2.2) (2025-12-16)
7
+
8
+ ### Bug Fixes
9
+
10
+ - Sanitize text content for AI ([85f3f04](https://github.com/cozy/cozy-libs/commit/85f3f04d7c81fe383e4dc20a0964a90deb99ed12))
11
+
12
+ ## [26.2.1](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.2.0...cozy-viewer@26.2.1) (2025-12-15)
13
+
14
+ **Note:** Version bump only for package cozy-viewer
15
+
6
16
  # [26.2.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@26.1.2...cozy-viewer@26.2.0) (2025-12-15)
7
17
 
8
18
  ### Bug Fixes
@@ -125,7 +125,7 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
125
125
 
126
126
  var summarizeFile = /*#__PURE__*/function () {
127
127
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
128
- var client, file, _ref2$stream, stream, model, fileBlob, textContent, summaryConfig, _error, messages, summaryResponse;
128
+ var client, file, _ref2$stream, stream, model, fileBlob, rawTextContent, textContent, summaryConfig, _error, messages, summaryResponse;
129
129
 
130
130
  return _regenerator.default.wrap(function _callee$(_context) {
131
131
  while (1) {
@@ -145,11 +145,12 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
145
145
  });
146
146
 
147
147
  case 7:
148
- textContent = _context.sent;
148
+ rawTextContent = _context.sent;
149
+ textContent = rawTextContent ? JSON.stringify(rawTextContent) : '';
149
150
  summaryConfig = (0, _cozyFlags.default)('drive.summary');
150
151
 
151
152
  if (!(summaryConfig !== null && summaryConfig !== void 0 && summaryConfig.maxTokens && (0, _helpers.roughTokensEstimation)(textContent) > summaryConfig.maxTokens)) {
152
- _context.next = 13;
153
+ _context.next = 14;
153
154
  break;
154
155
  }
155
156
 
@@ -157,7 +158,7 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
157
158
  _error.code = 'DOCUMENT_TOO_LARGE';
158
159
  throw _error;
159
160
 
160
- case 13:
161
+ case 14:
161
162
  messages = [{
162
163
  role: 'system',
163
164
  content: _prompts.SUMMARY_SYSTEM_PROMPT
@@ -165,30 +166,30 @@ var AIAssistantPanel = function AIAssistantPanel(_ref) {
165
166
  role: 'user',
166
167
  content: (0, _prompts.getSummaryUserPrompt)(textContent)
167
168
  }];
168
- _context.next = 16;
169
+ _context.next = 17;
169
170
  return (0, _ai.chatCompletion)(client, messages, {
170
171
  stream: stream,
171
172
  model: model
172
173
  });
173
174
 
174
- case 16:
175
+ case 17:
175
176
  summaryResponse = _context.sent;
176
177
  return _context.abrupt("return", summaryResponse);
177
178
 
178
- case 20:
179
- _context.prev = 20;
179
+ case 21:
180
+ _context.prev = 21;
180
181
  _context.t0 = _context["catch"](1);
181
182
 
182
183
  _cozyLogger.default.error('Error when summarizing file:', _context.t0);
183
184
 
184
185
  throw _context.t0;
185
186
 
186
- case 24:
187
+ case 25:
187
188
  case "end":
188
189
  return _context.stop();
189
190
  }
190
191
  }
191
- }, _callee, null, [[1, 20]]);
192
+ }, _callee, null, [[1, 21]]);
192
193
  }));
193
194
 
194
195
  return function summarizeFile(_x) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-viewer",
3
- "version": "26.2.0",
3
+ "version": "26.2.2",
4
4
  "description": "Cozy-Viewer provides a component to show files in a viewer.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "babel-preset-cozy-app": "^2.8.2",
32
32
  "cozy-client": "^60.20.0",
33
33
  "cozy-device-helper": "2.0.0",
34
- "cozy-harvest-lib": "^36.0.9",
34
+ "cozy-harvest-lib": "^36.0.11",
35
35
  "cozy-intent": "^2.30.1",
36
36
  "cozy-logger": "^1.17.0",
37
- "cozy-sharing": "^28.1.1",
37
+ "cozy-sharing": "^28.1.2",
38
38
  "cozy-ui": "^135.0.0",
39
39
  "cozy-ui-plus": "^4.1.0",
40
40
  "identity-obj-proxy": "3.0.0",
@@ -70,5 +70,5 @@
70
70
  "react-router-dom": ">=6.14.2",
71
71
  "twake-i18n": ">=0.3.0"
72
72
  },
73
- "gitHead": "d20c63e1b070ebfc4bf34d481602399120fd9c73"
73
+ "gitHead": "f66279b4f43a3c1abdc05ebceab759065ec888de"
74
74
  }
@@ -53,10 +53,11 @@ const AIAssistantPanel = ({ className }) => {
53
53
  try {
54
54
  const fileBlob = await fetchBlobFileById(client, file?._id)
55
55
 
56
- const textContent = await extractText(client, fileBlob, {
56
+ const rawTextContent = await extractText(client, fileBlob, {
57
57
  name: file.name,
58
58
  mime: file.mime
59
59
  })
60
+ const textContent = rawTextContent ? JSON.stringify(rawTextContent) : ''
60
61
 
61
62
  const summaryConfig = flag('drive.summary')
62
63
  if (