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

Function formatSessionTable

packages/opencode/src/cli/cmd/session.ts:118–135  ·  view source on GitHub ↗
(sessions: Session.Info[])

Source from the content-addressed store, hash-verified

116})
117
118function formatSessionTable(sessions: Session.Info[]): string {
119 const lines: string[] = []
120
121 const maxIdWidth = Math.max(20, ...sessions.map((s) => s.id.length))
122 const maxTitleWidth = Math.max(25, ...sessions.map((s) => s.title.length))
123
124 const header = `Session ID${" ".repeat(maxIdWidth - 10)} Title${" ".repeat(maxTitleWidth - 5)} Updated`
125 lines.push(header)
126 lines.push("─".repeat(header.length))
127 for (const session of sessions) {
128 const truncatedTitle = Locale.truncate(session.title, maxTitleWidth)
129 const timeStr = Locale.todayTimeOrDateTime(session.time.updated)
130 const line = `${session.id.padEnd(maxIdWidth)} ${truncatedTitle.padEnd(maxTitleWidth)} ${timeStr}`
131 lines.push(line)
132 }
133
134 return lines.join(EOL)
135}
136
137function formatSessionJSON(sessions: Session.Info[]): string {
138 const jsonData = sessions.map((session) => ({

Callers 1

session.tsFile · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected