Skip to content

Commit

Permalink
fix: Shell adapter history is not persisting
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguerra committed Aug 14, 2024
1 parent 7572be2 commit 5ae96d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/adapters/Shell.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ class Shell extends Adapter {
await this.receive(message)
this.#rl.prompt()
})

this.#rl.on('history', async (history) => {
await fs.promises.writeFile(historyPath, history.reverse().join('\n'))
if (history.length === 0) return
await fs.promises.appendFile(historyPath, `${history[0]}\n`)
})

let existingHistory = (await fs.promises.readFile(historyPath, 'utf8')).split('\n')
existingHistory.forEach(line => this.#rl.history.push(line))

try {
this.#rl.prompt()
this.emit('connected', this)
Expand Down

0 comments on commit 5ae96d4

Please sign in to comment.