MCPcopy Create free account
hub / github.com/anomalyco/opencode / pushPromptHistory

Function pushPromptHistory

packages/opencode/src/cli/cmd/run/prompt.shared.ts:73–94  ·  view source on GitHub ↗
(state: PromptHistoryState, prompt: RunPrompt)

Source from the content-addressed store, hash-verified

71}
72
73export function pushPromptHistory(state: PromptHistoryState, prompt: RunPrompt): PromptHistoryState {
74 if (!prompt.text.trim()) {
75 return state
76 }
77
78 const next = promptCopy(prompt)
79 if (state.items[state.items.length - 1] && promptSame(state.items[state.items.length - 1], next)) {
80 return {
81 ...state,
82 index: null,
83 draft: "",
84 }
85 }
86
87 const items = [...state.items, next].slice(-HISTORY_LIMIT)
88 return {
89 ...state,
90 items,
91 index: null,
92 draft: "",
93 }
94}
95
96export function movePromptHistory(state: PromptHistoryState, dir: -1 | 1, text: string, cursor: number): PromptMove {
97 if (state.items.length === 0) {

Callers 2

pushFunction · 0.90

Calls 2

promptCopyFunction · 0.85
promptSameFunction · 0.85

Tested by

no test coverage detected