Skip to content

feat: export local and view exported & project sessions in web UI #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 30 commits into
base: dev
Choose a base branch
from

Conversation

ndraiman
Copy link

@ndraiman ndraiman commented Jun 27, 2025

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
Screen.Recording.2025-06-27.at.18.12.03-720.mp4

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

@ndraiman ndraiman changed the title Added ability to export and view exported and project sessions LFF: Added ability to export and view exported/project sessions Jun 27, 2025
@ndraiman ndraiman force-pushed the ndraiman/export-session branch from f24c237 to 4ab58b8 Compare June 28, 2025 03:52
@ndraiman
Copy link
Author

Fixed conflicts with the new SDKs.
But now I need the Client SDK to be regenerated to support the Export commands

ndraiman added 2 commits June 28, 2025 07:00
- Commented out invalid Session.Export SDK call in TUI
- Added httpExportSession helper function with direct HTTP calls to localhost:4096
- Encapsulated HTTP logic for easy removal when SDK is regenerated
@ndraiman ndraiman changed the title LFF: Added ability to export and view exported/project sessions Added ability to export and view exported/project sessions in web Jun 28, 2025
@ndraiman ndraiman changed the title Added ability to export and view exported/project sessions in web feat: export local and view exported & project sessions in web UI Jun 28, 2025
@ndraiman
Copy link
Author

ndraiman commented Jun 28, 2025

Added a small POC in a separate branch with added Streaming support for messages API and allowing to invoke the agent from the Web UI:

Screen.Recording.2025-06-28.at.15.56.43.mp4

To view the diff with this PR click here

It's still rough and first draft, didn't want to modify the Share.tsx component for now to avoid conflicts with your changes.

Would love your opinion on this whole direction @thdxr @adamdotdevin 🙏🏻

@thdxr thdxr self-assigned this Jul 2, 2025
ndraiman added 9 commits July 7, 2025 23:09
…ionality

- Refactor SessionsList to use CSS modules and component structure
- Add project path subheader and search bar in title area
- Add "Last Updated" column with default sorting
- Implement column resizing functionality
- Apply design system width and styling improvements
- Add title text clamping for better display
- Clean up component structure and improve table styling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants