MCPcopy Index your code
hub / github.com/anomalyco/opencode / build

Function build

packages/opencode/src/cli/cmd/run/splash.ts:174–265  ·  view source on GitHub ↗
(input: SplashWriterInput, kind: "entry" | "exit", ctx: ScrollbackRenderContext)

Source from the content-addressed store, hash-verified

172}
173
174function build(input: SplashWriterInput, kind: "entry" | "exit", ctx: ScrollbackRenderContext): ScrollbackSnapshot {
175 const width = Math.max(1, ctx.width)
176 const meta = splashMeta(input)
177 const lines: Array<{ left: number; top: number; text: string; fg: ColorInput; bg?: ColorInput; attrs?: number }> = []
178 const left = input.theme.left
179 const right = input.theme.right
180 const leftShadow = input.theme.leftShadow
181 let height = 1
182
183 if (kind === "entry") {
184 const mark = go.right.slice(1)
185 const top = 1
186 const body_left = (mark[0]?.length ?? 0) + 2
187
188 for (let i = 0; i < mark.length; i += 1) {
189 draw(lines, mark[i] ?? "", {
190 left: 0,
191 top: top + i,
192 fg: left,
193 shadow: leftShadow,
194 })
195 }
196
197 push(lines, body_left, top, "OpenCode", right, undefined, TextAttributes.BOLD)
198 if (input.detail) {
199 push(
200 lines,
201 body_left,
202 top + 1,
203 Locale.truncateMiddle(input.detail, Math.max(1, width - body_left)),
204 left,
205 undefined,
206 )
207 }
208 height = top + mark.length
209 }
210
211 if (kind === "exit") {
212 const mark = go.right.slice(1)
213 const top = 1
214 const body_left = (mark[0]?.length ?? 0) + 2
215 const session = "Session "
216 const label = "Continue "
217
218 for (let i = 0; i < mark.length; i += 1) {
219 draw(lines, mark[i] ?? "", {
220 left: 0,
221 top: top + i,
222 fg: left,
223 shadow: leftShadow,
224 })
225 }
226
227 if (input.showSession !== false) {
228 push(lines, body_left, top, session, left, undefined, TextAttributes.DIM)
229 push(lines, body_left + session.length, top, meta.title, right, undefined, TextAttributes.BOLD)
230 }
231

Callers 2

entrySplashFunction · 0.70
exitSplashFunction · 0.70

Calls 4

splashMetaFunction · 0.85
drawFunction · 0.70
pushFunction · 0.70
writeFunction · 0.70

Tested by

no test coverage detected