Repository navigation
Commit cecdaf0
committed
Implement persistent text storage for pasted text and website contents
- Refactor pasted text handling in the save/open handlers and symbol replacers to use `extension_context.globalStorageUri.fsPath + '/pasted-text'` instead of `os.tmpdir()`, replace the MD5 hash with a `Date.now()` timestamp for the file ID and `#PastedText` symbol, and add garbage collection to the save handler that deletes files in that directory with a timestamp older than 1 year (31536000000 ms).
- treat parsed websites similarly
- the one year garbage collection threshold should be kept in `apps/editor/src/constants/values.ts`
- pasted text/websites storage should be abstracted into a shared interace/util
- [Pasted text] should return id (so accepting in param is not necessary)
- the 'website' symbol should have website's title in it, not the generic 'Website'
- rename 'persistent storage' to 'persistent text storage'
- in parsed website, don't place URL. When displaying such website, in the titlebar, use it's title from the symbol.
- in parsed website preview: don't print page title in heading. in constructed prompt: place the website text in a markdown code block (```markdown...) prefixed by the title in **bold text** (taken from the symbol)
- analyze latest changes: [Changes] - keep storing url (before ) in the symbol and restore ability to open the website from preview action button.
- simplify `apps/editor/src/views/prompt/backend/utils/persistent-text-storage.ts` by storing pasted text and websites to unified folder in the storage (no need to store them in separate `pasted-text` and `websites` folders). Use folder name `prompt-text`.
- simplify file names, e.g. [Pasted text] to 1792446329395.txt
- instead of timestamps, use sha256 hashes for filenames. Garbage collect old files based on file metadata.
- shorten these hashes to reasonable lengths [Pasted text]
├── apps
│ └── editor
│ ├── package.json
│ └── src
│ ├── commands
│ │ └── save-context-command
│ │ ├── actions
│ │ │ └── save-to-workspace-state.ts
│ │ └── save-context-command.ts
│ ├── constants
│ │ └── values.ts
│ ├── features
│ │ └── context-restoration
│ │ └── utils
│ │ └── global-storage-utils.ts
│ ├── utils
│ │ ├── files-collector.ts
│ │ ├── normalize-path.ts
│ │ └── prompt-builder.ts
│ └── views
│ └── prompt
│ ├── backend
│ │ ├── message-handlers
│ │ │ ├── handle-open-prompt-pasted-text.ts
│ │ │ ├── handle-open-website.ts
│ │ │ ├── handle-paste-url.ts
│ │ │ ├── handle-save-prompt-pasted-text.ts
│ │ │ ├── index.ts
│ │ │ └── utils
│ │ │ └── build-prompt-payload.ts
│ │ ├── prompt-view-provider.ts
│ │ └── utils
│ │ ├── persistent-text-storage.ts
│ │ ├── symbols
│ │ │ ├── pasted-text
│ │ │ │ └── replace-pasted-text-symbol.ts
│ │ │ ├── replace-symbols.ts
│ │ │ └── website
│ │ │ └── replace-website-symbol.ts
│ │ └── website-fetcher.ts
│ ├── frontend
│ │ ├── Main
│ │ │ ├── Main.tsx
│ │ │ └── MainView
│ │ │ └── MainView.tsx
│ │ ├── Prompt.tsx
│ │ └── hooks
│ │ └── use-prompt
│ │ └── use-prompt.ts
│ └── types
│ └── messages.ts
└── packages
├── shared
│ └── src
│ └── utils
│ └── simplify-prompt-symbols
│ └── simplify-prompt-symbols.ts
└── ui
└── src
└── components
└── editor
└── common
└── prompts
├── PromptField
│ ├── PromptField.tsx
│ └── hooks
│ └── use-handlers
│ ├── handle-paste.ts
│ └── utils.ts
└── shared
└── symbols
├── get-highlighted-text.tsx
├── position-mapping.ts
├── reconstruct-raw-value.ts
└── use-symbol-deletion.ts1 parent 3d2a608 commit cecdaf0
21 files changed
Lines changed: 260 additions & 147 deletions
File tree
- apps/editor/src/views/prompt
- backend
- message-handlers
- utils
- symbols
- pasted-text
- website
- frontend
- Main
- MainView
- hooks/use-prompt
- types
- packages
- ui/src/components/editor/common/prompts
- PromptField
- hooks/use-handlers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
17 | 32 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
22 | 37 | | |
23 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
24 | 48 | | |
25 | 49 | | |
26 | 50 | | |
| |||
78 | 102 | | |
79 | 103 | | |
80 | 104 | | |
81 | | - | |
| 105 | + | |
82 | 106 | | |
83 | 107 | | |
84 | 108 | | |
| |||
101 | 125 | | |
102 | 126 | | |
103 | 127 | | |
104 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
105 | 133 | | |
106 | 134 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 4 | + | |
| 5 | + | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
| |||
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
33 | 26 | | |
34 | 27 | | |
35 | 28 | | |
| |||
41 | 34 | | |
42 | 35 | | |
43 | 36 | | |
| 37 | + | |
| 38 | + | |
44 | 39 | | |
45 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
53 | 71 | | |
54 | 72 | | |
55 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | 1 | | |
6 | 2 | | |
7 | 3 | | |
| 4 | + | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
18 | 16 | | |
19 | 17 | | |
20 | | - | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
| 867 | + | |
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
| 871 | + | |
872 | 872 | | |
873 | 873 | | |
874 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
0 commit comments