opencode-ghost 1.0.3 → 1.0.5
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.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/composer.ts +5 -1
- package/src/placeholder.ts +5 -1
- package/src/tui.tsx +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.5] - 2026-10-08
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **tui:** Keep inline suggestions visible when the composer blurs
|
|
13
|
+
|
|
14
|
+
## [1.0.4] - 2026-10-08
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **tui:** Dim inline suggestions against the composer background
|
|
19
|
+
|
|
8
20
|
## [1.0.3] - 2026-10-08
|
|
9
21
|
|
|
10
22
|
### Fixed
|
|
@@ -203,6 +215,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
203
215
|
- Options for `model`, `acceptKeys`, `maxChars`, `idleDelayMs`,
|
|
204
216
|
`recentMessages` and `system`.
|
|
205
217
|
|
|
218
|
+
[1.0.5]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.4...v1.0.5
|
|
219
|
+
[1.0.4]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.3...v1.0.4
|
|
206
220
|
[1.0.3]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.2...v1.0.3
|
|
207
221
|
[1.0.2]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.1...v1.0.2
|
|
208
222
|
[1.0.1]: https://github.com/ozandogrultan/opencode-ghost/compare/v1.0.0...v1.0.1
|
package/package.json
CHANGED
package/src/composer.ts
CHANGED
|
@@ -33,12 +33,16 @@ export type EditorNode = {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function isEmptyComposer(editor: TextareaRenderable | undefined, focused: unknown, mode: string, normal: boolean, selected: boolean): boolean {
|
|
36
|
+
return !!editor && editor === focused && editor.focused && isEligibleComposer(editor, mode, normal, selected)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isEligibleComposer(editor: TextareaRenderable | undefined, mode: string, normal: boolean, selected: boolean): boolean {
|
|
36
40
|
if (!editor?.parent || editor.parent.isDestroyed) return false
|
|
37
41
|
const siblings = editor.parent.getChildren().filter((node) =>
|
|
38
42
|
!(node.id.startsWith("slot-layout-") && node.getChildren().length === 0),
|
|
39
43
|
)
|
|
40
44
|
if (siblings.length !== 2 || siblings[0] !== editor) return false
|
|
41
|
-
return normal && mode === "base" && !selected &&
|
|
45
|
+
return normal && mode === "base" && !selected && !editor.isDestroyed && editor.plainText === "" && !editor.hasSelection() && !editor.traits.capture?.includes("navigate") && editor.extmarks.getAll().length === 0
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
export function findComposerEditor<T extends EditorNode>(marker: EditorNode | undefined, isEditor: (node: EditorNode) => node is T, isComposer: (editor: T) => boolean): T | undefined {
|
package/src/placeholder.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { RGBA, type TextareaRenderable } from "@opentui/core"
|
|
2
2
|
|
|
3
3
|
export type PlaceholderEditor = Pick<TextareaRenderable, "placeholder" | "placeholderColor" | "plainText" | "isDestroyed">
|
|
4
4
|
|
|
5
|
+
export function dimPlaceholderColor(muted: RGBA): RGBA {
|
|
6
|
+
return RGBA.fromValues(muted.r, muted.g, muted.b, muted.a * 0.55)
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
export function createInlinePlaceholder() {
|
|
6
10
|
let owned: {
|
|
7
11
|
editor: PlaceholderEditor
|
package/src/tui.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** @jsxImportSource @opentui/solid */
|
|
2
2
|
import { Plugin } from "@opencode/plugin/tui"
|
|
3
3
|
import { TextareaRenderable, InputRenderable, type BoxRenderable, type Renderable } from "@opentui/core"
|
|
4
|
-
import { createEffect, createRoot, createSignal, on, onCleanup } from "solid-js"
|
|
5
|
-
import { composerAction, findComposerEditor, isEmptyComposer, keyName, observeComposerInput } from "./composer"
|
|
4
|
+
import { createEffect, createMemo, createRoot, createSignal, on, onCleanup } from "solid-js"
|
|
5
|
+
import { composerAction, findComposerEditor, isEligibleComposer, isEmptyComposer, keyName, observeComposerInput } from "./composer"
|
|
6
6
|
import { createLifecycle } from "./lifecycle"
|
|
7
7
|
import { acceptCommand, acceptShortcuts, ghostKeymapLayers } from "./keymap"
|
|
8
8
|
import { parseSuggestCommand, removedOptionKeys, resolveOptions, suggestionModel } from "./options"
|
|
9
|
-
import { createInlinePlaceholder } from "./placeholder"
|
|
9
|
+
import { createInlinePlaceholder, dimPlaceholderColor } from "./placeholder"
|
|
10
10
|
import { generateSuggestion } from "./stateless"
|
|
11
11
|
import { isEcho, normalize, resolveExplicitModel, resolveSmallModel } from "./text"
|
|
12
12
|
import { buildTranscript, lastUserText, suggestionPrompt, type TranscriptMessage } from "./transcript"
|
|
@@ -41,6 +41,7 @@ export default Plugin.define({
|
|
|
41
41
|
const [suggestion, setSuggestion] = createSignal<Suggestion | undefined>()
|
|
42
42
|
const [composerRevision, setComposerRevision] = createSignal(0)
|
|
43
43
|
const inline = createInlinePlaceholder()
|
|
44
|
+
const ghostColor = createMemo(() => dimPlaceholderColor(context.theme.text.muted))
|
|
44
45
|
|
|
45
46
|
let disposed = false
|
|
46
47
|
const composers = new Map<string, { marker: BoxRenderable; normal: () => boolean }>()
|
|
@@ -117,8 +118,8 @@ export default Plugin.define({
|
|
|
117
118
|
const syncInline = () => {
|
|
118
119
|
composerRevision()
|
|
119
120
|
const current = suggestion()
|
|
120
|
-
const editor = current ? getComposer(current.sessionID)
|
|
121
|
-
inline.sync(editor, current?.text,
|
|
121
|
+
const { editor, normal } = current ? getComposer(current.sessionID) : { editor: undefined, normal: false }
|
|
122
|
+
inline.sync(editor, current?.text, ghostColor(), !!current && canGenerate(current.sessionID) && isEligibleComposer(editor, context.keymap.mode.current(), normal, context.renderer.hasSelection))
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
const disposeRouteWatcher = createRoot((dispose) => {
|