[PR #466] [CLOSED] feat: export local and view exported & project sessions in web UI #9623

Closed
opened 2026-02-16 18:13:52 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/466
Author: @ndraiman
Created: 6/27/2025
Status: Closed

Base: devHead: ndraiman/export-session


📝 Commits (10+)

  • 574d576 Added ability to export and view exported and project sessions
  • a93ef1f Share.tsx - fixed sortTodosByStatus throwing when todos are undefined
  • 430915b Updated SessionsList to display exported date and time for exported sessions
  • 4ab58b8 Fixed conflicts - need client SDK regeneration for Export
  • 894a8e9 Fixed local session utils
  • 55b618e TEMP - Implement temporary HTTP workaround for session export in TUI
  • 22f0b3c Adjust font size for session title in local index page
  • da14d49 Update font size for session title in local project page
  • 9e7e44c Split local and project routes
  • 1ad34c0 cleanup

📊 Changes

30 files changed (+1569 additions, -0 deletions)

View changed files

📝 bun.lock (+5 -0)
📝 packages/opencode/src/server/server.ts (+103 -0)
📝 packages/opencode/src/session/index.ts (+86 -0)
📝 packages/tui/internal/commands/command.go (+6 -0)
📝 packages/tui/internal/tui/tui.go (+69 -0)
📝 packages/web/package.json (+1 -0)
packages/web/src/components/SessionsList.tsx (+92 -0)
packages/web/src/components/SessionsList/EmptyState.module.css (+7 -0)
packages/web/src/components/SessionsList/EmptyState.tsx (+9 -0)
packages/web/src/components/SessionsList/ErrorState.module.css (+14 -0)
packages/web/src/components/SessionsList/ErrorState.tsx (+15 -0)
packages/web/src/components/SessionsList/Header.module.css (+84 -0)
packages/web/src/components/SessionsList/Header.tsx (+34 -0)
packages/web/src/components/SessionsList/HelpSection.module.css (+44 -0)
packages/web/src/components/SessionsList/HelpSection.tsx (+14 -0)
packages/web/src/components/SessionsList/SessionsList.module.css (+23 -0)
packages/web/src/components/SessionsList/Table.module.css (+211 -0)
packages/web/src/components/SessionsList/Table.tsx (+97 -0)
packages/web/src/components/SessionsList/columns.tsx (+104 -0)
packages/web/src/components/SessionsList/index.ts (+2 -0)

...and 10 more files

📄 Description

Draft PR: Session Export and Local Viewing

Looking For Feedback

Note

This is a draft PR looking for feedback on the implementation approach and user experience.

Current Draft Limitation:

  • Need to run opencode serve.
  • Need to run web ui dev server bun --cwd packages/web dev.
  • Web UI port is hardcoded

https://github.com/user-attachments/assets/24a0cdfd-1093-4c07-80b4-98539f207f81

Summary

This PR adds the ability to export chat sessions to local storage and view them through a local web interface. Users can now:

  • Export active sessions to local JSON files stored in the config directory
  • Access exported sessions via local URLs (e.g., http://localhost:4321/local/{sessionId})
  • Browse and manage exported sessions through new API endpoints

Key Changes

Server

  • New API endpoints (packages/opencode/src/server/server.ts):

    • POST /session/:id/export - Export a session to local storage
    • GET /session/export - List all exported sessions
    • GET /session/:id/export - Retrieve specific exported session data
  • Session export functionality (packages/opencode/src/session/index.ts):

    • Export sessions as JSON files to ~/.config/opencode/session-exports/
    • Include session metadata, messages, and export timestamp
    • Generate local URLs for web access

TUI

  • New export command (packages/tui/internal/commands/command.go):
    • Added SessionExportCommand with trigger "export"
  • Export functionality (packages/tui/internal/tui/tui.go):
    • Export current session and copy local URL to clipboard
    • Success/error toast notifications
  • Generated client updates - Updated OpenAPI spec and Go client code

User Experience

  1. User runs export command in active session
  2. Session gets exported to local JSON file
  3. Local URL (http://localhost:4321/local/{sessionId}) copied to clipboard
  4. User can access exported session via browser at that URL

Technical Details

  • Export files stored in ~/.config/opencode/session-exports/{sessionId}.json
  • Local web server runs on port 4321
  • Exported sessions include full conversation history and metadata
  • Error handling for missing sessions and file operations

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/466 **Author:** [@ndraiman](https://github.com/ndraiman) **Created:** 6/27/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `ndraiman/export-session` --- ### 📝 Commits (10+) - [`574d576`](https://github.com/anomalyco/opencode/commit/574d576273711bf6b789b1e19596303602fe13b4) Added ability to export and view exported and project sessions - [`a93ef1f`](https://github.com/anomalyco/opencode/commit/a93ef1f237511026eac8f9a8b770bca14a533e93) Share.tsx - fixed `sortTodosByStatus` throwing when `todos` are undefined - [`430915b`](https://github.com/anomalyco/opencode/commit/430915ba9e30fd3728866dd25c8134d4b37fdbfb) Updated SessionsList to display exported date and time for exported sessions - [`4ab58b8`](https://github.com/anomalyco/opencode/commit/4ab58b879e340d3c3e39e40eaf7c2a79f25e3df9) Fixed conflicts - need client SDK regeneration for Export - [`894a8e9`](https://github.com/anomalyco/opencode/commit/894a8e99a88523d8d677411dd40a8159d1390f74) Fixed local session utils - [`55b618e`](https://github.com/anomalyco/opencode/commit/55b618e75c44cb9b963bd03b6ad25e2c2dea530c) TEMP - Implement temporary HTTP workaround for session export in TUI - [`22f0b3c`](https://github.com/anomalyco/opencode/commit/22f0b3c19282f0a6e68099eebde7c137ef3aea14) Adjust font size for session title in local index page - [`da14d49`](https://github.com/anomalyco/opencode/commit/da14d49d8af4c6d259862564086157f1fb3339b2) Update font size for session title in local project page - [`9e7e44c`](https://github.com/anomalyco/opencode/commit/9e7e44c86984c3116e95c666aa161f9195730bd7) Split `local` and `project` routes - [`1ad34c0`](https://github.com/anomalyco/opencode/commit/1ad34c07808d2a4fe536e5d2e74cbd48bdc31715) cleanup ### 📊 Changes **30 files changed** (+1569 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `bun.lock` (+5 -0) 📝 `packages/opencode/src/server/server.ts` (+103 -0) 📝 `packages/opencode/src/session/index.ts` (+86 -0) 📝 `packages/tui/internal/commands/command.go` (+6 -0) 📝 `packages/tui/internal/tui/tui.go` (+69 -0) 📝 `packages/web/package.json` (+1 -0) ➕ `packages/web/src/components/SessionsList.tsx` (+92 -0) ➕ `packages/web/src/components/SessionsList/EmptyState.module.css` (+7 -0) ➕ `packages/web/src/components/SessionsList/EmptyState.tsx` (+9 -0) ➕ `packages/web/src/components/SessionsList/ErrorState.module.css` (+14 -0) ➕ `packages/web/src/components/SessionsList/ErrorState.tsx` (+15 -0) ➕ `packages/web/src/components/SessionsList/Header.module.css` (+84 -0) ➕ `packages/web/src/components/SessionsList/Header.tsx` (+34 -0) ➕ `packages/web/src/components/SessionsList/HelpSection.module.css` (+44 -0) ➕ `packages/web/src/components/SessionsList/HelpSection.tsx` (+14 -0) ➕ `packages/web/src/components/SessionsList/SessionsList.module.css` (+23 -0) ➕ `packages/web/src/components/SessionsList/Table.module.css` (+211 -0) ➕ `packages/web/src/components/SessionsList/Table.tsx` (+97 -0) ➕ `packages/web/src/components/SessionsList/columns.tsx` (+104 -0) ➕ `packages/web/src/components/SessionsList/index.ts` (+2 -0) _...and 10 more files_ </details> ### 📄 Description # Draft PR: Session Export and Local Viewing ## Looking For Feedback >[!Note] > This is a draft PR looking for feedback on the implementation approach and user experience. > > **Current Draft Limitation:** > - Need to run `opencode serve`. > - Need to run web ui dev server `bun --cwd packages/web dev`. > - Can also build using [astro node adapter](https://docs.astro.build/en/guides/integrations-guide/node/) and run with `bun` > - Web UI port is hardcoded https://github.com/user-attachments/assets/24a0cdfd-1093-4c07-80b4-98539f207f81 ## Summary This PR adds the ability to export chat sessions to local storage and view them through a local web interface. Users can now: - Export active sessions to local JSON files stored in the config directory - Access exported sessions via local URLs (e.g., `http://localhost:4321/local/{sessionId}`) - Browse and manage exported sessions through new API endpoints ## Key Changes ### Server - **New API endpoints** (`packages/opencode/src/server/server.ts`): - `POST /session/:id/export` - Export a session to local storage - `GET /session/export` - List all exported sessions - `GET /session/:id/export` - Retrieve specific exported session data - **Session export functionality** (`packages/opencode/src/session/index.ts`): - Export sessions as JSON files to `~/.config/opencode/session-exports/` - Include session metadata, messages, and export timestamp - Generate local URLs for web access ### TUI - **New export command** (`packages/tui/internal/commands/command.go`): - Added `SessionExportCommand` with trigger "export" - **Export functionality** (`packages/tui/internal/tui/tui.go`): - Export current session and copy local URL to clipboard - Success/error toast notifications - **Generated client updates** - Updated OpenAPI spec and Go client code ## User Experience 1. User runs `export` command in active session 2. Session gets exported to local JSON file 3. Local URL (`http://localhost:4321/local/{sessionId}`) copied to clipboard 4. User can access exported session via browser at that URL ## Technical Details - Export files stored in `~/.config/opencode/session-exports/{sessionId}.json` - Local web server runs on port 4321 - Exported sessions include full conversation history and metadata - Error handling for missing sessions and file operations --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:52 -05:00
yindo closed this issue 2026-02-16 18:13:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9623