@jonsoc/app 1.1.34

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.
Files changed (139) hide show
  1. package/AGENTS.md +30 -0
  2. package/README.md +51 -0
  3. package/bunfig.toml +2 -0
  4. package/e2e/context.spec.ts +45 -0
  5. package/e2e/file-open.spec.ts +23 -0
  6. package/e2e/file-viewer.spec.ts +35 -0
  7. package/e2e/fixtures.ts +40 -0
  8. package/e2e/home.spec.ts +21 -0
  9. package/e2e/model-picker.spec.ts +43 -0
  10. package/e2e/navigation.spec.ts +9 -0
  11. package/e2e/palette.spec.ts +15 -0
  12. package/e2e/prompt-mention.spec.ts +26 -0
  13. package/e2e/prompt-slash-open.spec.ts +22 -0
  14. package/e2e/prompt.spec.ts +62 -0
  15. package/e2e/session.spec.ts +21 -0
  16. package/e2e/settings.spec.ts +44 -0
  17. package/e2e/sidebar.spec.ts +21 -0
  18. package/e2e/terminal-init.spec.ts +25 -0
  19. package/e2e/terminal.spec.ts +16 -0
  20. package/e2e/tsconfig.json +8 -0
  21. package/e2e/utils.ts +38 -0
  22. package/happydom.ts +75 -0
  23. package/index.html +23 -0
  24. package/package.json +72 -0
  25. package/playwright.config.ts +43 -0
  26. package/public/_headers +17 -0
  27. package/public/apple-touch-icon-v3.png +1 -0
  28. package/public/apple-touch-icon.png +1 -0
  29. package/public/favicon-96x96-v3.png +1 -0
  30. package/public/favicon-96x96.png +1 -0
  31. package/public/favicon-v3.ico +1 -0
  32. package/public/favicon-v3.svg +1 -0
  33. package/public/favicon.ico +1 -0
  34. package/public/favicon.svg +1 -0
  35. package/public/oc-theme-preload.js +28 -0
  36. package/public/site.webmanifest +1 -0
  37. package/public/social-share-zen.png +1 -0
  38. package/public/social-share.png +1 -0
  39. package/public/web-app-manifest-192x192.png +1 -0
  40. package/public/web-app-manifest-512x512.png +1 -0
  41. package/script/e2e-local.ts +143 -0
  42. package/src/addons/serialize.test.ts +319 -0
  43. package/src/addons/serialize.ts +591 -0
  44. package/src/app.tsx +150 -0
  45. package/src/components/dialog-connect-provider.tsx +428 -0
  46. package/src/components/dialog-edit-project.tsx +259 -0
  47. package/src/components/dialog-fork.tsx +104 -0
  48. package/src/components/dialog-manage-models.tsx +59 -0
  49. package/src/components/dialog-select-directory.tsx +208 -0
  50. package/src/components/dialog-select-file.tsx +196 -0
  51. package/src/components/dialog-select-mcp.tsx +96 -0
  52. package/src/components/dialog-select-model-unpaid.tsx +130 -0
  53. package/src/components/dialog-select-model.tsx +162 -0
  54. package/src/components/dialog-select-provider.tsx +70 -0
  55. package/src/components/dialog-select-server.tsx +249 -0
  56. package/src/components/dialog-settings.tsx +112 -0
  57. package/src/components/file-tree.tsx +112 -0
  58. package/src/components/link.tsx +17 -0
  59. package/src/components/model-tooltip.tsx +91 -0
  60. package/src/components/prompt-input.tsx +2076 -0
  61. package/src/components/session/index.ts +5 -0
  62. package/src/components/session/session-context-tab.tsx +428 -0
  63. package/src/components/session/session-header.tsx +343 -0
  64. package/src/components/session/session-new-view.tsx +93 -0
  65. package/src/components/session/session-sortable-tab.tsx +56 -0
  66. package/src/components/session/session-sortable-terminal-tab.tsx +187 -0
  67. package/src/components/session-context-usage.tsx +113 -0
  68. package/src/components/session-lsp-indicator.tsx +42 -0
  69. package/src/components/session-mcp-indicator.tsx +34 -0
  70. package/src/components/settings-agents.tsx +15 -0
  71. package/src/components/settings-commands.tsx +15 -0
  72. package/src/components/settings-general.tsx +306 -0
  73. package/src/components/settings-keybinds.tsx +437 -0
  74. package/src/components/settings-mcp.tsx +15 -0
  75. package/src/components/settings-models.tsx +15 -0
  76. package/src/components/settings-permissions.tsx +234 -0
  77. package/src/components/settings-providers.tsx +15 -0
  78. package/src/components/terminal.tsx +315 -0
  79. package/src/components/titlebar.tsx +156 -0
  80. package/src/context/command.tsx +308 -0
  81. package/src/context/comments.tsx +140 -0
  82. package/src/context/file.tsx +409 -0
  83. package/src/context/global-sdk.tsx +106 -0
  84. package/src/context/global-sync.tsx +898 -0
  85. package/src/context/language.tsx +161 -0
  86. package/src/context/layout-scroll.test.ts +73 -0
  87. package/src/context/layout-scroll.ts +118 -0
  88. package/src/context/layout.tsx +648 -0
  89. package/src/context/local.tsx +578 -0
  90. package/src/context/notification.tsx +173 -0
  91. package/src/context/permission.tsx +167 -0
  92. package/src/context/platform.tsx +59 -0
  93. package/src/context/prompt.tsx +245 -0
  94. package/src/context/sdk.tsx +48 -0
  95. package/src/context/server.tsx +214 -0
  96. package/src/context/settings.tsx +166 -0
  97. package/src/context/sync.tsx +320 -0
  98. package/src/context/terminal.tsx +267 -0
  99. package/src/custom-elements.d.ts +17 -0
  100. package/src/entry.tsx +76 -0
  101. package/src/env.d.ts +8 -0
  102. package/src/hooks/use-providers.ts +31 -0
  103. package/src/i18n/ar.ts +656 -0
  104. package/src/i18n/br.ts +667 -0
  105. package/src/i18n/da.ts +582 -0
  106. package/src/i18n/de.ts +591 -0
  107. package/src/i18n/en.ts +665 -0
  108. package/src/i18n/es.ts +585 -0
  109. package/src/i18n/fr.ts +592 -0
  110. package/src/i18n/ja.ts +579 -0
  111. package/src/i18n/ko.ts +580 -0
  112. package/src/i18n/no.ts +602 -0
  113. package/src/i18n/pl.ts +661 -0
  114. package/src/i18n/ru.ts +664 -0
  115. package/src/i18n/zh.ts +574 -0
  116. package/src/i18n/zht.ts +570 -0
  117. package/src/index.css +57 -0
  118. package/src/index.ts +2 -0
  119. package/src/pages/directory-layout.tsx +57 -0
  120. package/src/pages/error.tsx +290 -0
  121. package/src/pages/home.tsx +125 -0
  122. package/src/pages/layout.tsx +2599 -0
  123. package/src/pages/session.tsx +2505 -0
  124. package/src/sst-env.d.ts +10 -0
  125. package/src/utils/dom.ts +51 -0
  126. package/src/utils/id.ts +99 -0
  127. package/src/utils/index.ts +1 -0
  128. package/src/utils/perf.ts +135 -0
  129. package/src/utils/persist.ts +377 -0
  130. package/src/utils/prompt.ts +203 -0
  131. package/src/utils/same.ts +6 -0
  132. package/src/utils/solid-dnd.tsx +55 -0
  133. package/src/utils/sound.ts +110 -0
  134. package/src/utils/speech.ts +302 -0
  135. package/src/utils/worktree.ts +58 -0
  136. package/sst-env.d.ts +9 -0
  137. package/tsconfig.json +26 -0
  138. package/vite.config.ts +15 -0
  139. package/vite.js +26 -0
@@ -0,0 +1,161 @@
1
+ import * as i18n from "@solid-primitives/i18n"
2
+ import { createEffect, createMemo } from "solid-js"
3
+ import { createStore } from "solid-js/store"
4
+ import { createSimpleContext } from "@jonsoc/ui/context"
5
+ import { Persist, persisted } from "@/utils/persist"
6
+ import { dict as en } from "@/i18n/en"
7
+ import { dict as zh } from "@/i18n/zh"
8
+ import { dict as zht } from "@/i18n/zht"
9
+ import { dict as ko } from "@/i18n/ko"
10
+ import { dict as de } from "@/i18n/de"
11
+ import { dict as es } from "@/i18n/es"
12
+ import { dict as fr } from "@/i18n/fr"
13
+ import { dict as da } from "@/i18n/da"
14
+ import { dict as ja } from "@/i18n/ja"
15
+ import { dict as pl } from "@/i18n/pl"
16
+ import { dict as ru } from "@/i18n/ru"
17
+ import { dict as ar } from "@/i18n/ar"
18
+ import { dict as no } from "@/i18n/no"
19
+ import { dict as br } from "@/i18n/br"
20
+ import { dict as uiEn } from "@jonsoc/ui/i18n/en"
21
+ import { dict as uiZh } from "@jonsoc/ui/i18n/zh"
22
+ import { dict as uiZht } from "@jonsoc/ui/i18n/zht"
23
+ import { dict as uiKo } from "@jonsoc/ui/i18n/ko"
24
+ import { dict as uiDe } from "@jonsoc/ui/i18n/de"
25
+ import { dict as uiEs } from "@jonsoc/ui/i18n/es"
26
+ import { dict as uiFr } from "@jonsoc/ui/i18n/fr"
27
+ import { dict as uiDa } from "@jonsoc/ui/i18n/da"
28
+ import { dict as uiJa } from "@jonsoc/ui/i18n/ja"
29
+ import { dict as uiPl } from "@jonsoc/ui/i18n/pl"
30
+ import { dict as uiRu } from "@jonsoc/ui/i18n/ru"
31
+ import { dict as uiAr } from "@jonsoc/ui/i18n/ar"
32
+ import { dict as uiNo } from "@jonsoc/ui/i18n/no"
33
+ import { dict as uiBr } from "@jonsoc/ui/i18n/br"
34
+
35
+ export type Locale = "en" | "zh" | "zht" | "ko" | "de" | "es" | "fr" | "da" | "ja" | "pl" | "ru" | "ar" | "no" | "br"
36
+
37
+ type RawDictionary = typeof en & typeof uiEn
38
+ type Dictionary = i18n.Flatten<RawDictionary>
39
+
40
+ const LOCALES: readonly Locale[] = ["en", "zh", "zht", "ko", "de", "es", "fr", "da", "ja", "pl", "ru", "ar", "no", "br"]
41
+
42
+ function detectLocale(): Locale {
43
+ if (typeof navigator !== "object") return "en"
44
+
45
+ const languages = navigator.languages?.length ? navigator.languages : [navigator.language]
46
+ for (const language of languages) {
47
+ if (!language) continue
48
+ if (language.toLowerCase().startsWith("zh")) {
49
+ if (language.toLowerCase().includes("hant")) return "zht"
50
+ return "zh"
51
+ }
52
+ if (language.toLowerCase().startsWith("ko")) return "ko"
53
+ if (language.toLowerCase().startsWith("de")) return "de"
54
+ if (language.toLowerCase().startsWith("es")) return "es"
55
+ if (language.toLowerCase().startsWith("fr")) return "fr"
56
+ if (language.toLowerCase().startsWith("da")) return "da"
57
+ if (language.toLowerCase().startsWith("ja")) return "ja"
58
+ if (language.toLowerCase().startsWith("pl")) return "pl"
59
+ if (language.toLowerCase().startsWith("ru")) return "ru"
60
+ if (language.toLowerCase().startsWith("ar")) return "ar"
61
+ if (
62
+ language.toLowerCase().startsWith("no") ||
63
+ language.toLowerCase().startsWith("nb") ||
64
+ language.toLowerCase().startsWith("nn")
65
+ )
66
+ return "no"
67
+ if (language.toLowerCase().startsWith("pt")) return "br"
68
+ }
69
+
70
+ return "en"
71
+ }
72
+
73
+ export const { use: useLanguage, provider: LanguageProvider } = createSimpleContext({
74
+ name: "Language",
75
+ init: () => {
76
+ const [store, setStore, _, ready] = persisted(
77
+ Persist.global("language", ["language.v1"]),
78
+ createStore({
79
+ locale: detectLocale() as Locale,
80
+ }),
81
+ )
82
+
83
+ const locale = createMemo<Locale>(() => {
84
+ if (store.locale === "zh") return "zh"
85
+ if (store.locale === "zht") return "zht"
86
+ if (store.locale === "ko") return "ko"
87
+ if (store.locale === "de") return "de"
88
+ if (store.locale === "es") return "es"
89
+ if (store.locale === "fr") return "fr"
90
+ if (store.locale === "da") return "da"
91
+ if (store.locale === "ja") return "ja"
92
+ if (store.locale === "pl") return "pl"
93
+ if (store.locale === "ru") return "ru"
94
+ if (store.locale === "ar") return "ar"
95
+ if (store.locale === "no") return "no"
96
+ if (store.locale === "br") return "br"
97
+ return "en"
98
+ })
99
+
100
+ createEffect(() => {
101
+ const current = locale()
102
+ if (store.locale === current) return
103
+ setStore("locale", current)
104
+ })
105
+
106
+ const base = i18n.flatten({ ...en, ...uiEn })
107
+ const dict = createMemo<Dictionary>(() => {
108
+ if (locale() === "en") return base
109
+ if (locale() === "zh") return { ...base, ...i18n.flatten({ ...zh, ...uiZh }) }
110
+ if (locale() === "zht") return { ...base, ...i18n.flatten({ ...zht, ...uiZht }) }
111
+ if (locale() === "de") return { ...base, ...i18n.flatten({ ...de, ...uiDe }) }
112
+ if (locale() === "es") return { ...base, ...i18n.flatten({ ...es, ...uiEs }) }
113
+ if (locale() === "fr") return { ...base, ...i18n.flatten({ ...fr, ...uiFr }) }
114
+ if (locale() === "da") return { ...base, ...i18n.flatten({ ...da, ...uiDa }) }
115
+ if (locale() === "ja") return { ...base, ...i18n.flatten({ ...ja, ...uiJa }) }
116
+ if (locale() === "pl") return { ...base, ...i18n.flatten({ ...pl, ...uiPl }) }
117
+ if (locale() === "ru") return { ...base, ...i18n.flatten({ ...ru, ...uiRu }) }
118
+ if (locale() === "ar") return { ...base, ...i18n.flatten({ ...ar, ...uiAr }) }
119
+ if (locale() === "no") return { ...base, ...i18n.flatten({ ...no, ...uiNo }) }
120
+ if (locale() === "br") return { ...base, ...i18n.flatten({ ...br, ...uiBr }) }
121
+ return { ...base, ...i18n.flatten({ ...ko, ...uiKo }) }
122
+ })
123
+
124
+ const t = i18n.translator(dict, i18n.resolveTemplate)
125
+
126
+ const labelKey: Record<Locale, keyof Dictionary> = {
127
+ en: "language.en",
128
+ zh: "language.zh",
129
+ zht: "language.zht",
130
+ ko: "language.ko",
131
+ de: "language.de",
132
+ es: "language.es",
133
+ fr: "language.fr",
134
+ da: "language.da",
135
+ ja: "language.ja",
136
+ pl: "language.pl",
137
+ ru: "language.ru",
138
+ ar: "language.ar",
139
+ no: "language.no",
140
+ br: "language.br",
141
+ }
142
+
143
+ const label = (value: Locale) => t(labelKey[value])
144
+
145
+ createEffect(() => {
146
+ if (typeof document !== "object") return
147
+ document.documentElement.lang = locale()
148
+ })
149
+
150
+ return {
151
+ ready,
152
+ locale,
153
+ locales: LOCALES,
154
+ label,
155
+ t,
156
+ setLocale(next: Locale) {
157
+ setStore("locale", next)
158
+ },
159
+ }
160
+ },
161
+ })
@@ -0,0 +1,73 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { createRoot } from "solid-js"
3
+ import { createStore } from "solid-js/store"
4
+ import { makePersisted, type SyncStorage } from "@solid-primitives/storage"
5
+ import { createScrollPersistence } from "./layout-scroll"
6
+
7
+ describe("createScrollPersistence", () => {
8
+ test("debounces persisted scroll writes", async () => {
9
+ const key = "layout-scroll.test"
10
+ const data = new Map<string, string>()
11
+ const writes: string[] = []
12
+ const stats = { flushes: 0 }
13
+
14
+ const storage = {
15
+ getItem: (k: string) => data.get(k) ?? null,
16
+ setItem: (k: string, v: string) => {
17
+ data.set(k, v)
18
+ if (k === key) writes.push(v)
19
+ },
20
+ removeItem: (k: string) => {
21
+ data.delete(k)
22
+ },
23
+ } as SyncStorage
24
+
25
+ await new Promise<void>((resolve, reject) => {
26
+ createRoot((dispose) => {
27
+ const [raw, setRaw] = createStore({
28
+ sessionView: {} as Record<string, { scroll: Record<string, { x: number; y: number }> }>,
29
+ })
30
+
31
+ const [store, setStore] = makePersisted([raw, setRaw], { name: key, storage })
32
+
33
+ const scroll = createScrollPersistence({
34
+ debounceMs: 30,
35
+ getSnapshot: (sessionKey) => store.sessionView[sessionKey]?.scroll,
36
+ onFlush: (sessionKey, next) => {
37
+ stats.flushes += 1
38
+
39
+ const current = store.sessionView[sessionKey]
40
+ if (!current) {
41
+ setStore("sessionView", sessionKey, { scroll: next })
42
+ return
43
+ }
44
+ setStore("sessionView", sessionKey, "scroll", (prev) => ({ ...(prev ?? {}), ...next }))
45
+ },
46
+ })
47
+
48
+ const run = async () => {
49
+ await new Promise((r) => setTimeout(r, 0))
50
+ writes.length = 0
51
+
52
+ for (const i of Array.from({ length: 100 }, (_, n) => n)) {
53
+ scroll.setScroll("session", "review", { x: 0, y: i })
54
+ }
55
+
56
+ await new Promise((r) => setTimeout(r, 120))
57
+
58
+ expect(stats.flushes).toBeGreaterThanOrEqual(1)
59
+ expect(writes.length).toBeGreaterThanOrEqual(1)
60
+ expect(writes.length).toBeLessThanOrEqual(2)
61
+ }
62
+
63
+ void run()
64
+ .then(resolve)
65
+ .catch(reject)
66
+ .finally(() => {
67
+ scroll.dispose()
68
+ dispose()
69
+ })
70
+ })
71
+ })
72
+ })
73
+ })
@@ -0,0 +1,118 @@
1
+ import { createStore, produce } from "solid-js/store"
2
+
3
+ export type SessionScroll = {
4
+ x: number
5
+ y: number
6
+ }
7
+
8
+ type ScrollMap = Record<string, SessionScroll>
9
+
10
+ type Options = {
11
+ debounceMs?: number
12
+ getSnapshot: (sessionKey: string) => ScrollMap | undefined
13
+ onFlush: (sessionKey: string, scroll: ScrollMap) => void
14
+ }
15
+
16
+ export function createScrollPersistence(opts: Options) {
17
+ const wait = opts.debounceMs ?? 200
18
+ const [cache, setCache] = createStore<Record<string, ScrollMap>>({})
19
+ const dirty = new Set<string>()
20
+ const timers = new Map<string, ReturnType<typeof setTimeout>>()
21
+
22
+ function clone(input?: ScrollMap) {
23
+ const out: ScrollMap = {}
24
+ if (!input) return out
25
+
26
+ for (const key of Object.keys(input)) {
27
+ const pos = input[key]
28
+ if (!pos) continue
29
+ out[key] = { x: pos.x, y: pos.y }
30
+ }
31
+
32
+ return out
33
+ }
34
+
35
+ function seed(sessionKey: string) {
36
+ if (cache[sessionKey]) return
37
+ setCache(sessionKey, clone(opts.getSnapshot(sessionKey)))
38
+ }
39
+
40
+ function scroll(sessionKey: string, tab: string) {
41
+ seed(sessionKey)
42
+ return cache[sessionKey]?.[tab] ?? opts.getSnapshot(sessionKey)?.[tab]
43
+ }
44
+
45
+ function schedule(sessionKey: string) {
46
+ const prev = timers.get(sessionKey)
47
+ if (prev) clearTimeout(prev)
48
+ timers.set(
49
+ sessionKey,
50
+ setTimeout(() => flush(sessionKey), wait),
51
+ )
52
+ }
53
+
54
+ function setScroll(sessionKey: string, tab: string, pos: SessionScroll) {
55
+ seed(sessionKey)
56
+
57
+ const prev = cache[sessionKey]?.[tab]
58
+ if (prev?.x === pos.x && prev?.y === pos.y) return
59
+
60
+ setCache(sessionKey, tab, { x: pos.x, y: pos.y })
61
+ dirty.add(sessionKey)
62
+ schedule(sessionKey)
63
+ }
64
+
65
+ function flush(sessionKey: string) {
66
+ const timer = timers.get(sessionKey)
67
+ if (timer) clearTimeout(timer)
68
+ timers.delete(sessionKey)
69
+
70
+ if (!dirty.has(sessionKey)) return
71
+ dirty.delete(sessionKey)
72
+
73
+ opts.onFlush(sessionKey, clone(cache[sessionKey]))
74
+ }
75
+
76
+ function flushAll() {
77
+ const keys = Array.from(dirty)
78
+ if (keys.length === 0) return
79
+
80
+ for (const key of keys) {
81
+ flush(key)
82
+ }
83
+ }
84
+
85
+ function drop(keys: string[]) {
86
+ if (keys.length === 0) return
87
+
88
+ for (const key of keys) {
89
+ const timer = timers.get(key)
90
+ if (timer) clearTimeout(timer)
91
+ timers.delete(key)
92
+ dirty.delete(key)
93
+ }
94
+
95
+ setCache(
96
+ produce((draft) => {
97
+ for (const key of keys) {
98
+ delete draft[key]
99
+ }
100
+ }),
101
+ )
102
+ }
103
+
104
+ function dispose() {
105
+ drop(Array.from(timers.keys()))
106
+ }
107
+
108
+ return {
109
+ cache,
110
+ drop,
111
+ flush,
112
+ flushAll,
113
+ scroll,
114
+ seed,
115
+ setScroll,
116
+ dispose,
117
+ }
118
+ }