pinokiod 3.207.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.207.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,6 +207,28 @@ body.dark #status-window b {
207
207
  <script>
208
208
  let shell_id
209
209
  let lastNotifiedShellId = null
210
+ const formatUploadNotification = (files, sessionId, shellEmit, shellEmitAttempted) => {
211
+ if (!Array.isArray(files) || files.length === 0) {
212
+ return 'Upload complete (no files reported)'
213
+ }
214
+ const countLabel = files.length > 1 ? `${files.length} files attached` : 'File attached'
215
+ const sessionLabel = sessionId ? sessionId : '(unknown session)'
216
+ const summaries = files.map((file) => {
217
+ const name = file && (file.originalName || file.name || file.storedAs) ? (file.originalName || file.name || file.storedAs) : 'unknown'
218
+ const target = file && (file.cliRelativePath || file.displayPath || file.path) ? (file.cliRelativePath || file.displayPath || file.path) : ''
219
+ const summary = target ? `${name} → ${target}` : name
220
+ return summary.length > 180 ? `${summary.slice(0, 177)}…` : summary
221
+ })
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>')}`
231
+ }
210
232
  const postMessageToAncestors = (payload) => {
211
233
  if (!payload || typeof payload !== "object") {
212
234
  return false
@@ -932,9 +954,11 @@ document.addEventListener("DOMContentLoaded", async () => {
932
954
  reloadMemory()
933
955
  }
934
956
  } catch (_) {}
957
+ const shellEmit = typeof result.shellEmit === 'boolean' ? result.shellEmit : undefined
958
+ const shellEmitAttempted = typeof result.shellEmitAttempted === 'boolean' ? result.shellEmitAttempted : undefined
935
959
  n.Noty({
936
- text: files.length > 1 ? `${files.length} files attached` : `File attached`,
937
- timeout: 4000
960
+ text: formatUploadNotification(files, shell_id, shellEmit, shellEmitAttempted),
961
+ timeout: 6000
938
962
  })
939
963
  }
940
964
  if (failures.length > 0) {
@@ -182,6 +182,28 @@ body.frozen {
182
182
  <link href="/terminal.css" rel="stylesheet"/>
183
183
  <script>
184
184
  let shell_id
185
+ const formatUploadNotification = (files, sessionId, shellEmit, shellEmitAttempted) => {
186
+ if (!Array.isArray(files) || files.length === 0) {
187
+ return 'Upload complete (no files reported)'
188
+ }
189
+ const countLabel = files.length > 1 ? `${files.length} files attached` : 'File attached'
190
+ const sessionLabel = sessionId ? sessionId : '(unknown session)'
191
+ const summaries = files.map((file) => {
192
+ const name = file && (file.originalName || file.name || file.storedAs) ? (file.originalName || file.name || file.storedAs) : 'unknown'
193
+ const target = file && (file.cliRelativePath || file.displayPath || file.path) ? (file.cliRelativePath || file.displayPath || file.path) : ''
194
+ const summary = target ? `${name} → ${target}` : name
195
+ return summary.length > 180 ? `${summary.slice(0, 177)}…` : summary
196
+ })
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>')}`
206
+ }
185
207
  Dropzone.autoDiscover = false;
186
208
  function postMessageToAncestors(payload) {
187
209
  if (!payload || typeof payload !== "object") {
@@ -785,9 +807,11 @@ document.addEventListener("DOMContentLoaded", async () => {
785
807
  type: "terminal.upload",
786
808
  files: mappedFiles
787
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
788
812
  n.Noty({
789
- text: mappedFiles.length > 1 ? `${mappedFiles.length} files attached` : `File attached`,
790
- timeout: 4000
813
+ text: formatUploadNotification(mappedFiles, shell_id, shellEmit, shellEmitAttempted),
814
+ timeout: 6000
791
815
  })
792
816
  } else {
793
817
  refreshParent({
@@ -1029,9 +1053,11 @@ document.addEventListener("DOMContentLoaded", async () => {
1029
1053
  reloadMemory()
1030
1054
  }
1031
1055
  } catch (_) {}
1056
+ const shellEmit = typeof result.shellEmit === 'boolean' ? result.shellEmit : undefined
1057
+ const shellEmitAttempted = typeof result.shellEmitAttempted === 'boolean' ? result.shellEmitAttempted : undefined
1032
1058
  n.Noty({
1033
- text: mappedFiles.length > 1 ? `${mappedFiles.length} files attached` : `File attached`,
1034
- timeout: 4000
1059
+ text: formatUploadNotification(mappedFiles, shell_id, shellEmit, shellEmitAttempted),
1060
+ timeout: 6000
1035
1061
  })
1036
1062
  }
1037
1063
  if (failures.length > 0) {