mirror of
https://github.com/cosmicoptima/loom.git
synced 2026-07-22 07:40:25 +00:00
add status bar indicator for compeltion
This commit is contained in:
parent
15b9487373
commit
3efdab908c
1 changed files with 10 additions and 0 deletions
10
main.ts
10
main.ts
|
|
@ -59,6 +59,7 @@ export default class LoomPlugin extends Plugin {
|
|||
|
||||
editor: Editor;
|
||||
view: LoomView;
|
||||
statusBarItem: HTMLElement;
|
||||
|
||||
openai: OpenAIApi;
|
||||
|
||||
|
|
@ -96,6 +97,10 @@ export default class LoomPlugin extends Plugin {
|
|||
|
||||
this.setOpenAI();
|
||||
|
||||
this.statusBarItem = this.addStatusBarItem();
|
||||
this.statusBarItem.setText("Completing...");
|
||||
this.statusBarItem.style.display = "none";
|
||||
|
||||
this.addCommand({
|
||||
id: "loom-complete",
|
||||
name: "Complete",
|
||||
|
|
@ -752,6 +757,8 @@ export default class LoomPlugin extends Plugin {
|
|||
if (!file) return;
|
||||
// TODO add async support to withFile and wftsar, so `complete` can be wrapped
|
||||
|
||||
this.statusBarItem.style.display = "inline-flex";
|
||||
|
||||
const state = this.state[file.path];
|
||||
let prompt = this.fullText(state.current, state);
|
||||
|
||||
|
|
@ -795,6 +802,7 @@ export default class LoomPlugin extends Plugin {
|
|||
"Unknown OpenAI API error: " + e.response.data.error.message
|
||||
);
|
||||
|
||||
this.statusBarItem.style.display = "none";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -823,6 +831,8 @@ export default class LoomPlugin extends Plugin {
|
|||
|
||||
this.save();
|
||||
this.view.render();
|
||||
|
||||
this.statusBarItem.style.display = "none";
|
||||
}
|
||||
|
||||
fullText(id: string, state: NoteState) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue