Skip to content

Added action RecreateSession#119

Open
chris-adam wants to merge 1 commit into
masterfrom
PARAF-420/recreate_session
Open

Added action RecreateSession#119
chris-adam wants to merge 1 commit into
masterfrom
PARAF-420/recreate_session

Conversation

@chris-adam

@chris-adam chris-adam commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added RecreateSession action to support signing session management and recovery workflows.
    • Enhanced session display functionality to render multiple signing session badges for content items with improved session aggregation.
  • Bug Fixes

    • Normalized session label text capitalization to maintain consistent branding.
  • Tests

    • Expanded test suite with coverage for session recreation and session badge rendering scenarios.

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds a new "RecreateSession" action for e-sign sessions in mail approvals. It introduces new view classes for session recreation and removal, updates session display logic to show multiple badges, normalizes text formatting, and includes corresponding test coverage and localization updates.

Changes

Session Recreation & Multi-Session Management

Layer / File(s) Summary
Text Normalization
CHANGES.rst, imio/dms/mail/adapters.py, imio/dms/mail/tests/test_adapters.py, imio/dms/mail/tests/test_views.py, imio/dms/mail/locales/*
Changed domain label from "[ia.docs]" to "[iA.Docs]" across adapters, tests, and translation files for consistency.
Core View Implementation
imio/dms/mail/browser/views.py
Added ImioRemoveItemFromSessionView and ImioRecreateSessionView classes to handle session operations; ImioRecreateSessionView propagates new session IDs into OMApprovalAdapter annotations and triggers catalog reindexing.
Column Rendering
imio/dms/mail/columns.py
Rewrote SessionIdColumn.renderCell to aggregate and display multiple session badges per file, deriving session IDs from annotation structure and rendering as comma-joined dashboard links.
Configuration & Wiring
imio/dms/mail/browser/configure.zcml
Added esign-session-recreate browser:page entry mapping to ImioRecreateSessionView with may_recreate_session exposure.
Tests
imio/dms/mail/tests/test_columns.py, imio/dms/mail/tests/test_views.py
Added TestSessionIdColumn and TestImioRecreateSessionView test classes with setup helpers and validation methods for session rendering and recreation flows, including session annotation handling and catalog reindexing verification.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • IMIO/imio.dms.mail#104: Both PRs add and enhance SessionIdColumn/versions table support for e-sign sessions, with focus on multi-session display and table structure.
  • IMIO/imio.dms.mail#95: Both PRs modify e-sign session handling and annotation structure for mail approvals to support multi-session synchronization and session-driven workflows.
  • IMIO/imio.dms.mail#83: Both PRs extend esign session UI views and configuration in browser/views.py and configure.zcml to add new session-related actions.

Suggested reviewers

  • sgeulette

🐰 A session born anew, with IDs propagated true,
Multiple badges dance, in columns shining bright,
RecreateSession hops forth, making workflows light!
✨📋

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Added action RecreateSession' accurately reflects the main changes in the pull request, which introduces new RecreateSession functionality across multiple files including ZCML configuration, view classes, and comprehensive tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PARAF-420/recreate_session

Comment @coderabbitai help to get the list of available commands and usage tips.

@chris-adam chris-adam force-pushed the PARAF-420/recreate_session branch from 75f594a to 72d4d66 Compare May 6, 2026 13:35
@chris-adam chris-adam marked this pull request as ready for review May 6, 2026 13:35
@chris-adam chris-adam requested a review from sgeulette May 6, 2026 13:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@imio/dms/mail/browser/views.py`:
- Around line 581-582: Replace the blind append with logic that replaces the
recreated session id in approval.annot["session_ids"] instead of adding a
duplicate: locate the previous session id for this approval (the old id created
by the prior session—use the variable available in the recreate flow or derive
it from approval.annot["session_ids"]), replace that entry with new_id, and only
append new_id if no suitable old id is found; update code around
approval.annot["session_ids"] and new_id so the list length remains stable when
a single session is recreated.

In `@imio/dms/mail/tests/test_columns.py`:
- Around line 162-177: The assertions in test_columns.py hard-code session IDs
("0" and "1") while the tests create sessions using dynamic IDs (self.sid0,
self.sid1); update the expected HTML strings in the two asserts that call
self.column.renderCell(self.brain_b) and self.column.renderCell(self.brain_a) to
use format placeholders for the session id(s) and pass the appropriate variables
(use collection_uid and self.sid0 / self.sid1) so the anchor titles, link
fragment esign_session_id and visible badge text use the dynamic session IDs
instead of fixed numbers; locate the expectations near the calls to renderCell
for self.brain_b and self.brain_a to apply the change.

In `@imio/dms/mail/tests/test_views.py`:
- Around line 658-659: The test currently asserts recreated session titles by
positional indices (annot['sessions'][0] / [1]) which depends on global
numbering; change it to locate each session by its id using the existing old_id
and new_id variables and assert the title for that found session. Specifically,
iterate/search annot['sessions'] for the entry whose 'id' equals old_id and
assert its 'title' equals the expected string, and do the same for new_id, so
the checks rely on ids instead of fixed list positions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d703205-4f2e-4f28-ae62-0eebfdf53eaa

📥 Commits

Reviewing files that changed from the base of the PR and between be57181 and 72d4d66.

📒 Files selected for processing (12)
  • CHANGES.rst
  • imio/dms/mail/adapters.py
  • imio/dms/mail/browser/configure.zcml
  • imio/dms/mail/browser/views.py
  • imio/dms/mail/columns.py
  • imio/dms/mail/locales/en/LC_MESSAGES/imio.dms.mail.po
  • imio/dms/mail/locales/fr/LC_MESSAGES/imio.dms.mail.po
  • imio/dms/mail/locales/generated.pot
  • imio/dms/mail/locales/imio.dms.mail.pot
  • imio/dms/mail/tests/test_adapters.py
  • imio/dms/mail/tests/test_columns.py
  • imio/dms/mail/tests/test_views.py

Comment on lines +581 to +582
if new_id not in approval.annot["session_ids"]:
approval.annot["session_ids"].append(new_id)

@coderabbitai coderabbitai Bot May 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Replace the recreated session id instead of appending it.

This keeps the old session id in approval.annot["session_ids"] and adds new_id, so the approval annotation drifts from the global eSign annotation after a recreate. Downstream, imio/dms/mail/columns.py Line 250 uses len(self.table._approval.session_ids) as the multi-session gate, so a mail recreated from a single session will still be treated as multi-session. Remove or replace the previous id here instead of blindly appending the new one.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@imio/dms/mail/browser/views.py` around lines 581 - 582, Replace the blind
append with logic that replaces the recreated session id in
approval.annot["session_ids"] instead of adding a duplicate: locate the previous
session id for this approval (the old id created by the prior session—use the
variable available in the recreate flow or derive it from
approval.annot["session_ids"]), replace that entry with new_id, and only append
new_id if no suitable old id is found; update code around
approval.annot["session_ids"] and new_id so the list length remains stable when
a single session is recreated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the point. We want to keep track of the old session as well. The global esign annotation is already managed my the view RecreateSessionView

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chris-adam, understood — keeping the old session ID alongside the new one in approval.annot["session_ids"] is intentional for audit/history purposes, and the global eSign annotation lifecycle is already fully handled by the parent RecreateSessionView. I'll note this for future reviews.


✏️ Learnings added
Learnt from: chris-adam
Repo: IMIO/imio.dms.mail PR: 119
File: imio/dms/mail/browser/views.py:581-582
Timestamp: 2026-05-06T13:46:44.662Z
Learning: In `imio/dms/mail/browser/views.py`, `ImioRecreateSessionView.__call__` intentionally appends `new_id` to `approval.annot["session_ids"]` without removing the old session id. This is by design: the approval annotation keeps a full history of all session ids (old and new) for a given mail. The global eSign annotation (sessions dict, uids, etc.) is managed separately by the parent `RecreateSessionView.__call__`. Downstream code in `columns.py` that gates on `len(session_ids)` should therefore expect multiple ids per mail after a recreate.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: chris-adam
Repo: IMIO/imio.dms.mail PR: 106
File: imio/dms/mail/setuphandlers.py:535-537
Timestamp: 2026-03-24T10:40:48.436Z
Learning: In this repository’s `imio.dms.mail` package, `collective.quickupload` is pinned to version `1.11.1` via `versions-base.cfg`. At that pinned version, `IQuickUploadControlPanel` (from `collective.quickupload.browser.quickupload_settings`) includes the `set_sim_upload_limit` method, so review checks should not raise compatibility/API-existence concerns that would otherwise apply to newer major versions (e.g., collective.quickupload 2.x).

Comment thread imio/dms/mail/tests/test_columns.py
Comment thread imio/dms/mail/tests/test_views.py
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.

1 participant