Skip to main content

Timeline

The Timeline API provides functionality for managing timeline channels, entries, and operations within Anchorpoint projects. The timeline serves as a central activity feed that tracks version control operations.

Usage

Timeline functions are accessed from both the anchorpoint and apsync modules:

from dataclasses import dataclass
from datetime import datetime
import anchorpoint as ap
import apsync as aps
import json

# Create a timeline channel entry
def create_timeline_entry(history_item):
entry = ap.TimelineChannelEntry()
entry.id = history_item["id"]
entry.time = int(datetime.fromisoformat(history_item["time"]).timestamp())
entry.message = history_item["message"]
entry.user_email = history_item["user_email"]
entry.has_details = True

# Set icon based on application type
if history_item["type"] == "cinema4d":
entry.icon = aps.Icon(":/icons/organizations-and-products/c4d.svg", "#F3D582")
entry.tooltip = "Published from Cinema 4D"
elif history_item["type"] == "maya":
entry.icon = aps.Icon(":/icons/organizations-and-products/maya.svg", "#F3D582")
entry.tooltip = "Published from Maya"
else:
entry.icon = aps.Icon(":/icons/user-interface/information.svg", "#70717A")
entry.tooltip = "Created a new file"

return entry

# Load timeline channel callback
def on_load_timeline_channel(channel_id: str, page_size: int, ctx):
if channel_id != "custom-channel":
return None

info = ap.TimelineChannelInfo(ctx.project_id)
history = get_history_entries(ctx) # Your custom history function
has_more = False
changes = None

return info, changes, history, has_more

# Update timeline entries
ap.update_timeline_entries("custom-channel", project_id, entries, has_more=False)

Anchorpoint Timeline Functions

Timeline Interface Management

  • open_timeline() Opens the timeline view in Anchorpoint.

  • close_timeline_sidebar() Closes the timeline sidebar.

  • reload_timeline_entries() Reloads all timeline entries.

  • update_timeline_last_seen() Updates the last seen timestamp for timeline.

Timeline Channel Operations

  • refresh_timeline_channel(channel_id) Refreshes a specific timeline channel.

    Arguments

    • channel_id (str): Timeline channel identifier
  • get_timeline_update_count() Gets the current timeline update count.

    Returns (int): Current update count

  • set_timeline_update_count(project_id, channel_id, count, since=0) Sets the timeline update count for a channel.

    Arguments

    • project_id (str): Project identifier
    • channel_id (str): Channel identifier
    • count (int): New update count
    • since (int): Timestamp since when to count updates
  • delete_timeline_channel_entries(channel_id, entry_ids) Deletes specific timeline entries.

    Arguments

    • channel_id (str): Channel identifier
    • entry_ids (list[str]): List of entry IDs to delete

Timeline Channel Actions

  • enable_timeline_channel_action(channel_id, action_id, enable=True) Enables or disables a timeline channel action.

    Arguments

    • channel_id (str): Channel identifier
    • action_id (str): Action identifier
    • enable (bool): Whether to enable the action
  • stop_timeline_channel_action_processing(channel_id, action_id) Stops processing of a timeline channel action.

    Arguments

    • channel_id (str): Channel identifier
    • action_id (str): Action identifier
  • timeline_channel_action_processing(channel_id, action_id, message=None) Indicates that a timeline channel action is processing.

    Arguments

    • channel_id (str): Channel identifier
    • action_id (str): Action identifier
    • message (str): Optional status message

Version Control Operations

  • vc_load_pending_changes(channel_id, reload=False) Loads pending version control changes.

    Arguments

    • channel_id (str): Channel identifier
    • reload (bool): Whether to force reload the changes
  • vc_resolve_conflicts(channel_id) Resolves version control conflicts.

    Arguments

    • channel_id (str): Channel identifier

Apsync Timeline Functions

Timeline Entries

  • add_timeline_entry(path, text) Adds an entry to the timeline.

    Arguments

    • path (str): File or folder path the entry relates to
    • text (str): Timeline entry text

Timeline Channel Management

  • add_timeline_channel(project, channel) Adds a timeline channel to a project.

    Arguments

  • remove_timeline_channel(project, channelId) Removes a timeline channel from a project.

    Arguments

    • project (class: Project): Project to remove channel from
    • channelId (str): Channel identifier to remove
  • update_timeline_channel(project, channel) Updates a timeline channel.

    Arguments

    • project (class: Project): Project containing the channel
    • channel (class: TimelineChannel): Updated channel object
  • get_timeline_channel(project, channelId) Gets a specific timeline channel.

    Arguments

    • project (class: Project): Project containing the channel
    • channelId (str): Channel identifier

    Returns (class: TimelineChannel or None): Channel object or None if not found

  • get_timeline_channels(project) Gets all timeline channels in a project.

    Arguments

    • project (class: Project): Project to get channels from

    Returns (list[class: TimelineChannel]): List of timeline channels

Timeline Classes

TimelineChannel Class

The TimelineChannel class represents a timeline channel within a project.

Properties

  • id (str): Unique identifier for the channel
  • name (str): Display name of the channel
  • description (str): Description of the channel's purpose

Examples

Basic Timeline Operations

import anchorpoint
import apsync

ctx = anchorpoint.get_context()

def basic_timeline_operations():
"""Demonstrate basic timeline operations"""

# Open timeline view
anchorpoint.open_timeline()

# Add entry for current action
apsync.add_timeline_entry(ctx.path, f"Processed {ctx.filename} with custom action")

# Get current project for channel operations
api = anchorpoint.get_api()
project = api.get_project()

if project:
# Get all timeline channels
channels = apsync.get_timeline_channels(project)
print(f"Project has {len(channels)} timeline channels:")

for channel in channels:
print(f" - {channel.name} (ID: {channel.id})")

# Update timeline display
anchorpoint.reload_timeline_entries()
anchorpoint.update_timeline_last_seen()

basic_timeline_operations()

Timeline Channel Management

import anchorpoint
import apsync

def manage_timeline_channels():
"""Demonstrate timeline channel management"""

api = anchorpoint.get_api()
project = api.get_project()

if not project:
print("Not in a project context")
return

# Get all existing channels
channels = apsync.get_timeline_channels(project)
print(f"Found {len(channels)} timeline channels:")

for channel in channels:
print(f" Channel: {channel.name}")
print(f" ID: {channel.id}")
print(f" Description: {channel.description}")

# Refresh each channel
anchorpoint.refresh_timeline_channel(channel.id)

# Create a new channel for version control operations
vc_channel = apsync.TimelineChannel()
vc_channel.name = "Version Control"
vc_channel.description = "Git operations and version control activities"

try:
apsync.add_timeline_channel(project, vc_channel)
print(f"\nCreated new channel: {vc_channel.name}")

# Add initial entry to the new channel
apsync.add_timeline_entry(project.path, "Version control channel initialized")

# Update the channel information
vc_channel.description = "Git operations, commits, and version control activities"
apsync.update_timeline_channel(project, vc_channel)
print("Updated channel description")

except Exception as e:
print(f"Error creating channel: {e}")

manage_timeline_channels()

Timeline Action Processing

import anchorpoint
import apsync
import time

ctx = anchorpoint.get_context()

def timeline_action_workflow():
"""Demonstrate timeline action processing workflow"""

# Simulate a long-running operation with timeline feedback
channel_id = "main_channel" # This would be a real channel ID
action_id = "batch_processor"

try:
# Indicate that processing is starting
anchorpoint.timeline_channel_action_processing(
channel_id,
action_id,
"Starting batch file processing..."
)

# Add timeline entry for the start of processing
apsync.add_timeline_entry(ctx.path, "Batch processing started")

# Simulate work with progress updates
for i in range(5):
time.sleep(1) # Simulate work
anchorpoint.timeline_channel_action_processing(
channel_id,
action_id,
f"Processing step {i+1}/5..."
)

# Complete the processing
apsync.add_timeline_entry(ctx.path, "Batch processing completed successfully")

# Stop the processing indicator
anchorpoint.stop_timeline_channel_action_processing(channel_id, action_id)

print("Timeline action workflow completed")

except Exception as e:
# Handle errors and update timeline
anchorpoint.log_error(f"Timeline action failed: {str(e)}")
apsync.add_timeline_entry(ctx.path, f"Batch processing failed: {str(e)}")

# Make sure to stop processing indicator even on error
try:
anchorpoint.stop_timeline_channel_action_processing(channel_id, action_id)
except:
pass

timeline_action_workflow()