pinokiod 3.208.0 → 3.209.0

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.
@@ -137,13 +137,19 @@ class Terminal {
137
137
  }
138
138
 
139
139
  const marker = '[attachment] '
140
+ let shellEmitAttempted = false
141
+ let shellEmitSucceeded = false
140
142
  if (params && params.id && kernel && kernel.shell && typeof kernel.shell.emit === 'function') {
141
143
  try {
142
- kernel.shell.emit({
144
+ shellEmitAttempted = true
145
+ shellEmitSucceeded = kernel.shell.emit({
143
146
  id: params.id,
144
147
  emit: marker,
145
148
  paste: true
146
- })
149
+ }) === true
150
+ if (!shellEmitSucceeded && ondata) {
151
+ ondata({ raw: marker })
152
+ }
147
153
  } catch (error) {
148
154
  if (ondata) {
149
155
  ondata({ raw: marker })
@@ -164,7 +170,7 @@ class Terminal {
164
170
  req.params.buffers = {}
165
171
  }
166
172
 
167
- return { files: saved, errors: failures }
173
+ return { files: saved, errors: failures, shellEmit: shellEmitSucceeded, shellEmitAttempted }
168
174
  }
169
175
 
170
176
  resolveShellInstance(params, kernel) {
package/kernel/shells.js CHANGED
@@ -393,12 +393,14 @@ class Shells {
393
393
  } else {
394
394
  session.emit(params.emit)
395
395
  }
396
+ return true
396
397
  } else {
397
398
  const preview = typeof params.emit === 'string' ? params.emit.slice(0, 64) : ''
398
399
  console.warn('[shell.emit] missing session for id', params.id, {
399
400
  paste: !!params.paste,
400
401
  preview
401
402
  })
403
+ return false
402
404
  }
403
405
  }
404
406
  async send(params, ondata, enter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.208.0",
3
+ "version": "3.209.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -4868,7 +4868,9 @@ class Server {
4868
4868
  const result = await terminalApi.upload(requestPayload, () => {}, this.kernel)
4869
4869
  const files = result && Array.isArray(result.files) ? result.files : []
4870
4870
  const errors = result && Array.isArray(result.errors) ? result.errors : []
4871
- res.json({ files, errors })
4871
+ const shellEmit = result && typeof result.shellEmit === 'boolean' ? result.shellEmit : false
4872
+ const shellEmitAttempted = result && typeof result.shellEmitAttempted === 'boolean' ? result.shellEmitAttempted : false
4873
+ res.json({ files, errors, shellEmit, shellEmitAttempted })
4872
4874
  } catch (error) {
4873
4875
  res.status(500).json({ error: error && error.message ? error.message : 'remote upload failed' })
4874
4876
  }
@@ -207,7 +207,7 @@ body.dark #status-window b {
207
207
  <script>
208
208
  let shell_id
209
209
  let lastNotifiedShellId = null
210
- const formatUploadNotification = (files, sessionId) => {
210
+ const formatUploadNotification = (files, sessionId, shellEmit, shellEmitAttempted) => {
211
211
  if (!Array.isArray(files) || files.length === 0) {
212
212
  return 'Upload complete (no files reported)'
213
213
  }
@@ -219,7 +219,15 @@ const formatUploadNotification = (files, sessionId) => {
219
219
  const summary = target ? `${name} → ${target}` : name
220
220
  return summary.length > 180 ? `${summary.slice(0, 177)}…` : summary
221
221
  })
222
- return `${countLabel}<br>Session: ${sessionLabel}<br>${summaries.join('<br>')}`
222
+ let emitStatus
223
+ if (shellEmitAttempted) {
224
+ emitStatus = shellEmit ? 'Shell emit: delivered to terminal session' : 'Shell emit: failed – fallback used'
225
+ } else if (shellEmitAttempted === false) {
226
+ emitStatus = 'Shell emit: not attempted'
227
+ } else {
228
+ emitStatus = 'Shell emit: status unknown'
229
+ }
230
+ return `${countLabel}<br>Session: ${sessionLabel}<br>${emitStatus}<br>${summaries.join('<br>')}`
223
231
  }
224
232
  const postMessageToAncestors = (payload) => {
225
233
  if (!payload || typeof payload !== "object") {
@@ -946,8 +954,10 @@ document.addEventListener("DOMContentLoaded", async () => {
946
954
  reloadMemory()
947
955
  }
948
956
  } catch (_) {}
957
+ const shellEmit = typeof result.shellEmit === 'boolean' ? result.shellEmit : undefined
958
+ const shellEmitAttempted = typeof result.shellEmitAttempted === 'boolean' ? result.shellEmitAttempted : undefined
949
959
  n.Noty({
950
- text: formatUploadNotification(files, shell_id),
960
+ text: formatUploadNotification(files, shell_id, shellEmit, shellEmitAttempted),
951
961
  timeout: 6000
952
962
  })
953
963
  }
@@ -182,7 +182,7 @@ body.frozen {
182
182
  <link href="/terminal.css" rel="stylesheet"/>
183
183
  <script>
184
184
  let shell_id
185
- const formatUploadNotification = (files, sessionId) => {
185
+ const formatUploadNotification = (files, sessionId, shellEmit, shellEmitAttempted) => {
186
186
  if (!Array.isArray(files) || files.length === 0) {
187
187
  return 'Upload complete (no files reported)'
188
188
  }
@@ -194,7 +194,15 @@ const formatUploadNotification = (files, sessionId) => {
194
194
  const summary = target ? `${name} → ${target}` : name
195
195
  return summary.length > 180 ? `${summary.slice(0, 177)}…` : summary
196
196
  })
197
- return `${countLabel}<br>Session: ${sessionLabel}<br>${summaries.join('<br>')}`
197
+ let emitStatus
198
+ if (shellEmitAttempted) {
199
+ emitStatus = shellEmit ? 'Shell emit: delivered to terminal session' : 'Shell emit: failed – fallback used'
200
+ } else if (shellEmitAttempted === false) {
201
+ emitStatus = 'Shell emit: not attempted'
202
+ } else {
203
+ emitStatus = 'Shell emit: status unknown'
204
+ }
205
+ return `${countLabel}<br>Session: ${sessionLabel}<br>${emitStatus}<br>${summaries.join('<br>')}`
198
206
  }
199
207
  Dropzone.autoDiscover = false;
200
208
  function postMessageToAncestors(payload) {
@@ -799,8 +807,10 @@ document.addEventListener("DOMContentLoaded", async () => {
799
807
  type: "terminal.upload",
800
808
  files: mappedFiles
801
809
  })
810
+ const shellEmit = packet.data && typeof packet.data.shellEmit === 'boolean' ? packet.data.shellEmit : undefined
811
+ const shellEmitAttempted = packet.data && typeof packet.data.shellEmitAttempted === 'boolean' ? packet.data.shellEmitAttempted : undefined
802
812
  n.Noty({
803
- text: formatUploadNotification(mappedFiles, shell_id),
813
+ text: formatUploadNotification(mappedFiles, shell_id, shellEmit, shellEmitAttempted),
804
814
  timeout: 6000
805
815
  })
806
816
  } else {
@@ -1043,8 +1053,10 @@ document.addEventListener("DOMContentLoaded", async () => {
1043
1053
  reloadMemory()
1044
1054
  }
1045
1055
  } catch (_) {}
1056
+ const shellEmit = typeof result.shellEmit === 'boolean' ? result.shellEmit : undefined
1057
+ const shellEmitAttempted = typeof result.shellEmitAttempted === 'boolean' ? result.shellEmitAttempted : undefined
1046
1058
  n.Noty({
1047
- text: formatUploadNotification(mappedFiles, shell_id),
1059
+ text: formatUploadNotification(mappedFiles, shell_id, shellEmit, shellEmitAttempted),
1048
1060
  timeout: 6000
1049
1061
  })
1050
1062
  }