Skip to content

Add enhanced session management with secure encrypted sessions - #7

Merged
YoungMayor merged 6 commits into
mainfrom
copilot/add-session-management-features
Oct 27, 2025
Merged

Add enhanced session management with secure encrypted sessions#7
YoungMayor merged 6 commits into
mainfrom
copilot/add-session-management-features

Conversation

Copilot AI commented Oct 26, 2025

Copy link
Copy Markdown
Contributor

Implements comprehensive session tracking improvements: default note behavior, task collection, session persistence/management, and encrypted sessions with password protection.

Changes

Enhanced Session Recording

  • Default notes: Text without command prefix automatically recorded as notes (no Note prefix required)
  • Task tracking: Task [description] collects todos, appended as markdown checklist on session end
  • END aliases: Accept END, QUIT, CLOSE (case-insensitive)
  • Session persistence: Sessions saved to ~/.config/mayrlabs/sessions/ with optional copy to pwd (user prompted)
  • Smart filenames: Sessions use format session-{timestamp}-{slugSummary}.md (max 32 chars) for easy identification
  • Summary display: Session lists show summaries extracted from filenames (e.g., "session-20240126-100000-bug-fix.md - Bug fix")

Session Management Commands

  • sessions: Interactive browser to copy/delete/clipboard sessions with summary display
  • session-clear: Bulk delete with 6-digit PIN confirmation
  • session-prune [days]: Delete sessions older than N days with PIN confirmation

Secure Sessions

  • secure-session-start: Password-protected sessions with XOR encryption
  • secure-sessions: Decrypt and manage encrypted sessions with summary display
  • Password hints stored in secure-sessions/password-hints.txt

Example

mayrlabs session-start "API refactor"
Session > Identified n+1 query problem in user endpoint
Session > Task Add database indexes
Session > AI Best practices for query optimization?
Session > Implemented connection pooling
Session > Task Update documentation
Session > END

Output session includes collected tasks:

## Tasks
- [ ] Add database indexes
- [ ] Update documentation

Session saved as: session-20240126-100000-api-refactor.md

When listing sessions:

? Select a session:
  > session-20240126-100000-api-refactor.md - Api refactor
    session-20240127-140000-bug-fix-auth.md - Bug fix auth

After session ends, user is prompted:

✅ Session ended and saved to: ~/.config/mayrlabs/sessions/session-...
? Copy session to current directory? (Y/n)

Implementation

Core changes in internal/commands/session.go:

  • Refactored startSession() into focused helper functions to reduce cyclomatic complexity from 42 to 8
  • Added slugify() for filename generation and extractSummaryFromFilename() for display
  • Added encryptSessionFile()/decryptSessionFile() for XOR cipher
  • 5 new Cobra commands for session lifecycle management

Encryption uses basic XOR—suitable for casual use. Production sensitive data should upgrade to AES.

Original prompt

For the session. The user shouldn't need to prefix notes with Note
Every message sent without AI or END should be regarded as Notes

We should also have

  • Task/Todo [Task] - Record a task
  • END/End/end/QUIT/Quit/quit/CLOSE/Close/close - All of these should end the session

The tasks should be at the bottom of the file. I am guessing you would not add them to the file until the user ENDs the session

And also, the session files should not be moved. They should be copied. This way we would have a list of session files as a form of backup. And at such the sessions should be stored on a sessions sub-folder and we can then do

  • mayrlabs sessions - To list session as a select
    • When a session is selected, user has option to copy file to pwd, delete, copy to clipboard, and go back
  • mayrlabs session-clear - To clear all sessions. This requires 6 digit pin confirmation
  • mayrlabs session-prune [days] - To delete every session older than [days] ago. This would first show the count of sessions and list of sessions and still requires a 6 digit pin confirmation

We should also add secure sessions

mayrlabs secure-session-start [summary]

The command prompts the user for a password and password hint.

There should be a mayrlabs/secure-sessions/password-hints.txt file where the files are mapped to the password hint.

It basically functions like a session. But the session file is encrypted when the session ends using the provided password

And when user does

mayrlabs secure-sessions and he selects a session and an option to copy file or content. He would need to provide the password to decrypt the file. Successful decryption would perform the action


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 26, 2025 23:27
…ment commands

Co-authored-by: YoungMayor <47315212+YoungMayor@users.noreply.github.com>
…ndling

Co-authored-by: YoungMayor <47315212+YoungMayor@users.noreply.github.com>
Co-authored-by: YoungMayor <47315212+YoungMayor@users.noreply.github.com>
Copilot AI changed the title [WIP] Add session management features for user notes Add enhanced session management with secure encrypted sessions Oct 26, 2025
Copilot AI requested a review from YoungMayor October 26, 2025 23:38
@YoungMayor

Copy link
Copy Markdown
Contributor

@copilot

golangci-lint run --fix
internal/commands/session.go:29:1: cyclomatic complexity 42 of func startSession is high (> 30) (gocyclo)
func startSession(args []string, secure bool, password string, passwordHint string) error {
^
1 issues:

  • gocyclo: 1

Please refactor the startSession command, break it down to reduce it's length and if/else checks.

Then on sessions and secure-sessions. After the session is ended, do not automatically copy the session to pwd. Ask the user if he would like to copy it to the current directory.

And when user does mayrlabs sessions or mayrlabs secure-sessions is it it possible to include the summary to the list.
I guess that means we would have to change the md file names to
session-{timestamp}-{truncatedSlugSummary}.md
The truncatedSlugSummary would be the slugified and truncated (max 32 chars) version of the summary

… and prompt before copying to pwd

Co-authored-by: YoungMayor <47315212+YoungMayor@users.noreply.github.com>

Copilot AI commented Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

@copilot

golangci-lint run --fix
...

Done in commit 48d7ac4:

  1. Refactored startSession - Reduced cyclomatic complexity from 42 to 8 by extracting helper functions (getSessionSummary, createSessionFile, handleAICommand, handleTaskCommand, handleNoteCommand, endSession, runSessionLoop)

  2. User prompt for pwd copy - After session ends, user is now asked "Copy session to current directory?" instead of automatic copy

  3. Summary in filenames - Sessions now use format session-{timestamp}-{slugSummary}.md (max 32 chars) and summaries are displayed in selection lists

Example:

  • Filename: session-20240126-100000-bug-fix-authentication.md
  • Displayed as: session-20240126-100000-bug-fix-authentication.md - Bug fix authentication

All tests passing ✅

@YoungMayor
YoungMayor marked this pull request as ready for review October 27, 2025 07:22
@YoungMayor
YoungMayor merged commit fe7d8aa into main Oct 27, 2025
1 check passed
@YoungMayor
YoungMayor deleted the copilot/add-session-management-features branch October 27, 2025 07:24
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